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);