mirror of https://github.com/Chocobozzz/PeerTube
Migrate from webseed to web-videos
parent
d732ec7b46
commit
34555bebf8
|
@ -15,7 +15,8 @@ const objectStorageProxyRouter = express.Router()
|
||||||
|
|
||||||
objectStorageProxyRouter.use(cors())
|
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,
|
ensurePrivateObjectStorageProxyIsEnabled,
|
||||||
optionalAuthenticate,
|
optionalAuthenticate,
|
||||||
asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
|
asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
|
||||||
|
|
|
@ -29,13 +29,13 @@ const privateWebVideoStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUI
|
||||||
: []
|
: []
|
||||||
|
|
||||||
staticRouter.use(
|
staticRouter.use(
|
||||||
STATIC_PATHS.PRIVATE_WEBSEED,
|
[ STATIC_PATHS.PRIVATE_WEB_VIDEOS, STATIC_PATHS.LEGACY_PRIVATE_WEB_VIDEOS ],
|
||||||
...privateWebVideoStaticMiddlewares,
|
...privateWebVideoStaticMiddlewares,
|
||||||
express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }),
|
express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }),
|
||||||
handleStaticError
|
handleStaticError
|
||||||
)
|
)
|
||||||
staticRouter.use(
|
staticRouter.use(
|
||||||
STATIC_PATHS.WEBSEED,
|
[ STATIC_PATHS.WEB_VIDEOS, STATIC_PATHS.LEGACY_WEB_VIDEOS ],
|
||||||
express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }),
|
express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }),
|
||||||
handleStaticError
|
handleStaticError
|
||||||
)
|
)
|
||||||
|
|
|
@ -750,8 +750,13 @@ const STATIC_PATHS = {
|
||||||
// TODO: deprecated in v6, to remove
|
// TODO: deprecated in v6, to remove
|
||||||
THUMBNAILS: '/static/thumbnails/',
|
THUMBNAILS: '/static/thumbnails/',
|
||||||
|
|
||||||
WEBSEED: '/static/webseed/',
|
// Need to keep this legacy path for previously generated torrents
|
||||||
PRIVATE_WEBSEED: '/static/webseed/private/',
|
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/',
|
REDUNDANCY: '/static/redundancy/',
|
||||||
|
|
||||||
|
@ -775,7 +780,9 @@ const LAZY_STATIC_PATHS = {
|
||||||
STORYBOARDS: '/lazy-static/storyboards/'
|
STORYBOARDS: '/lazy-static/storyboards/'
|
||||||
}
|
}
|
||||||
const OBJECT_STORAGE_PROXY_PATHS = {
|
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: {
|
STREAMING_PLAYLISTS: {
|
||||||
PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
|
PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
|
||||||
|
|
|
@ -30,7 +30,7 @@ function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebVideoPrivateFileUrl (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
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -558,10 +558,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
|
||||||
|
|
||||||
private getWebVideoFileStaticPath (video: MVideo) {
|
private getWebVideoFileStaticPath (video: MVideo) {
|
||||||
if (isVideoInPrivateDirectory(video.privacy)) {
|
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) {
|
private getHLSFileStaticPath (video: MVideo) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ describe('Object storage for video static file privacy', function () {
|
||||||
const video = await server.videos.getWithToken({ id: uuid })
|
const video = await server.videos.getWithToken({ id: uuid })
|
||||||
|
|
||||||
for (const file of video.files) {
|
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 })
|
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)
|
const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl)
|
||||||
|
|
||||||
await makeRawRequest({
|
await makeRawRequest({
|
||||||
url: server.url + '/object-storage-proxy/webseed/private/' + webVideoFilename,
|
url: server.url + '/object-storage-proxy/web-videos/private/' + webVideoFilename,
|
||||||
token: server.accessToken,
|
token: server.accessToken,
|
||||||
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
expectedStatus: HttpStatusCode.BAD_REQUEST_400
|
||||||
})
|
})
|
||||||
|
|
|
@ -125,7 +125,7 @@ async function check1WebSeed (videoUUID?: string) {
|
||||||
if (!videoUUID) videoUUID = video1Server2.uuid
|
if (!videoUUID) videoUUID = video1Server2.uuid
|
||||||
|
|
||||||
const webseeds = [
|
const webseeds = [
|
||||||
`${servers[1].url}/static/webseed/`
|
`${servers[1].url}/static/web-videos/`
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
|
@ -145,7 +145,7 @@ async function check2Webseeds (videoUUID?: string) {
|
||||||
|
|
||||||
const webseeds = [
|
const webseeds = [
|
||||||
`${servers[0].url}/static/redundancy/`,
|
`${servers[0].url}/static/redundancy/`,
|
||||||
`${servers[1].url}/static/webseed/`
|
`${servers[1].url}/static/web-videos/`
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('Test video static file privacy', function () {
|
||||||
|
|
||||||
for (const file of video.files) {
|
for (const file of video.files) {
|
||||||
expect(file.fileDownloadUrl).to.not.include('/private/')
|
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)
|
const torrent = await parseTorrentVideo(server, file)
|
||||||
expect(torrent.urlList).to.have.lengthOf(0)
|
expect(torrent.urlList).to.have.lengthOf(0)
|
||||||
|
|
|
@ -51,11 +51,12 @@ async function completeWebVideoFilesCheck (options: {
|
||||||
expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`))
|
expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`))
|
||||||
|
|
||||||
if (objectStorageBaseUrl && requiresAuth) {
|
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) {
|
} else if (objectStorageBaseUrl) {
|
||||||
expectStartWith(file.fileUrl, objectStorageBaseUrl)
|
expectStartWith(file.fileUrl, objectStorageBaseUrl)
|
||||||
} else {
|
} 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}`))
|
expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`))
|
||||||
|
|
|
@ -366,7 +366,7 @@ x-tagGroups:
|
||||||
- Runners
|
- Runners
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
'/static/webseed/{filename}':
|
'/static/web-videos/{filename}':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- Static Video Files
|
- Static Video Files
|
||||||
|
@ -378,11 +378,11 @@ paths:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
'404':
|
'404':
|
||||||
description: not found
|
description: not found
|
||||||
'/static/webseed/private/{filename}':
|
'/static/web-videos/private/{filename}':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- Static Video Files
|
- Static Video Files
|
||||||
summary: Get private Web Video video file
|
summary: Get private Web Video file
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/staticFilename'
|
- $ref: '#/components/parameters/staticFilename'
|
||||||
- $ref: '#/components/parameters/videoFileToken'
|
- $ref: '#/components/parameters/videoFileToken'
|
||||||
|
|
|
@ -199,7 +199,7 @@ server {
|
||||||
alias /var/www/peertube/peertube-latest/client/dist/$1;
|
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
|
# 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;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
@ -212,16 +212,10 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bypass PeerTube for performance reasons. Optional.
|
# Bypass PeerTube for performance reasons. Optional.
|
||||||
location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
|
location ~ ^/static/(webseed|web-videos|redundancy|streaming-playlists)/ {
|
||||||
limit_rate_after 5M;
|
limit_rate_after 5M;
|
||||||
|
|
||||||
# Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
|
set $peertube_limit_rate 5M;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Use this line with nginx >= 1.17.0
|
# Use this line with nginx >= 1.17.0
|
||||||
limit_rate $peertube_limit_rate;
|
limit_rate $peertube_limit_rate;
|
||||||
|
|
Loading…
Reference in New Issue