From f2c28822c1ebef8a0143c4d05676286072dab996 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 31 Mar 2023 00:52:48 +0330 Subject: [PATCH] option - ban ir ip - ban ir domain --- web/html/xui/setting.html | 71 +++++++++++++++++++++++++++- web/translation/translate.en_US.toml | 6 ++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index 057dae95..7acab065 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -97,7 +97,9 @@ - {{ i18n "pages.setting.advancedTemplate"}} + + + {{ i18n "pages.setting.advancedTemplate"}} @@ -304,6 +306,73 @@ this.templateSettings = newTemplateSettings }, }, + IRIpSettings: { + get: function () { + localIpFilter = false + if(this.templateSettings != null){ + this.templateSettings.routing.rules.forEach(routingRule => { + if(routingRule.hasOwnProperty("ip")){ + if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){ + localIpFilter = true + } + } + }); + } + return localIpFilter + }, + set: function (newValue) { + newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig); + if (newValue){ + newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"ip\": [\"geoip:ir\"],\"type\": \"field\"}")) + } + else { + newTemplateSettings.routing.rules = []; + this.templateSettings.routing.rules.forEach(routingRule => { + if (routingRule.hasOwnProperty('ip')){ + if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){ + return; + } + } + newTemplateSettings.routing.rules.push(routingRule); + }); + } + this.templateSettings = newTemplateSettings + }, + }, + IRdomainSettings: { + get: function () { + localdomainFilter = false + if(this.templateSettings != null){ + this.templateSettings.routing.rules.forEach(routingRule => { + if(routingRule.hasOwnProperty("domain")){ + if (routingRule.domain[0] === "regexp:.+.ir$" && routingRule.outboundTag == "blocked"){ + localdomainFilter = true + } + } + }); + } + return localdomainFilter + }, + set: function (newValue) { + newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig); + if (newValue){ + newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"domain\": [\"regexp:.+.ir$\"],\"type\": \"field\"}")) + } + else { + newTemplateSettings.routing.rules = []; + this.templateSettings.routing.rules.forEach(routingRule => { + if (routingRule.hasOwnProperty('domain')){ + if (routingRule.domain[0] === "regexp:.+.ir$" && routingRule.outboundTag == "blocked"){ + return; + } + } + newTemplateSettings.routing.rules.push(routingRule); + }); + } + this.templateSettings = newTemplateSettings + }, + }, + } }); diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 247096f1..c40c5da1 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -202,8 +202,12 @@ "xrayConfigTemplateDesc" = "Generate the final xray configuration file based on this template, restart the panel to take effect." "xrayConfigTorrent" = "Ban bittorrent usage" "xrayConfigTorrentDesc" = "Change the configuration temlate to avoid using bittorrent by users, restart the panel to take effect" -"xrayConfigPrivateIp" = "Ban private ip range to connect" +"xrayConfigPrivateIp" = "Ban private IP ranges to connect" "xrayConfigPrivateIpDesc" = "Change the configuration temlate to avoid connecting with private IP ranges, restart the panel to take effect" +"xrayConfigIRIp" = "Ban Iran IP ranges to connect" +"xrayConfigIRIpDesc" = "Change the configuration temlate to avoid connecting with Iran IP ranges, restart the panel to take effect" +"xrayConfigIRdomain" = "Ban IR domains to connect" +"xrayConfigIRdomainDesc" = "Change the configuration temlate to avoid connecting with IR domains, restart the panel to take effect" "xrayConfigInbounds" = "Configuration of Inbounds" "xrayConfigInboundsDesc" = "Change the configuration temlate to accept special clients, restart the panel to take effect" "xrayConfigOutbounds" = "Configuration of Outbounds"