1
0
Fork 0
forked from svrjs/svrjs

Fixed non-working blacklist

This commit is contained in:
Dorian Niemiec 2023-08-29 14:56:39 +02:00
parent 10f9e1b5f2
commit 1ebf19d768
5 changed files with 29 additions and 26 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 DorianTech S.A.
Copyright (c) 2020-2023 DorianTech
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -3,7 +3,7 @@
"port": 80,
"pubport": 80,
"page404": "404.html",
"timestamp": 1693186939816,
"timestamp": 1693313769931,
"blacklist": [],
"nonStandardCodes": [],
"enableCompression": true,

View file

@ -46,7 +46,7 @@
&nbsp;&nbsp;"rewriteMap": [<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"definingRegex": "/\\/invoke500\\/\\?/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacements": dorians[<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacements": [<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"regex": "/\\/invoke500\\/\\?/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacement": "/invoke500.svr?"<br/>

View file

@ -17,7 +17,7 @@
<div style="display: inline-block; text-align: left; border-width: 2px; border-style: solid; border-color: gray; padding: 8px;">
MIT License<br/>
<br/>
Copyright (c) 2020 DorianTech S.A.<br/>
Copyright (c) 2020-2023 DorianTech<br/>
<br/>
Permission is hereby granted, free of charge, to any person obtaining a copy<br/>
of this software and associated documentation files (the "Software"), to deal<br/>

23
svr.js
View file

@ -15,7 +15,7 @@
/*
* MIT License
*
* Copyright (c) 2020 DorianTech S.A.
* Copyright (c) 2020-2023 DorianTech
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
@ -666,6 +666,9 @@ function ipBlockList(rawBlockList) {
// Function to add an IP or CIDR block to the block list
instance.add = function (rawValue) {
// Add to raw block list
instance.raw.push(rawValue);
// Initialize variables
var beginIndex = instance.prepared.length;
var cidrIndex = instance.cidrs.length;
@ -1061,15 +1064,15 @@ var blacklist = ipBlockList(rawBlackList);
var nonStandardCodes = [];
nonStandardCodesRaw.forEach(function (nonStandardCodeRaw) {
var nO = {};
var newObject = {};
Object.keys(nonStandardCodeRaw).forEach(function (nsKey) {
if (nsKey != "users") {
nO[nsKey] = nonStandardCodeRaw[nsKey];
newObject[nsKey] = nonStandardCodeRaw[nsKey];
} else {
nO["users"] = ipBlockList(nonStandardCodeRaw.users);
newObject["users"] = ipBlockList(nonStandardCodeRaw.users);
}
});
nonStandardCodes.push(nO);
nonStandardCodes.push(newObject);
});
var customHeaders = (configJSON.customHeaders == undefined ? {} : JSON.parse(JSON.stringify(configJSON.customHeaders)));
@ -1163,13 +1166,13 @@ if (secure) {
cert = fs.readFileSync((configJSON.cert[0] != "/" && !configJSON.cert.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + configJSON.cert : configJSON.cert).toString();
var sniNames = Object.keys(sni);
var sniCredentials = [];
for (var i = 0; i < sniNames.length; i++) {
sniNames.forEach(function (sniName) {
sniCredentials.push({
name: sniNames[i],
cert: fs.readFileSync((sni[sniNames[i]].cert[0] != "/" && !sni[sniNames[i]].cert.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniNames[i]].cert : sni[sniNames[i]].cert).toString(),
key: fs.readFileSync((sni[sniNames[i]].key[0] != "/" && !sni[sniNames[i]].key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniNames[i]].key : sni[sniNames[i]].key).toString()
name: sniName,
cert: fs.readFileSync((sni[sniName].cert[0] != "/" && !sni[sniName].cert.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniName].cert : sni[sniName].cert).toString(),
key: fs.readFileSync((sni[sniName].key[0] != "/" && !sni[sniName].key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniName].key : sni[sniName].key).toString()
});
});
}
}
var logFile = undefined;