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().
Bart Noordervliet committed
Jul 19, 2020 at 19:44 UTC
af99d9036e8f14e08f77bde524a11110b2f8fbb4
1 file changed
+1
-1
redirserver.js
+1
-1
@@ -124,7 +124,7 @@ module.exports.CreateRedirServer = function (parent, db, args, func) {
124
// Find a free port starting with the specified one and going up.
125
function CheckListenPort(port, addr, func) {
126
var s = obj.net.createServer(function (socket) { });
127
- obj.tcpServer = s.listen(port, function () { s.close(function () { if (func) { func(port, addr); } }); }).on("error", function (err) {
127
+ obj.tcpServer = s.listen(port, addr, function () { s.close(function () { if (func) { func(port, addr); } }); }).on("error", function (err) {
128
if (args.exactports) { console.error("ERROR: MeshCentral HTTP server port " + port + " not available."); process.exit(); }
129
else { if (port < 65535) { CheckListenPort(port + 1, addr, func); } else { if (func) { func(0); } } }
130
});