aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-17 21:10:29 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-17 21:10:29 +0200
commit25cad919924faebda48f8741d3e6e0c3e23c6182 (patch)
tree17bd64a7e559452b5654b8ed99b3cce38ecc196e /server/models/video.js
parent7a2c9a8e55194342aa050147cf8b0564d4854966 (diff)
downloadPeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.tar.gz
PeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.tar.zst
PeerTube-25cad919924faebda48f8741d3e6e0c3e23c6182.zip
Server: handle tls websockets
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js17
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
3const config = require('config')
4const createTorrent = require('create-torrent') 3const createTorrent = require('create-torrent')
5const ffmpeg = require('fluent-ffmpeg') 4const ffmpeg = require('fluent-ffmpeg')
6const fs = require('fs') 5const fs = require('fs')
@@ -16,11 +15,6 @@ const logger = require('../helpers/logger')
16const modelUtils = require('./utils') 15const modelUtils = require('./utils')
17const utils = require('../helpers/utils') 16const utils = require('../helpers/utils')
18 17
19const http = config.get('webserver.https') === true ? 'https' : 'http'
20const host = config.get('webserver.host')
21const port = config.get('webserver.port')
22const 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) {