diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-19 21:34:51 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-19 21:34:51 +0200 |
commit | e861452fb26553177ad4e32bfb18b4fd8a5b1816 (patch) | |
tree | 7c0cfd464709243a452b431665f5107a973df682 /server/lib | |
parent | 5c39adb7313e0696aabb4b71196ab7b0b378c359 (diff) | |
download | PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.tar.gz PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.tar.zst PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.zip |
Server: put config in constants
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/friends.js | 8 | ||||
-rw-r--r-- | server/lib/webtorrent.js | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js index 6e1516b94..6a2c37fd7 100644 --- a/server/lib/friends.js +++ b/server/lib/friends.js | |||
@@ -11,12 +11,8 @@ const waterfall = require('async/waterfall') | |||
11 | 11 | ||
12 | const constants = require('../initializers/constants') | 12 | const constants = require('../initializers/constants') |
13 | const logger = require('../helpers/logger') | 13 | const logger = require('../helpers/logger') |
14 | const peertubeCrypto = require('../helpers/peertube-crypto') | ||
15 | const requests = require('../helpers/requests') | 14 | const requests = require('../helpers/requests') |
16 | 15 | ||
17 | const http = config.get('webserver.https') ? 'https' : 'http' | ||
18 | const host = config.get('webserver.host') | ||
19 | const port = config.get('webserver.port') | ||
20 | const Pod = mongoose.model('Pod') | 16 | const Pod = mongoose.model('Pod') |
21 | const Request = mongoose.model('Request') | 17 | const Request = mongoose.model('Request') |
22 | const Video = mongoose.model('Video') | 18 | const Video = mongoose.model('Video') |
@@ -45,7 +41,7 @@ function hasFriends (callback) { | |||
45 | } | 41 | } |
46 | 42 | ||
47 | function getMyCertificate (callback) { | 43 | function getMyCertificate (callback) { |
48 | fs.readFile(peertubeCrypto.getCertDir() + 'peertube.pub', 'utf8', callback) | 44 | fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.pub', 'utf8', callback) |
49 | } | 45 | } |
50 | 46 | ||
51 | function makeFriends (callback) { | 47 | function makeFriends (callback) { |
@@ -220,7 +216,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) { | |||
220 | url: pod.url + '/api/' + constants.API_VERSION + '/pods/', | 216 | url: pod.url + '/api/' + constants.API_VERSION + '/pods/', |
221 | method: 'POST', | 217 | method: 'POST', |
222 | json: { | 218 | json: { |
223 | url: http + '://' + host + ':' + port, | 219 | url: constants.CONFIG.WEBSERVER.URL, |
224 | publicKey: cert | 220 | publicKey: cert |
225 | } | 221 | } |
226 | } | 222 | } |
diff --git a/server/lib/webtorrent.js b/server/lib/webtorrent.js index bcd30139e..2090b792b 100644 --- a/server/lib/webtorrent.js +++ b/server/lib/webtorrent.js | |||
@@ -1,15 +1,14 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | ||
4 | const ipc = require('node-ipc') | 3 | const ipc = require('node-ipc') |
5 | const pathUtils = require('path') | 4 | const pathUtils = require('path') |
6 | const spawn = require('electron-spawn') | 5 | const spawn = require('electron-spawn') |
7 | 6 | ||
7 | const constants = require('../initializers/constants') | ||
8 | const logger = require('../helpers/logger') | 8 | const logger = require('../helpers/logger') |
9 | 9 | ||
10 | const electronDebug = config.get('electron.debug') | 10 | let host = constants.CONFIG.WEBSERVER.HOST |
11 | let host = config.get('webserver.host') | 11 | let port = constants.CONFIG.WEBSERVER.PORT |
12 | let port = config.get('webserver.port') | ||
13 | let nodeKey = 'webtorrentnode' + port | 12 | let nodeKey = 'webtorrentnode' + port |
14 | let processKey = 'webtorrentprocess' + port | 13 | let processKey = 'webtorrentprocess' + port |
15 | ipc.config.silent = true | 14 | ipc.config.silent = true |
@@ -59,7 +58,7 @@ function create (options, callback) { | |||
59 | 58 | ||
60 | const webtorrentProcess = spawn(pathUtils.join(__dirname, 'webtorrent-process.js'), host, port, { detached: true }) | 59 | const webtorrentProcess = spawn(pathUtils.join(__dirname, 'webtorrent-process.js'), host, port, { detached: true }) |
61 | 60 | ||
62 | if (electronDebug === true) { | 61 | if (constants.CONFIG.ELECTRON.DEBUG === true) { |
63 | webtorrentProcess.stderr.on('data', function (data) { | 62 | webtorrentProcess.stderr.on('data', function (data) { |
64 | logger.debug('Webtorrent process stderr: ', data.toString()) | 63 | logger.debug('Webtorrent process stderr: ', data.toString()) |
65 | }) | 64 | }) |