aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-14 20:03:04 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-16 20:29:26 +0100
commit49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed (patch)
tree68c59d67637a297d513e07ea96ba236a7f0cd43b /server/helpers
parent41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd (diff)
downloadPeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.tar.gz
PeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.tar.zst
PeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.zip
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).
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/pods.js12
-rw-r--r--server/helpers/custom-validators/videos.js6
-rw-r--r--server/helpers/requests.js8
3 files changed, 14 insertions, 12 deletions
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
5const miscValidators = require('./misc') 5const miscValidators = require('./misc')
6 6
7const podsValidators = { 7const podsValidators = {
8 isEachUniqueUrlValid 8 isEachUniqueHostValid
9} 9}
10 10
11function isEachUniqueUrlValid (urls) { 11function isEachUniqueHostValid (hosts) {
12 return miscValidators.isArray(urls) && 12 return miscValidators.isArray(hosts) &&
13 urls.length !== 0 && 13 hosts.length !== 0 &&
14 urls.every(function (url) { 14 hosts.every(function (host) {
15 return validator.isURL(url) && urls.indexOf(url) === urls.lastIndexOf(url) 15 return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host)
16 }) 16 })
17} 17}
18 18
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 = {
15 isVideoDurationValid, 15 isVideoDurationValid,
16 isVideoMagnetValid, 16 isVideoMagnetValid,
17 isVideoNameValid, 17 isVideoNameValid,
18 isVideoPodUrlValid, 18 isVideoPodHostValid,
19 isVideoTagsValid, 19 isVideoTagsValid,
20 isVideoThumbnailValid, 20 isVideoThumbnailValid,
21 isVideoThumbnail64Valid 21 isVideoThumbnail64Valid
@@ -33,7 +33,7 @@ function isEachRemoteVideosValid (requests) {
33 isVideoDurationValid(video.duration) && 33 isVideoDurationValid(video.duration) &&
34 isVideoMagnetValid(video.magnet) && 34 isVideoMagnetValid(video.magnet) &&
35 isVideoNameValid(video.name) && 35 isVideoNameValid(video.name) &&
36 isVideoPodUrlValid(video.podUrl) && 36 isVideoPodHostValid(video.podHost) &&
37 isVideoTagsValid(video.tags) && 37 isVideoTagsValid(video.tags) &&
38 isVideoThumbnail64Valid(video.thumbnailBase64) && 38 isVideoThumbnail64Valid(video.thumbnailBase64) &&
39 isVideoRemoteIdValid(video.remoteId) 39 isVideoRemoteIdValid(video.remoteId)
@@ -70,7 +70,7 @@ function isVideoNameValid (value) {
70 return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) 70 return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME)
71} 71}
72 72
73function isVideoPodUrlValid (value) { 73function isVideoPodHostValid (value) {
74 // TODO: set options (TLD...) 74 // TODO: set options (TLD...)
75 return validator.isURL(value) 75 return validator.isURL(value)
76} 76}
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) {
25 25
26function makeSecureRequest (params, callback) { 26function makeSecureRequest (params, callback) {
27 const requestParams = { 27 const requestParams = {
28 url: params.toPod.url + params.path 28 url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path
29 } 29 }
30 30
31 // Add data with POST requst ? 31 // Add data with POST requst ?
@@ -34,9 +34,11 @@ function makeSecureRequest (params, callback) {
34 34
35 // Add signature if it is specified in the params 35 // Add signature if it is specified in the params
36 if (params.sign === true) { 36 if (params.sign === true) {
37 const host = constants.CONFIG.WEBSERVER.HOST
38
37 requestParams.json.signature = { 39 requestParams.json.signature = {
38 url: constants.CONFIG.WEBSERVER.URL, 40 host,
39 signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL) 41 signature: peertubeCrypto.sign(host)
40 } 42 }
41 } 43 }
42 44