server.listen bind to ipv6 too

This commit is contained in:
LouisLam 2021-08-10 16:36:21 +08:00
parent 5512b15162
commit d6fad7f1ef

View File

@ -40,7 +40,10 @@ const passwordHash = require("./password-hash");
const args = require("args-parser")(process.argv);
const version = require("../package.json").version;
const hostname = process.env.HOST || args.host || "0.0.0.0"
// If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise.
const hostname = process.env.HOST || args.host;
const port = parseInt(process.env.PORT || args.port || 3001);
console.info("Version: " + version)
@ -568,7 +571,13 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
console.log("Init")
server.listen(port, hostname, () => {
if (hostname) {
console.log(`Listening on ${hostname}:${port}`);
} else {
console.log("Listening on ${port}");
}
startMonitors();
});