From 49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2016 20:03:04 +0100 Subject: Pod URL -> pod host. HTTPS is required to make friends. Reason: in a network with mix http/https pods, https pods won't be able to play videos from http pod (insecure requests). --- server/helpers/custom-validators/pods.js | 12 ++++++------ server/helpers/custom-validators/videos.js | 6 +++--- server/helpers/requests.js | 8 +++++--- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/pods.js b/server/helpers/custom-validators/pods.js index 40f8b5d0b..0154a2424 100644 --- a/server/helpers/custom-validators/pods.js +++ b/server/helpers/custom-validators/pods.js @@ -5,14 +5,14 @@ const validator = require('express-validator').validator const miscValidators = require('./misc') const podsValidators = { - isEachUniqueUrlValid + isEachUniqueHostValid } -function isEachUniqueUrlValid (urls) { - return miscValidators.isArray(urls) && - urls.length !== 0 && - urls.every(function (url) { - return validator.isURL(url) && urls.indexOf(url) === urls.lastIndexOf(url) +function isEachUniqueHostValid (hosts) { + return miscValidators.isArray(hosts) && + hosts.length !== 0 && + hosts.every(function (host) { + return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host) }) } diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 45acb7686..4a6a62326 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js @@ -15,7 +15,7 @@ const videosValidators = { isVideoDurationValid, isVideoMagnetValid, isVideoNameValid, - isVideoPodUrlValid, + isVideoPodHostValid, isVideoTagsValid, isVideoThumbnailValid, isVideoThumbnail64Valid @@ -33,7 +33,7 @@ function isEachRemoteVideosValid (requests) { isVideoDurationValid(video.duration) && isVideoMagnetValid(video.magnet) && isVideoNameValid(video.name) && - isVideoPodUrlValid(video.podUrl) && + isVideoPodHostValid(video.podHost) && isVideoTagsValid(video.tags) && isVideoThumbnail64Valid(video.thumbnailBase64) && isVideoRemoteIdValid(video.remoteId) @@ -70,7 +70,7 @@ function isVideoNameValid (value) { return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) } -function isVideoPodUrlValid (value) { +function isVideoPodHostValid (value) { // TODO: set options (TLD...) return validator.isURL(value) } diff --git a/server/helpers/requests.js b/server/helpers/requests.js index 95775c981..06109ce16 100644 --- a/server/helpers/requests.js +++ b/server/helpers/requests.js @@ -25,7 +25,7 @@ function makeRetryRequest (params, callback) { function makeSecureRequest (params, callback) { const requestParams = { - url: params.toPod.url + params.path + url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path } // Add data with POST requst ? @@ -34,9 +34,11 @@ function makeSecureRequest (params, callback) { // Add signature if it is specified in the params if (params.sign === true) { + const host = constants.CONFIG.WEBSERVER.HOST + requestParams.json.signature = { - url: constants.CONFIG.WEBSERVER.URL, - signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL) + host, + signature: peertubeCrypto.sign(host) } } -- cgit v1.2.3