forked from svrjs/svrjs
Replace some instances of "blacklist" (racist?) with "block list"
This commit is contained in:
parent
37f3d1d2af
commit
28244bf2c5
1 changed files with 10 additions and 10 deletions
20
svr.js
20
svr.js
|
@ -1153,7 +1153,7 @@ if (fs.existsSync(__dirname + "/config.json")) {
|
||||||
|
|
||||||
// Default server configuration properties
|
// Default server configuration properties
|
||||||
var wwwredirect = false;
|
var wwwredirect = false;
|
||||||
var rawBlackList = [];
|
var rawBlockList = [];
|
||||||
var users = [];
|
var users = [];
|
||||||
var page404 = "404.html";
|
var page404 = "404.html";
|
||||||
var serverAdmin = "[no contact information]";
|
var serverAdmin = "[no contact information]";
|
||||||
|
@ -1180,7 +1180,7 @@ var allowDoubleSlashes = false;
|
||||||
var allowPostfixDoubleSlashes = false;
|
var allowPostfixDoubleSlashes = false;
|
||||||
|
|
||||||
// Get properties from config.json
|
// Get properties from config.json
|
||||||
if (configJSON.blacklist != undefined) rawBlackList = configJSON.blacklist;
|
if (configJSON.blacklist != undefined) rawBlockList = configJSON.blacklist;
|
||||||
if (configJSON.wwwredirect != undefined) wwwredirect = configJSON.wwwredirect;
|
if (configJSON.wwwredirect != undefined) wwwredirect = configJSON.wwwredirect;
|
||||||
if (configJSON.port != undefined) port = configJSON.port;
|
if (configJSON.port != undefined) port = configJSON.port;
|
||||||
if (configJSON.pubport != undefined) pubport = configJSON.pubport;
|
if (configJSON.pubport != undefined) pubport = configJSON.pubport;
|
||||||
|
@ -1255,7 +1255,7 @@ try {
|
||||||
configJSON.version = version;
|
configJSON.version = version;
|
||||||
configJSON.productName = "SVR.JS";
|
configJSON.productName = "SVR.JS";
|
||||||
|
|
||||||
var blacklist = ipBlockList(rawBlackList);
|
var blocklist = ipBlockList(rawBlockList);
|
||||||
|
|
||||||
var nonStandardCodes = [];
|
var nonStandardCodes = [];
|
||||||
nonStandardCodesRaw.forEach(function (nonStandardCodeRaw) {
|
nonStandardCodesRaw.forEach(function (nonStandardCodeRaw) {
|
||||||
|
@ -4099,13 +4099,13 @@ if (!cluster.isPrimary) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// scan blacklist
|
// Scan the block list
|
||||||
if (blacklist.check(reqip) && href != "/favicon.ico") {
|
if (blocklist.check(reqip) && href != "/favicon.ico") {
|
||||||
// Return client blocked message
|
// Return client blocked message
|
||||||
var bheaders = getCustomHeaders();
|
var bheaders = getCustomHeaders();
|
||||||
bheaders["Content-Type"] = "text/html; charset=utf8";
|
bheaders["Content-Type"] = "text/html; charset=utf8";
|
||||||
res.writeHead(403, "Client blocked", bheaders);
|
res.writeHead(403, "Client blocked", bheaders);
|
||||||
res.write("<!DOCTYPE html><html><head><title>Access denied - SVR.JS</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><br/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body><div style=\"height: auto; width: 70%; border-style: solid; border-width: 5; border-color: red; text-align: center; margin: 0 auto;\"><h1>ACCESS DENIED</h1><p style=\"font-size:20px\">Request from " + reqip + " is denied. The client is now in the blacklist.</p><p style=\"font-style: italic; font-weight: normal;\">SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" + (req.headers.host == undefined ? "" : " on " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "</p></div></body></html>");
|
res.write("<!DOCTYPE html><html><head><title>Access denied - SVR.JS</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><br/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body><div style=\"height: auto; width: 70%; border-style: solid; border-width: 5; border-color: red; text-align: center; margin: 0 auto;\"><h1>ACCESS DENIED</h1><p style=\"font-size:20px\">Request from " + reqip + " is denied. The client is now in the block list.</p><p style=\"font-style: italic; font-weight: normal;\">SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" + (req.headers.host == undefined ? "" : " on " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "</p></div></body></html>");
|
||||||
serverconsole.errmessage("Client blocked");
|
serverconsole.errmessage("Client blocked");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5244,8 +5244,8 @@ function start(init) {
|
||||||
if (ip[i].indexOf(":") == -1) {
|
if (ip[i].indexOf(":") == -1) {
|
||||||
ip[i] = "::ffff:" + ip[i];
|
ip[i] = "::ffff:" + ip[i];
|
||||||
}
|
}
|
||||||
if (!blacklist.check(ip[i])) {
|
if (!blocklist.check(ip[i])) {
|
||||||
blacklist.add(ip[i]);
|
blocklist.add(ip[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cluster.isPrimary === undefined) serverconsole.climessage("IPs successfully blocked.");
|
if (cluster.isPrimary === undefined) serverconsole.climessage("IPs successfully blocked.");
|
||||||
|
@ -5261,7 +5261,7 @@ function start(init) {
|
||||||
if (ip[i].indexOf(":") == -1) {
|
if (ip[i].indexOf(":") == -1) {
|
||||||
ip[i] = "::ffff:" + ip[i];
|
ip[i] = "::ffff:" + ip[i];
|
||||||
}
|
}
|
||||||
blacklist.remove(ip[i]);
|
blocklist.remove(ip[i]);
|
||||||
}
|
}
|
||||||
if (cluster.isPrimary === undefined) serverconsole.climessage("IPs successfully unblocked.");
|
if (cluster.isPrimary === undefined) serverconsole.climessage("IPs successfully unblocked.");
|
||||||
else if (!cluster.isPrimary) process.send("IPs successfully unblocked.");
|
else if (!cluster.isPrimary) process.send("IPs successfully unblocked.");
|
||||||
|
@ -5760,7 +5760,7 @@ function saveConfig() {
|
||||||
delete configJSONobj.domian;
|
delete configJSONobj.domian;
|
||||||
if (configJSONobj.page404 === undefined) configJSONobj.page404 = "404.html";
|
if (configJSONobj.page404 === undefined) configJSONobj.page404 = "404.html";
|
||||||
configJSONobj.timestamp = timestamp;
|
configJSONobj.timestamp = timestamp;
|
||||||
configJSONobj.blacklist = blacklist.raw;
|
configJSONobj.blacklist = blocklist.raw;
|
||||||
if (configJSONobj.nonStandardCodes === undefined) configJSONobj.nonStandardCodes = [];
|
if (configJSONobj.nonStandardCodes === undefined) configJSONobj.nonStandardCodes = [];
|
||||||
if (configJSONobj.enableCompression === undefined) configJSONobj.enableCompression = true;
|
if (configJSONobj.enableCompression === undefined) configJSONobj.enableCompression = true;
|
||||||
if (configJSONobj.customHeaders === undefined) configJSONobj.customHeaders = {};
|
if (configJSONobj.customHeaders === undefined) configJSONobj.customHeaders = {};
|
||||||
|
|
Reference in a new issue