diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-17 21:10:29 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-17 21:10:29 +0200 |
commit | 25cad919924faebda48f8741d3e6e0c3e23c6182 (patch) | |
tree | 17bd64a7e559452b5654b8ed99b3cce38ecc196e /server/models | |
parent | 7a2c9a8e55194342aa050147cf8b0564d4854966 (diff) | |
download | PeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.tar.gz PeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.tar.zst PeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.zip |
Server: handle tls websockets
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/server/models/video.js b/server/models/video.js index 9272bea6d..4b941a40c 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -1,6 +1,5 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | ||
4 | const createTorrent = require('create-torrent') | 3 | const createTorrent = require('create-torrent') |
5 | const ffmpeg = require('fluent-ffmpeg') | 4 | const ffmpeg = require('fluent-ffmpeg') |
6 | const fs = require('fs') | 5 | const fs = require('fs') |
@@ -16,11 +15,6 @@ const logger = require('../helpers/logger') | |||
16 | const modelUtils = require('./utils') | 15 | const modelUtils = require('./utils') |
17 | const utils = require('../helpers/utils') | 16 | const utils = require('../helpers/utils') |
18 | 17 | ||
19 | const http = config.get('webserver.https') === true ? 'https' : 'http' | ||
20 | const host = config.get('webserver.host') | ||
21 | const port = config.get('webserver.port') | ||
22 | const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED | ||
23 | |||
24 | // --------------------------------------------------------------------------- | 18 | // --------------------------------------------------------------------------- |
25 | 19 | ||
26 | // TODO: add indexes on searchable columns | 20 | // TODO: add indexes on searchable columns |
@@ -106,7 +100,16 @@ VideoSchema.pre('save', function (next) { | |||
106 | tasks.push( | 100 | tasks.push( |
107 | // TODO: refractoring | 101 | // TODO: refractoring |
108 | function (callback) { | 102 | function (callback) { |
109 | createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) { | 103 | const options = { |
104 | announceList: [ | ||
105 | [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ] | ||
106 | ], | ||
107 | urlList: [ | ||
108 | constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename | ||
109 | ] | ||
110 | } | ||
111 | |||
112 | createTorrent(videoPath, options, function (err, torrent) { | ||
110 | if (err) return callback(err) | 113 | if (err) return callback(err) |
111 | 114 | ||
112 | fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { | 115 | fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { |