forked from svrjs/svrjs
Change blocklist-related commands to use .forEach() function instead of a for loop
This commit is contained in:
parent
7680bb8c27
commit
3b4fd9641c
1 changed files with 11 additions and 11 deletions
|
@ -23,14 +23,14 @@ module.exports.commands = {
|
||||||
if (ip == undefined || JSON.stringify(ip) == "[]") {
|
if (ip == undefined || JSON.stringify(ip) == "[]") {
|
||||||
if (!cluster.isPrimary === false) log("Cannot block non-existent IP.");
|
if (!cluster.isPrimary === false) log("Cannot block non-existent IP.");
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < ip.length; i++) {
|
ip.forEach((ipAddress) => {
|
||||||
if (ip[i] != "localhost" && ip[i].indexOf(":") == -1) {
|
if (ipAddress !== "localhost" && ipAddress.indexOf(":") == -1) {
|
||||||
ip[i] = "::ffff:" + ip[i];
|
ipAddress = "::ffff:" + ipAddress;
|
||||||
}
|
}
|
||||||
if (!blocklist.check(ip[i])) {
|
if (!blocklist.check(ipAddress)) {
|
||||||
blocklist.add(ip[i]);
|
blocklist.add(ipAddress);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
process.serverConfig.blacklist = blocklist.raw;
|
process.serverConfig.blacklist = blocklist.raw;
|
||||||
if (!cluster.isPrimary === false) log("IPs successfully blocked.");
|
if (!cluster.isPrimary === false) log("IPs successfully blocked.");
|
||||||
passCommand(ip, log);
|
passCommand(ip, log);
|
||||||
|
@ -40,12 +40,12 @@ module.exports.commands = {
|
||||||
if (ip == undefined || JSON.stringify(ip) == "[]") {
|
if (ip == undefined || JSON.stringify(ip) == "[]") {
|
||||||
if (!cluster.isPrimary === false) log("Cannot unblock non-existent IP.");
|
if (!cluster.isPrimary === false) log("Cannot unblock non-existent IP.");
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < ip.length; i++) {
|
ip.forEach((ipAddress) => {
|
||||||
if (ip[i].indexOf(":") == -1) {
|
if (ipAddress !== "localhost" && ipAddress.indexOf(":") == -1) {
|
||||||
ip[i] = "::ffff:" + ip[i];
|
ipAddress = "::ffff:" + ipAddress;
|
||||||
}
|
}
|
||||||
blocklist.remove(ip[i]);
|
blocklist.remove(ipAddress);
|
||||||
}
|
});
|
||||||
process.serverConfig.blacklist = blocklist.raw;
|
process.serverConfig.blacklist = blocklist.raw;
|
||||||
if (!cluster.isPrimary === false) log("IPs successfully unblocked.");
|
if (!cluster.isPrimary === false) log("IPs successfully unblocked.");
|
||||||
passCommand(ip, log);
|
passCommand(ip, log);
|
||||||
|
|
Reference in a new issue