changed the default config
This commit is contained in:
parent
cc6b34dd46
commit
d04b750f87
|
@ -148,26 +148,42 @@ var tcpProm;
|
|||
function fillConfig(config, args) {
|
||||
config.debug = config.debug || args.debug;
|
||||
|
||||
if (!config.dns) {
|
||||
config.dns = { bind: [ 53 ], modules: [{ name: 'proxy', port: 3053 }] };
|
||||
}
|
||||
if (!config.ddns) {
|
||||
config.ddns = { enabled: false };
|
||||
}
|
||||
// Use Object.assign to add any properties needed but not defined in the mdns config.
|
||||
// It will first copy the defaults into an empty object, then copy any real config over that.
|
||||
var mdnsDefaults = { port: 5353, broadcast: '224.0.0.251', ttl: 300 };
|
||||
config.mdns = Object.assign({}, mdnsDefaults, config.mdns);
|
||||
// Use Object.assign to copy any real config values over the default values so we can
|
||||
// easily make sure all the fields we need exist .
|
||||
var mdnsDefaults = { disabled: false, port: 5353, broadcast: '224.0.0.251', ttl: 300 };
|
||||
config.mdns = Object.assign(mdnsDefaults, config.mdns);
|
||||
|
||||
if (!config.tcp) {
|
||||
config.tcp = {};
|
||||
}
|
||||
if (!config.http) {
|
||||
config.http = { modules: [{ name: 'proxy', domains: ['*'], port: 3000 }] };
|
||||
}
|
||||
if (!config.tls) {
|
||||
config.tls = {};
|
||||
function fillComponent(name, fillBind, fillDomains) {
|
||||
if (!config[name]) {
|
||||
config[name] = {};
|
||||
}
|
||||
if (!Array.isArray(config[name].modules)) {
|
||||
config[name].modules = [];
|
||||
}
|
||||
|
||||
if (fillBind && !Array.isArray(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('tcp', true, false);
|
||||
fillComponent('http', false, true);
|
||||
fillComponent('tls', false, true);
|
||||
|
||||
if (!config.tls.acme && (args.email || args.agreeTos)) {
|
||||
config.tls.acme = {};
|
||||
}
|
||||
|
@ -175,14 +191,13 @@ function fillConfig(config, args) {
|
|||
config.tls.acme.approvedDomains = args.agreeTos.split(',');
|
||||
}
|
||||
if (args.email) {
|
||||
config.email = args.email;
|
||||
config.tls.acme.email = args.email;
|
||||
}
|
||||
config.device = { hostname: require('os').hostname() };
|
||||
|
||||
config.tunnel = args.tunnel || config.tunnel;
|
||||
|
||||
if (Array.isArray(config.tcp.bind)) {
|
||||
if (Array.isArray(config.tcp.bind) && config.tcp.bind.length) {
|
||||
return PromiseA.resolve(config);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue