diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-12 16:09:02 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-10-24 14:48:24 +0200 |
commit | 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (patch) | |
tree | e7f1d12ef5dae1e1142c3a8d0b681c1dbbb0de10 /server/controllers/static.ts | |
parent | 38a3ccc7f8ad0ea94362b58c732af7c387ab46be (diff) | |
download | PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.gz PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.zst PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.zip |
Put private videos under a specific subdirectory
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r-- | server/controllers/static.ts | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 33c429eb1..dc091455a 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -1,20 +1,34 @@ | |||
1 | import cors from 'cors' | 1 | import cors from 'cors' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | import { handleStaticError } from '@server/middlewares' | 3 | import { |
4 | asyncMiddleware, | ||
5 | ensureCanAccessPrivateVideoHLSFiles, | ||
6 | ensureCanAccessVideoPrivateWebTorrentFiles, | ||
7 | handleStaticError, | ||
8 | optionalAuthenticate | ||
9 | } from '@server/middlewares' | ||
4 | import { CONFIG } from '../initializers/config' | 10 | import { CONFIG } from '../initializers/config' |
5 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' | 11 | import { DIRECTORIES, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' |
6 | 12 | ||
7 | const staticRouter = express.Router() | 13 | const staticRouter = express.Router() |
8 | 14 | ||
9 | // Cors is very important to let other servers access torrent and video files | 15 | // Cors is very important to let other servers access torrent and video files |
10 | staticRouter.use(cors()) | 16 | staticRouter.use(cors()) |
11 | 17 | ||
12 | // Videos path for webseed | 18 | // WebTorrent/Classic videos |
19 | staticRouter.use( | ||
20 | STATIC_PATHS.PRIVATE_WEBSEED, | ||
21 | optionalAuthenticate, | ||
22 | asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles), | ||
23 | express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), | ||
24 | handleStaticError | ||
25 | ) | ||
13 | staticRouter.use( | 26 | staticRouter.use( |
14 | STATIC_PATHS.WEBSEED, | 27 | STATIC_PATHS.WEBSEED, |
15 | express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }), | 28 | express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }), |
16 | handleStaticError | 29 | handleStaticError |
17 | ) | 30 | ) |
31 | |||
18 | staticRouter.use( | 32 | staticRouter.use( |
19 | STATIC_PATHS.REDUNDANCY, | 33 | STATIC_PATHS.REDUNDANCY, |
20 | express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), | 34 | express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), |
@@ -23,8 +37,15 @@ staticRouter.use( | |||
23 | 37 | ||
24 | // HLS | 38 | // HLS |
25 | staticRouter.use( | 39 | staticRouter.use( |
40 | STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, | ||
41 | optionalAuthenticate, | ||
42 | asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles), | ||
43 | express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }), | ||
44 | handleStaticError | ||
45 | ) | ||
46 | staticRouter.use( | ||
26 | STATIC_PATHS.STREAMING_PLAYLISTS.HLS, | 47 | STATIC_PATHS.STREAMING_PLAYLISTS.HLS, |
27 | express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }), | 48 | express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, { fallthrough: false }), |
28 | handleStaticError | 49 | handleStaticError |
29 | ) | 50 | ) |
30 | 51 | ||