1
0
Fork 0

Migrate from webseed to web-videos

This commit is contained in:
Chocobozzz 2023-07-11 11:39:59 +02:00
parent d732ec7b46
commit 34555bebf8
No known key found for this signature in database
GPG key ID: 583A612D890159BE
11 changed files with 31 additions and 28 deletions

View file

@ -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),

View file

@ -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
)

View file

@ -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/'

View file

@ -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
}
// ---------------------------------------------------------------------------

View file

@ -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) {

View file

@ -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
})

View file

@ -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) {

View file

@ -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)

View file

@ -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}`))

View file

@ -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'

View file

@ -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;