From f32db19b520e66fda036daddcf0cf664010222ac Mon Sep 17 00:00:00 2001 From: tigerbot Date: Mon, 8 May 2017 17:47:51 -0600 Subject: [PATCH] handled case where no TCP modules exist --- lib/goldilocks.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/goldilocks.js b/lib/goldilocks.js index bc5e6f1..d92d8d9 100644 --- a/lib/goldilocks.js +++ b/lib/goldilocks.js @@ -476,13 +476,22 @@ module.exports.create = function (deps, config) { var listenPromises = []; var tcpPortMap = {}; - - if (config.tcp.bind) { - config.tcp.bind.forEach(function (port) { - tcpPortMap[port] = true; - }); + function addPorts(bindList) { + if (!bindList) { + return; + } + if (Array.isArray(bindList)) { + bindList.forEach(function (port) { + tcpPortMap[port] = true; + }); + } + else { + tcpPortMap[bindList] = true; + } } - config.tcp.modules.forEach(function (mod) { + + addPorts(config.tcp.bind); + (config.tcp.modules || []).forEach(function (mod) { if (mod.name === 'forward') { var forwarder = createTcpForwarder(mod); mod.ports.forEach(function (port) { @@ -502,19 +511,6 @@ module.exports.create = function (deps, config) { // Even though these ports were specified in different places we treat any TCP // connections we haven't been told to just forward exactly as is equal so that // we can potentially use the same ports for different protocols. - function addPorts(bindList) { - if (!bindList) { - return; - } - if (Array.isArray(bindList)) { - bindList.forEach(function (port) { - tcpPortMap[port] = true; - }); - } - else { - tcpPortMap[bindList] = true; - } - } addPorts(config.tls.bind); addPorts(config.http.bind);