From af99d9036e8f14e08f77bde524a11110b2f8fbb4 Mon Sep 17 00:00:00 2001 From: Bart Noordervliet Date: Sun, 19 Jul 2020 19:44:19 +0200 Subject: [PATCH] Use bind address (if present) when checking redir port The CheckListenPort() function of redirserver.js was not using the optional bind address ("redirPortBind" in config.json), causing it to change the port number when unable to bind on all interfaces. Correct this by passing in 'addr' as the second parameter to createServer.listen(). --- redirserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redirserver.js b/redirserver.js index 6aab526c..b67100e1 100644 --- a/redirserver.js +++ b/redirserver.js @@ -124,7 +124,7 @@ module.exports.CreateRedirServer = function (parent, db, args, func) { // Find a free port starting with the specified one and going up. function CheckListenPort(port, addr, func) { var s = obj.net.createServer(function (socket) { }); - obj.tcpServer = s.listen(port, function () { s.close(function () { if (func) { func(port, addr); } }); }).on("error", function (err) { + obj.tcpServer = s.listen(port, addr, function () { s.close(function () { if (func) { func(port, addr); } }); }).on("error", function (err) { if (args.exactports) { console.error("ERROR: MeshCentral HTTP server port " + port + " not available."); process.exit(); } else { if (port < 65535) { CheckListenPort(port + 1, addr, func); } else { if (func) { func(0); } } } });