From c30c6f08f36e1784ba59108f0b9d3d160b83daa1 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 24 Sep 2024 14:57:14 +0200 Subject: Direct Sub Json - geoIP, geoSite --- web/html/xui/settings.html | 66 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 13 deletions(-) (limited to 'web/html') diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html index 2ea44418..7cebfd1e 100644 --- a/web/html/xui/settings.html +++ b/web/html/xui/settings.html @@ -380,9 +380,14 @@ - + - + + + + + + @@ -458,8 +463,7 @@ type: "field", outboundTag: "direct", domain: [ - "geosite:category-ir", - "geosite:cn" + "geosite:category-ir" ], "enabled": true }, @@ -468,17 +472,30 @@ outboundTag: "direct", ip: [ "geoip:private", - "geoip:ir", - "geoip:cn" + "geoip:ir" ], enabled: true }, ], - countryOptions: [ + geoIPOptions: [ { label: 'Private IP/Domain', value: 'private' }, { label: '🇮🇷 Iran', value: 'ir' }, { label: '🇨🇳 China', value: 'cn' }, { label: '🇷🇺 Russia', value: 'ru' }, + { label: '🇻🇳 Vietnam', value: 'vn' }, + { label: '🇪🇸 Spain', value: 'es' }, + { label: '🇮🇩 Indonesia', value: 'id' }, + { label: '🇺🇦 Ukraine', value: 'ua' }, + { label: '🇹🇷 Türkiye', value: 'tr' }, + { label: '🇧🇷 Brazil', value: 'br' }, + ], + geoSiteOptions: [ + { label: '🇮🇷 Iran', value: 'ir' }, + { label: '🇨🇳 China', value: 'cn' }, + { label: '🇷🇺 Russia', value: 'ru' }, + { label: 'Apple', value: 'apple' }, + { label: 'Meta', value: 'meta' }, + { label: 'Google', value: 'google' }, ], get remarkModel() { rm = this.allSetting.remarkModel; @@ -730,26 +747,49 @@ this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : ""; } }, - directCountries: { + geoIP: { get: function () { if (!this.enableDirect) return []; - rules = JSON.parse(this.allSetting.subJsonRules); + const rules = JSON.parse(this.allSetting.subJsonRules); return Array.isArray(rules) ? rules[1].ip.map(d => d.replace("geoip:", "")) : []; }, set: function (v) { - rules = JSON.parse(this.allSetting.subJsonRules); + const rules = JSON.parse(this.allSetting.subJsonRules); if (!Array.isArray(rules)) return; - rules[0].domain = []; + rules[1].ip = []; + v.forEach(d => { + rules[1].ip.push("geoip:" + d); + }); + this.allSetting.subJsonRules = JSON.stringify(rules); + } + }, + geoSite: { + get: function () { + if (!this.enableDirect) return []; + const rules = JSON.parse(this.allSetting.subJsonRules); + return Array.isArray(rules) ? + rules[0].domain.map(d => { + if (d.startsWith("geosite:category-")) { + return d.replace("geosite:category-", ""); + } + return d.replace("geosite:", ""); + }) + : []; + }, + set: function (v) { + const rules = JSON.parse(this.allSetting.subJsonRules); + if (!Array.isArray(rules)) return; + + rules[0].domain = []; v.forEach(d => { let category = ''; - if (["cn", "private"].includes(d)) { + if (["cn", "apple", "meta", "google"].includes(d)) { category = ""; } else if (["ru", "ir"].includes(d)) { category = "category-"; } rules[0].domain.push("geosite:" + category + d); - rules[1].ip.push("geoip:" + d); }); this.allSetting.subJsonRules = JSON.stringify(rules); } -- cgit v1.2.3