fixed a few misc errors that appeared in testing

This commit is contained in:
tigerbot 2017-10-11 13:06:24 -06:00
parent 79ef9694b7
commit 2a57a1e12c
1 changed files with 15 additions and 19 deletions

View File

@ -30,7 +30,7 @@ function mergeSettings(orig, changes) {
function fixRawConfig(config) { function fixRawConfig(config) {
var updated = false; var updated = false;
if (config.tcp && config.tcp && !Array.isArray(config.tcp)) { if (config.tcp && config.tcp.bind && !Array.isArray(config.tcp.bind)) {
config.tcp.bind = [ config.tcp.bind ]; config.tcp.bind = [ config.tcp.bind ];
updated = true; updated = true;
} }
@ -87,7 +87,7 @@ function fixRawConfig(config) {
updateModules(dom.modules); updateModules(dom.modules);
var strDoms = dom.names.slice().sort().join(','); var strDoms = dom.names.slice().sort().join(',');
var added = config.domain.some(function (existing) { var added = config.domains.some(function (existing) {
if (strDoms !== existing.names.slice().sort().join(',')) { if (strDoms !== existing.names.slice().sort().join(',')) {
return; return;
} }
@ -100,7 +100,7 @@ function fixRawConfig(config) {
} }
var newDom = { var newDom = {
id: crypto.randomBytes(8).toString('hex'), id: crypto.randomBytes(4).toString('hex'),
names: dom.names, names: dom.names,
modules: {} modules: {}
}; };
@ -260,7 +260,11 @@ function fillConfig(config, args) {
var mdnsDefaults = { disabled: false, port: 5353, broadcast: '224.0.0.251', ttl: 300 }; var mdnsDefaults = { disabled: false, port: 5353, broadcast: '224.0.0.251', ttl: 300 };
config.mdns = Object.assign(mdnsDefaults, config.mdns); config.mdns = Object.assign(mdnsDefaults, config.mdns);
function fillComponent(name, fillBind, fillDomains) { if (!Array.isArray(config.domains)) {
config.domains = [];
}
function fillComponent(name, fillBind) {
if (!config[name]) { if (!config[name]) {
config[name] = {}; config[name] = {};
} }
@ -271,22 +275,11 @@ function fillConfig(config, args) {
if (fillBind && !Array.isArray(config[name].bind)) { if (fillBind && !Array.isArray(config[name].bind)) {
config[name].bind = []; config[name].bind = [];
} }
if (fillDomains) {
if (!Array.isArray(config[name].domains)) {
config[name].domains = [];
}
config[name].domains.forEach(function (domain) {
if (!Array.isArray(domain.modules)) {
domain.modules = [];
}
});
}
} }
fillComponent('dns', true, false); fillComponent('udp', true);
fillComponent('tcp', true, false); fillComponent('tcp', true);
fillComponent('http', false, true); fillComponent('http', false);
fillComponent('tls', false, true); fillComponent('tls', false);
if (!config.tls.acme && (args.email || args.agreeTos)) { if (!config.tls.acme && (args.email || args.agreeTos)) {
config.tls.acme = {}; config.tls.acme = {};
@ -384,6 +377,9 @@ function run(args) {
// TODO spin up multiple workers // TODO spin up multiple workers
// TODO use greenlock-cluster // TODO use greenlock-cluster
cluster.fork(); cluster.fork();
}).catch(function (err) {
console.error(err);
process.exit(1);
}) })
; ;
} }