* Adds auto cors updates to geth command when blockchain started via run command.
* Fixes issues with storage/webserver configs not enabled but still having their values put in to geth cors * Adds fixes for not including port when port == false * Refactors of cors logic, and also now in a generic location so can be used by both `embark blockchain` and when blockchain started in separate process
This commit is contained in:
parent
87cd371894
commit
5b4e829675
|
@ -54,6 +54,8 @@ Config.prototype.loadConfigFiles = function(options) {
|
||||||
this.loadWebServerConfigFile();
|
this.loadWebServerConfigFile();
|
||||||
this.loadChainTrackerFile();
|
this.loadChainTrackerFile();
|
||||||
this.loadPluginContractFiles();
|
this.loadPluginContractFiles();
|
||||||
|
|
||||||
|
this._updateBlockchainCors();
|
||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.reloadConfig = function() {
|
Config.prototype.reloadConfig = function() {
|
||||||
|
@ -66,6 +68,27 @@ Config.prototype.reloadConfig = function() {
|
||||||
this.loadContractsConfigFile();
|
this.loadContractsConfigFile();
|
||||||
this.loadExternalContractsFiles();
|
this.loadExternalContractsFiles();
|
||||||
this.loadChainTrackerFile();
|
this.loadChainTrackerFile();
|
||||||
|
|
||||||
|
this._updateBlockchainCors();
|
||||||
|
};
|
||||||
|
|
||||||
|
Config.prototype._updateBlockchainCors = function(){
|
||||||
|
let blockchainConfig = this.blockchainConfig;
|
||||||
|
let storageConfig = this.storageConfig;
|
||||||
|
let webServerConfig = this.webServerConfig;
|
||||||
|
let cors = '';
|
||||||
|
|
||||||
|
if(webServerConfig && webServerConfig.enabled) {
|
||||||
|
let webServerPort = webServerConfig.port ? `:${webServerConfig.port}` : '';
|
||||||
|
if(webServerConfig.host) cors = `http://${webServerConfig.host}${webServerPort}`;
|
||||||
|
}
|
||||||
|
if(storageConfig && storageConfig.enabled) {
|
||||||
|
let storagePort = storageConfig.port ? `:${storageConfig.port}` : '';
|
||||||
|
if(storageConfig.host) cors += `${cors.length ? ',' : ''}${storageConfig.protocol || 'http'}://${storageConfig.host}${storagePort}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockchainConfig.rpcCorsDomain === 'auto' && cors.length) blockchainConfig.rpcCorsDomain = cors;
|
||||||
|
if(blockchainConfig.wsOrigins === 'auto' && cors.length) blockchainConfig.wsOrigins = cors;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, enabledByDefault) {
|
Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, enabledByDefault) {
|
||||||
|
|
14
lib/index.js
14
lib/index.js
|
@ -49,19 +49,7 @@ class Embark {
|
||||||
|
|
||||||
blockchain(env, client) {
|
blockchain(env, client) {
|
||||||
this.context = [constants.contexts.blockchain];
|
this.context = [constants.contexts.blockchain];
|
||||||
let blockchainConfig = this.config.blockchainConfig;
|
return require('./cmds/blockchain/blockchain.js')(this.config.blockchainConfig, client, env, this.isDev(env)).run();
|
||||||
let storageConfig = this.config.storageConfig;
|
|
||||||
let webServerConfig = this.config.webServerConfig;
|
|
||||||
|
|
||||||
if(blockchainConfig.rpcCorsDomain === 'auto') {
|
|
||||||
if(webServerConfig) blockchainConfig.rpcCorsDomain = `http://${webServerConfig.host}:${webServerConfig.port}`;
|
|
||||||
if(storageConfig) blockchainConfig.rpcCorsDomain += `${blockchainConfig.rpcCorsDomain.length ? ',' : ''}${storageConfig.protocol}://${storageConfig.host}:${storageConfig.port}`;
|
|
||||||
}
|
|
||||||
if(blockchainConfig.wsOrigins === 'auto') {
|
|
||||||
if(webServerConfig) blockchainConfig.wsOrigins = `http://${webServerConfig.host}:${webServerConfig.port}`;
|
|
||||||
if(storageConfig) blockchainConfig.wsOrigins += `${blockchainConfig.wsOrigins.length ? ',' : ''}${storageConfig.protocol}://${storageConfig.host}:${storageConfig.port}`;
|
|
||||||
}
|
|
||||||
return require('./cmds/blockchain/blockchain.js')(blockchainConfig, client, env, this.isDev(env)).run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator(options) {
|
simulator(options) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"provider": "swarm",
|
"provider": "swarm",
|
||||||
"host": "swarm-gateways.net",
|
"host": "swarm-gateways.net",
|
||||||
"port": 80,
|
"port": false,
|
||||||
"getUrl": "http://swarm-gateways.net/bzzr:/"
|
"getUrl": "http://swarm-gateways.net/bzzr:/"
|
||||||
},
|
},
|
||||||
"livenet": {
|
"livenet": {
|
||||||
|
|
Loading…
Reference in New Issue