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