Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Migrate from webseed to web-videos

Chocobozzz34555bebf8e2
diff --git a/server/controllers/object-storage-proxy.ts b/server/controllers/object-storage-proxy.ts
index 0edde64fe9..d0c59bf93c 100644
--- a/server/controllers/object-storage-proxy.ts
+++ b/server/controllers/object-storage-proxy.ts
@@ -15,7 +15,8 @@ const objectStorageProxyRouter = express.Router()
objectStorageProxyRouter.use(cors())
-objectStorageProxyRouter.get(OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + ':filename',
+objectStorageProxyRouter.get(
+ [ OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + ':filename', OBJECT_STORAGE_PROXY_PATHS.LEGACY_PRIVATE_WEB_VIDEOS + ':filename' ],
ensurePrivateObjectStorageProxyIsEnabled,
optionalAuthenticate,
asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 5ce739bfc3..97caa8292d 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -29,13 +29,13 @@ const privateWebVideoStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUI
: []
staticRouter.use(
- STATIC_PATHS.PRIVATE_WEBSEED,
+ [ STATIC_PATHS.PRIVATE_WEB_VIDEOS, STATIC_PATHS.LEGACY_PRIVATE_WEB_VIDEOS ],
...privateWebVideoStaticMiddlewares,
express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }),
handleStaticError
)
staticRouter.use(
- STATIC_PATHS.WEBSEED,
+ [ STATIC_PATHS.WEB_VIDEOS, STATIC_PATHS.LEGACY_WEB_VIDEOS ],
express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }),
handleStaticError
)
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 5116c63969..03ae94d356 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -750,8 +750,13 @@ const STATIC_PATHS = {
// TODO: deprecated in v6, to remove
THUMBNAILS: '/static/thumbnails/',
- WEBSEED: '/static/webseed/',
- PRIVATE_WEBSEED: '/static/webseed/private/',
+ // Need to keep this legacy path for previously generated torrents
+ LEGACY_WEB_VIDEOS: '/static/webseed/',
+ WEB_VIDEOS: '/static/web-videos/',
+
+ // Need to keep this legacy path for previously generated torrents
+ LEGACY_PRIVATE_WEB_VIDEOS: '/static/webseed/private/',
+ PRIVATE_WEB_VIDEOS: '/static/web-videos/private/',
REDUNDANCY: '/static/redundancy/',
@@ -775,7 +780,9 @@ const LAZY_STATIC_PATHS = {
STORYBOARDS: '/lazy-static/storyboards/'
}
const OBJECT_STORAGE_PROXY_PATHS = {
- PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/',
+ // Need to keep this legacy path for previously generated torrents
+ LEGACY_PRIVATE_WEB_VIDEOS: '/object-storage-proxy/webseed/private/',
+ PRIVATE_WEB_VIDEOS: '/object-storage-proxy/web-videos/private/',
STREAMING_PLAYLISTS: {
PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
diff --git a/server/lib/object-storage/urls.ts b/server/lib/object-storage/urls.ts
index d25f840264..40619cd5a1 100644
--- a/server/lib/object-storage/urls.ts
+++ b/server/lib/object-storage/urls.ts
@@ -30,7 +30,7 @@ function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) {
}
function getWebVideoPrivateFileUrl (filename: string) {
- return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + filename
+ return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + filename
}
// ---------------------------------------------------------------------------
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 5e476f3c70..ee34ad2ff0 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -558,10 +558,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
private getWebVideoFileStaticPath (video: MVideo) {
if (isVideoInPrivateDirectory(video.privacy)) {
- return join(STATIC_PATHS.PRIVATE_WEBSEED, this.filename)
+ return join(STATIC_PATHS.PRIVATE_WEB_VIDEOS, this.filename)
}
- return join(STATIC_PATHS.WEBSEED, this.filename)
+ return join(STATIC_PATHS.WEB_VIDEOS, this.filename)
}
private getHLSFileStaticPath (video: MVideo) {
diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/server/tests/api/object-storage/video-static-file-privacy.ts
index 18d30a2f5e..64ab542a53 100644
--- a/server/tests/api/object-storage/video-static-file-privacy.ts
+++ b/server/tests/api/object-storage/video-static-file-privacy.ts
@@ -39,7 +39,7 @@ describe('Object storage for video static file privacy', function () {
const video = await server.videos.getWithToken({ id: uuid })
for (const file of video.files) {
- expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/webseed/private/')
+ expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/web-videos/private/')
await makeRawRequest({ url: file.fileUrl, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
}
@@ -538,7 +538,7 @@ describe('Object storage for video static file privacy', function () {
const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl)
await makeRawRequest({
- url: server.url + '/object-storage-proxy/webseed/private/' + webVideoFilename,
+ url: server.url + '/object-storage-proxy/web-videos/private/' + webVideoFilename,
token: server.accessToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 85da6acf53..0c5c272254 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -125,7 +125,7 @@ async function check1WebSeed (videoUUID?: string) {
if (!videoUUID) videoUUID = video1Server2.uuid
const webseeds = [
- `${servers[1].url}/static/webseed/`
+ `${servers[1].url}/static/web-videos/`
]
for (const server of servers) {
@@ -145,7 +145,7 @@ async function check2Webseeds (videoUUID?: string) {
const webseeds = [
`${servers[0].url}/static/redundancy/`,
- `${servers[1].url}/static/webseed/`
+ `${servers[1].url}/static/web-videos/`
]
for (const server of servers) {
diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/server/tests/api/videos/video-static-file-privacy.ts
index ec4c697db2..0a9864134f 100644
--- a/server/tests/api/videos/video-static-file-privacy.ts
+++ b/server/tests/api/videos/video-static-file-privacy.ts
@@ -41,7 +41,7 @@ describe('Test video static file privacy', function () {
for (const file of video.files) {
expect(file.fileDownloadUrl).to.not.include('/private/')
- expectStartWith(file.fileUrl, server.url + '/static/webseed/private/')
+ expectStartWith(file.fileUrl, server.url + '/static/web-videos/private/')
const torrent = await parseTorrentVideo(server, file)
expect(torrent.urlList).to.have.lengthOf(0)
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts
index b7f7a16138..e09bd60b57 100644
--- a/server/tests/shared/videos.ts
+++ b/server/tests/shared/videos.ts
@@ -51,11 +51,12 @@ async function completeWebVideoFilesCheck (options: {
expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`))
if (objectStorageBaseUrl && requiresAuth) {
- expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/object-storage-proxy/webseed/${privatePath}${nameReg}${extension}`))
+ const regexp = new RegExp(`${originServer.url}/object-storage-proxy/web-videos/${privatePath}${nameReg}${extension}`)
+ expect(file.fileUrl).to.match(regexp)
} else if (objectStorageBaseUrl) {
expectStartWith(file.fileUrl, objectStorageBaseUrl)
} else {
- expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/webseed/${privatePath}${nameReg}${extension}`))
+ expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/web-videos/${privatePath}${nameReg}${extension}`))
}
expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`))
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index b2303bdd12..2dfad99871 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -366,7 +366,7 @@ x-tagGroups:
- Runners
paths:
- '/static/webseed/{filename}':
+ '/static/web-videos/{filename}':
get:
tags:
- Static Video Files
@@ -378,11 +378,11 @@ paths:
description: successful operation
'404':
description: not found
- '/static/webseed/private/{filename}':
+ '/static/web-videos/private/{filename}':
get:
tags:
- Static Video Files
- summary: Get private Web Video video file
+ summary: Get private Web Video file
parameters:
- $ref: '#/components/parameters/staticFilename'
- $ref: '#/components/parameters/videoFileToken'
diff --git a/support/nginx/peertube b/support/nginx/peertube
index f5b9d131ae..822f6f9acf 100644
--- a/support/nginx/peertube
+++ b/support/nginx/peertube
@@ -199,7 +199,7 @@ server {
alias /var/www/peertube/peertube-latest/client/dist/$1;
}
- location ~ ^(/static/(webseed|streaming-playlists)/private/)|^/download {
+ location ~ ^(/static/(webseed|web-videos|streaming-playlists)/private/)|^/download {
# We can't rate limit a try_files directive, so we need to duplicate @api
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -212,16 +212,10 @@ server {
}
# Bypass PeerTube for performance reasons. Optional.
- location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
+ location ~ ^/static/(webseed|web-videos|redundancy|streaming-playlists)/ {
limit_rate_after 5M;
- # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
- set $peertube_limit_rate 800k;
-
- # Increase rate limit in HLS mode, because we don't have multiple simultaneous connections
- if ($request_uri ~ -fragmented.mp4$) {
- set $peertube_limit_rate 5M;
- }
+ set $peertube_limit_rate 5M;
# Use this line with nginx >= 1.17.0
limit_rate $peertube_limit_rate;