config -- canonicalHost, defaultHost

This commit is contained in:
Michael Bradley, Jr 2018-07-15 15:33:48 -05:00
parent 6d482cfb95
commit 3885128e18
1 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,7 @@ const utils = require('../utils/utils.js');
const path = require('path'); const path = require('path');
const deepEqual = require('deep-equal'); const deepEqual = require('deep-equal');
const constants = require('../constants'); const constants = require('../constants');
const {canonicalHost, defaultHost} = require('../utils/host');
var Config = function(options) { var Config = function(options) {
const self = this; const self = this;
@ -106,6 +107,9 @@ Config.prototype._updateBlockchainCors = function(){
// remove /ipfs or /bzz: from getUrl if it's there // remove /ipfs or /bzz: from getUrl if it's there
let getUrlParts = storageConfig.upload.getUrl.split('/'); let getUrlParts = storageConfig.upload.getUrl.split('/');
getUrlParts = getUrlParts.slice(0, 3); getUrlParts = getUrlParts.slice(0, 3);
let host = canonicalHost(getUrlParts[2].split(':')[0]);
let port = getUrlParts[2].split(':')[1];
getUrlParts[2] = port ? [host, port].join(':') : host;
corsParts.push(getUrlParts.join('/')); corsParts.push(getUrlParts.join('/'));
} }
// use our modified getUrl or in case it wasn't specified, use a built url // use our modified getUrl or in case it wasn't specified, use a built url
@ -246,7 +250,7 @@ Config.prototype.loadStorageConfigFile = function() {
"upload": { "upload": {
"provider": "ipfs", "provider": "ipfs",
"protocol": "http", "protocol": "http",
"host": "localhost", "host" : defaultHost,
"port": 5001, "port": 5001,
"getUrl": "http://localhost:8080/ipfs/" "getUrl": "http://localhost:8080/ipfs/"
}, },
@ -281,7 +285,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper"], "available_providers": ["whisper"],
"connection": { "connection": {
"host": "localhost", "port": 8546, "type": "ws" "host": defaultHost,
"port": 8546,
"type": "ws"
} }
} }
}; };
@ -293,7 +299,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
Config.prototype.loadWebServerConfigFile = function() { Config.prototype.loadWebServerConfigFile = function() {
var configObject = { var configObject = {
"enabled": true, "host": "localhost", "port": 8000 "enabled": true,
"host": defaultHost,
"port": 8000
}; };
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver'); let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');