fix ip fliters from files #3401
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
81557ab2d4
commit
df91c90d33
|
@ -608,7 +608,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, only users from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, only users from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:userAllowedIP.txt\""
|
||||||
},
|
},
|
||||||
"userBlockedIP": {
|
"userBlockedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -616,7 +616,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, users from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, users from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:userBlockedIP.txt\""
|
||||||
},
|
},
|
||||||
"agentAllowedIP": {
|
"agentAllowedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -624,7 +624,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, only agents from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, only agents from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:agentAllowedIP.txt\""
|
||||||
},
|
},
|
||||||
"agentBlockedIP": {
|
"agentBlockedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -632,7 +632,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, agents from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, agents from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:agentBlockedIP.txt\""
|
||||||
},
|
},
|
||||||
"authLog": {
|
"authLog": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -1967,7 +1967,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, only users from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, only users from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:userAllowedIP.txt\""
|
||||||
},
|
},
|
||||||
"userBlockedIP": {
|
"userBlockedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -1975,7 +1975,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, users from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, users from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:userBlockedIP.txt\""
|
||||||
},
|
},
|
||||||
"agentAllowedIP": {
|
"agentAllowedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -1983,7 +1983,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, only agents from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, only agents from allowed IP address ranges can connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:agentAllowedIP.txt\""
|
||||||
},
|
},
|
||||||
"agentBlockedIP": {
|
"agentBlockedIP": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -1991,7 +1991,7 @@
|
||||||
"array"
|
"array"
|
||||||
],
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "When set, agents from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\""
|
"description": "When set, agents from these denied IP address ranges will not be able to connect to the server. Example: \"192.168.2.100,192.168.1.0/24\" \"file:agentBlockedIP.txt\""
|
||||||
},
|
},
|
||||||
"userSessionIdleTimeout": {
|
"userSessionIdleTimeout": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|
|
@ -1339,6 +1339,10 @@ function CreateMeshCentralServer(config, args) {
|
||||||
if ((obj.config.domains[i].loginkey != null) && (obj.common.validateAlphaNumericArray(obj.config.domains[i].loginkey, 1, 128) == false)) { console.log("ERROR: Invalid login key, must be alpha-numeric string with no spaces."); process.exit(); return; }
|
if ((obj.config.domains[i].loginkey != null) && (obj.common.validateAlphaNumericArray(obj.config.domains[i].loginkey, 1, 128) == false)) { console.log("ERROR: Invalid login key, must be alpha-numeric string with no spaces."); process.exit(); return; }
|
||||||
if (typeof obj.config.domains[i].agentkey == 'string') { obj.config.domains[i].agentkey = [obj.config.domains[i].agentkey]; }
|
if (typeof obj.config.domains[i].agentkey == 'string') { obj.config.domains[i].agentkey = [obj.config.domains[i].agentkey]; }
|
||||||
if ((obj.config.domains[i].agentkey != null) && (obj.common.validateAlphaNumericArray(obj.config.domains[i].agentkey, 1, 128) == false)) { console.log("ERROR: Invalid agent key, must be alpha-numeric string with no spaces."); process.exit(); return; }
|
if ((obj.config.domains[i].agentkey != null) && (obj.common.validateAlphaNumericArray(obj.config.domains[i].agentkey, 1, 128) == false)) { console.log("ERROR: Invalid agent key, must be alpha-numeric string with no spaces."); process.exit(); return; }
|
||||||
|
obj.config.domains[i].userallowedip = obj.config.domains[i].userallowedip = readIpListFromFile(obj.config.domains[i].userallowedip);
|
||||||
|
obj.config.domains[i].userblockedip = obj.config.domains[i].userblockedip = readIpListFromFile(obj.config.domains[i].userblockedip);
|
||||||
|
obj.config.domains[i].agentallowedip = obj.config.domains[i].agentallowedip = readIpListFromFile(obj.config.domains[i].agentallowedip);
|
||||||
|
obj.config.domains[i].agentblockedip = obj.config.domains[i].agentblockedip = readIpListFromFile(obj.config.domains[i].agentblockedip);
|
||||||
if (typeof obj.config.domains[i].userallowedip == 'string') { if (obj.config.domains[i].userallowedip == '') { delete obj.config.domains[i].userallowedip; } else { obj.config.domains[i].userallowedip = obj.config.domains[i].userallowedip.split(' ').join('').split(','); } }
|
if (typeof obj.config.domains[i].userallowedip == 'string') { if (obj.config.domains[i].userallowedip == '') { delete obj.config.domains[i].userallowedip; } else { obj.config.domains[i].userallowedip = obj.config.domains[i].userallowedip.split(' ').join('').split(','); } }
|
||||||
if (typeof obj.config.domains[i].userblockedip == 'string') { if (obj.config.domains[i].userblockedip == '') { delete obj.config.domains[i].userblockedip; } else { obj.config.domains[i].userblockedip = obj.config.domains[i].userblockedip.split(' ').join('').split(','); } }
|
if (typeof obj.config.domains[i].userblockedip == 'string') { if (obj.config.domains[i].userblockedip == '') { delete obj.config.domains[i].userblockedip; } else { obj.config.domains[i].userblockedip = obj.config.domains[i].userblockedip.split(' ').join('').split(','); } }
|
||||||
if (typeof obj.config.domains[i].agentallowedip == 'string') { if (obj.config.domains[i].agentallowedip == '') { delete obj.config.domains[i].agentallowedip; } else { obj.config.domains[i].agentallowedip = obj.config.domains[i].agentallowedip.split(' ').join('').split(','); } }
|
if (typeof obj.config.domains[i].agentallowedip == 'string') { if (obj.config.domains[i].agentallowedip == '') { delete obj.config.domains[i].agentallowedip; } else { obj.config.domains[i].agentallowedip = obj.config.domains[i].agentallowedip.split(' ').join('').split(','); } }
|
||||||
|
@ -3762,7 +3766,7 @@ function CreateMeshCentralServer(config, args) {
|
||||||
function readIpListFromFile(arg) {
|
function readIpListFromFile(arg) {
|
||||||
if ((typeof arg != 'string') || (!arg.startsWith('file:'))) return arg;
|
if ((typeof arg != 'string') || (!arg.startsWith('file:'))) return arg;
|
||||||
var lines = null;
|
var lines = null;
|
||||||
try { lines = obj.fs.readFileSync(obj.path.join(obj.datapath, arg.substring(5))).toString().split('\r\n').join('\r').split('\r'); } catch (ex) { }
|
try { lines = obj.fs.readFileSync(obj.path.join(obj.datapath, arg.substring(5))).toString().split(/\r?\n/).join('\r').split('\r'); } catch (ex) { }
|
||||||
if (lines == null) return null;
|
if (lines == null) return null;
|
||||||
const validLines = [];
|
const validLines = [];
|
||||||
for (var i in lines) { if ((lines[i].length > 0) && (((lines[i].charAt(0) > '0') && (lines[i].charAt(0) < '9')) || (lines[i].charAt(0) == ':'))) validLines.push(lines[i]); }
|
for (var i in lines) { if ((lines[i].length > 0) && (((lines[i].charAt(0) > '0') && (lines[i].charAt(0) < '9')) || (lines[i].charAt(0) == ':'))) validLines.push(lines[i]); }
|
||||||
|
|
Loading…
Reference in New Issue