Server: host -> hostname (host = hostname + port)

This commit is contained in:
Chocobozzz 2016-10-23 19:41:17 +02:00
parent 2c49ca42d1
commit 3737bbafb1
16 changed files with 21 additions and 21 deletions

View File

@ -3,11 +3,11 @@ listen:
webserver: webserver:
https: false https: false
host: 'localhost' hostname: 'localhost'
port: 9000 port: 9000
database: database:
host: 'localhost' hostname: 'localhost'
port: 27017 port: 27017
suffix: '-dev' suffix: '-dev'

View File

@ -1,7 +1,7 @@
# Correspond to your reverse proxy "listen" configuration # Correspond to your reverse proxy "listen" configuration
webserver: webserver:
https: false https: false
host: 'example.com' hostname: 'example.com'
port: 80 port: 80
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9001 port: 9001
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9001 port: 9001
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9002 port: 9002
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9002 port: 9002
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9003 port: 9003
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9003 port: 9003
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9004 port: 9004
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9004 port: 9004
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9005 port: 9005
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9005 port: 9005
database: database:

View File

@ -2,7 +2,7 @@ listen:
port: 9006 port: 9006
webserver: webserver:
host: 'localhost' hostname: 'localhost'
port: 9006 port: 9006
database: database:

View File

@ -5,5 +5,5 @@ webserver:
https: false https: false
database: database:
host: 'localhost' hostname: 'localhost'
port: 27017 port: 27017

View File

@ -13,9 +13,9 @@ router.get('/local', getLocalClient)
// Get the client credentials for the PeerTube front end // Get the client credentials for the PeerTube front end
function getLocalClient (req, res, next) { function getLocalClient (req, res, next) {
const serverHost = constants.CONFIG.WEBSERVER.HOST const serverHostname = constants.CONFIG.WEBSERVER.HOSTNAME
const serverPort = constants.CONFIG.WEBSERVER.PORT const serverPort = constants.CONFIG.WEBSERVER.PORT
let headerHostShouldBe = serverHost let headerHostShouldBe = serverHostname
if (serverPort !== 80 && serverPort !== 443) { if (serverPort !== 80 && serverPort !== 443) {
headerHostShouldBe += ':' + serverPort headerHostShouldBe += ':' + serverPort
} }

View File

@ -8,7 +8,7 @@ winston.emitErrs = true
const constants = require('../initializers/constants') const constants = require('../initializers/constants')
const label = constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT const label = constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT
// Create the directory if it does not exist // Create the directory if it does not exist
mkdirp.sync(constants.CONFIG.STORAGE.LOG_DIR) mkdirp.sync(constants.CONFIG.STORAGE.LOG_DIR)

View File

@ -15,8 +15,8 @@ const checker = {
// Check the config files // Check the config files
function checkConfig () { function checkConfig () {
const required = [ 'listen.port', const required = [ 'listen.port',
'webserver.https', 'webserver.host', 'webserver.port', 'webserver.https', 'webserver.hostname', 'webserver.port',
'database.host', 'database.port', 'database.suffix', 'database.hostname', 'database.port', 'database.suffix',
'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails' 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails'
] ]
const miss = [] const miss = []

View File

@ -32,7 +32,7 @@ const OAUTH_LIFETIME = {
const CONFIG = { const CONFIG = {
DATABASE: { DATABASE: {
DBNAME: 'peertube' + config.get('database.suffix'), DBNAME: 'peertube' + config.get('database.suffix'),
HOST: config.get('database.host'), HOSTNAME: config.get('database.hostname'),
PORT: config.get('database.port') PORT: config.get('database.port')
}, },
STORAGE: { STORAGE: {
@ -45,11 +45,11 @@ const CONFIG = {
WEBSERVER: { WEBSERVER: {
SCHEME: config.get('webserver.https') === true ? 'https' : 'http', SCHEME: config.get('webserver.https') === true ? 'https' : 'http',
WS: config.get('webserver.https') === true ? 'wss' : 'ws', WS: config.get('webserver.https') === true ? 'wss' : 'ws',
HOST: config.get('webserver.host'), HOSTNAME: config.get('webserver.hostname'),
PORT: config.get('webserver.port') PORT: config.get('webserver.port')
} }
} }
CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOST + ':' + CONFIG.WEBSERVER.PORT CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@ const database = {
function connect () { function connect () {
mongoose.Promise = global.Promise mongoose.Promise = global.Promise
mongoose.connect('mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME) mongoose.connect('mongodb://' + constants.CONFIG.DATABASE.HOSTNAME + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME)
mongoose.connection.on('error', function () { mongoose.connection.on('error', function () {
throw new Error('Mongodb connection error.') throw new Error('Mongodb connection error.')
}) })

View File

@ -273,7 +273,7 @@ function isMe (url) {
const hostname = parsedUrl.hostname const hostname = parsedUrl.hostname
const port = parseInt(parsedUrl.port) const port = parseInt(parsedUrl.port)
const myHostname = constants.CONFIG.WEBSERVER.HOST const myHostname = constants.CONFIG.WEBSERVER.HOSTNAME
const myPort = constants.CONFIG.WEBSERVER.PORT const myPort = constants.CONFIG.WEBSERVER.PORT
return hostname === myHostname && port === myPort return hostname === myHostname && port === myPort

View File

@ -102,7 +102,7 @@ VideoSchema.pre('save', function (next) {
function (callback) { function (callback) {
const options = { const options = {
announceList: [ announceList: [
[ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ] [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ]
], ],
urlList: [ urlList: [
constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename