add validation to port value parsing

only port configurations that are valid (not isNaN) after parseInt
are considered to be used in port variable
This commit is contained in:
Marc Harnos 2022-01-07 23:16:26 +01:00
parent 2c8d5d28e9
commit 0053a29d10
No known key found for this signature in database
GPG Key ID: A7D68CEB704F557A

View File

@ -71,7 +71,9 @@ if (hostname) {
console.log("Custom hostname: " + hostname);
}
const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001);
const port = [process.env.UPTIME_KUMA_PORT, process.env.PORT, args.port, 3001]
.map(portValue => parseInt(portValue))
.find(portValue => !isNaN(portValue));
// SSL
const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined;