From ab58f2481c0b654bbddec0c907b238d9475e9115 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 24 Aug 2016 04:32:24 -0700 Subject: [PATCH] config: fixes. --- lib/bcoin/node/config.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/bcoin/node/config.js b/lib/bcoin/node/config.js index 8e5b9e33..45bdf7c9 100644 --- a/lib/bcoin/node/config.js +++ b/lib/bcoin/node/config.js @@ -76,7 +76,7 @@ config.parse = function parse(options) { if (!data.knownPeers) data.knownPeers = config.parseKnown(prefix + '/known-peers'); - if (!text.authPeers) + if (!data.authPeers) data.authPeers = config.parseAuth(prefix + '/authorized-peers'); } @@ -249,8 +249,8 @@ config.parseText = function parseText(text) { key = line.trim(); value = null; } else { - key = line.slice(0, eq).trim(); - value = line.slice(eq + 1).trim(); + key = line.substring(0, eq).trim(); + value = line.substring(eq + 1).trim(); } key = key.replace(/\-/g, '').toLowerCase(); @@ -259,6 +259,9 @@ config.parseText = function parseText(text) { if (alias) key = alias; + if (key.length === 0) + continue; + if (value.length === 0) continue; @@ -309,6 +312,9 @@ config.parseArg = function parseArg(argv) { if (value.length === 0) continue; + if (key.length === 0) + continue; + data[key] = value; continue; @@ -377,6 +383,9 @@ config.parseEnv = function parseEnv(env) { if (alias) key = alias; + if (key.length === 0) + continue; + if (value.length === 0) continue; @@ -417,6 +426,7 @@ config.parseKnownText = function parseKnownText(text) { host = hostname[0]; ip = hostname[1]; } else { + host = null; ip = hostname[0]; } @@ -426,9 +436,12 @@ config.parseKnownText = function parseKnownText(text) { if (key.length !== 33) throw new Error('Invalid key: ' + parts[1]); - if (host) + if (host && host.length > 0) map[host] = key; + if (ip.length === 0) + continue; + map[ip] = key; }