handled case where no TCP modules exist

This commit is contained in:
tigerbot 2017-05-08 17:47:51 -06:00
parent 513e6e8bdd
commit f32db19b52
1 changed files with 15 additions and 19 deletions

View File

@ -476,13 +476,22 @@ module.exports.create = function (deps, config) {
var listenPromises = []; var listenPromises = [];
var tcpPortMap = {}; var tcpPortMap = {};
function addPorts(bindList) {
if (config.tcp.bind) { if (!bindList) {
config.tcp.bind.forEach(function (port) { return;
}
if (Array.isArray(bindList)) {
bindList.forEach(function (port) {
tcpPortMap[port] = true; tcpPortMap[port] = true;
}); });
} }
config.tcp.modules.forEach(function (mod) { else {
tcpPortMap[bindList] = true;
}
}
addPorts(config.tcp.bind);
(config.tcp.modules || []).forEach(function (mod) {
if (mod.name === 'forward') { if (mod.name === 'forward') {
var forwarder = createTcpForwarder(mod); var forwarder = createTcpForwarder(mod);
mod.ports.forEach(function (port) { 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 // 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 // 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. // 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.tls.bind);
addPorts(config.http.bind); addPorts(config.http.bind);