mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-25 05:34:08 -08:00
Add IP validation
This commit is contained in:
parent
8160930470
commit
ad71fc9481
|
@ -123,6 +123,15 @@ if (ipsToAllow !== undefined) {
|
||||||
log.error("server", "IPs to allow must be a string, " + typeof ipsToAllow + " provided");
|
log.error("server", "IPs to allow must be a string, " + typeof ipsToAllow + " provided");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const net = require("net");
|
||||||
|
for (const ip of ipsToAllow.split(",")) {
|
||||||
|
if (net.isIP(ip) === 0) {
|
||||||
|
log.error("server", "Provided IPs to allow must be valid IP addresses, " + ip + " provided");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.info("server", "IPs to allow: " + ipsToAllow);
|
log.info("server", "IPs to allow: " + ipsToAllow);
|
||||||
const ipfilter = require("express-ipfilter").IpFilter;
|
const ipfilter = require("express-ipfilter").IpFilter;
|
||||||
app.use(ipfilter(ipsToAllow.split(","), { mode: "allow" }));
|
app.use(ipfilter(ipsToAllow.split(","), { mode: "allow" }));
|
||||||
|
|
Loading…
Reference in a new issue