From c30c6f08f36e1784ba59108f0b9d3d160b83daa1 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 24 Sep 2024 14:57:14 +0200 Subject: [PATCH] Direct Sub Json - geoIP, geoSite --- web/html/xui/settings.html | 66 ++++++++++++++++++++++------ web/translation/translate.en_US.toml | 2 +- web/translation/translate.es_ES.toml | 2 +- web/translation/translate.fa_IR.toml | 2 +- web/translation/translate.id_ID.toml | 2 +- web/translation/translate.pt_BR.toml | 2 +- web/translation/translate.ru_RU.toml | 2 +- web/translation/translate.tr_TR.toml | 2 +- web/translation/translate.uk_UA.toml | 2 +- web/translation/translate.vi_VN.toml | 2 +- web/translation/translate.zh_CN.toml | 2 +- 11 files changed, 63 insertions(+), 23 deletions(-) diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html index 2ea44418d4..7cebfd1eec 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); } diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index f92f46edc4..0978e84e55 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -316,7 +316,7 @@ "muxSett" = "Mux Settings" "direct" = "Direct Connection" "directDesc" = "Directly establishes connections with domains or IP ranges of a specific country." -"directSett" = "Direct Connection Options" + [pages.xray] "title" = "Xray Configs" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 462e534e0f..1997bd8282 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -316,7 +316,7 @@ "muxSett" = "Configuración Mux" "direct" = "Conexión Directa" "directDesc" = "Establece conexiones directas con dominios o rangos de IP de un país específico." -"directSett" = "Opciones de Conexión Directa" + [pages.xray] "title" = "Xray Configuración" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 0b4e7854c5..dac201f209 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -316,7 +316,7 @@ "muxSett" = "تنظیمات ماکس" "direct" = "اتصال مستقیم" "directDesc" = "به طور مستقیم با دامنه ها یا محدوده آی‌پی یک کشور خاص ارتباط برقرار می کند" -"directSett" = "گزینه های اتصال مستقیم" + [pages.xray] "title" = "پیکربندی ایکس‌ری" diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml index b59c5fc7b3..565b10a767 100644 --- a/web/translation/translate.id_ID.toml +++ b/web/translation/translate.id_ID.toml @@ -316,7 +316,7 @@ "muxSett" = "Pengaturan Mux" "direct" = "Koneksi langsung" "directDesc" = "Secara langsung membuat koneksi dengan domain atau rentang IP negara tertentu." -"directSett" = "Opsi Koneksi Langsung" + [pages.xray] "title" = "Konfigurasi Xray" diff --git a/web/translation/translate.pt_BR.toml b/web/translation/translate.pt_BR.toml index 4da6d8f90d..106bc9b9bd 100644 --- a/web/translation/translate.pt_BR.toml +++ b/web/translation/translate.pt_BR.toml @@ -316,7 +316,7 @@ "muxSett" = "Configurações de Mux" "direct" = "Conexão Direta" "directDesc" = "Estabelece conexões diretamente com domínios ou intervalos de IP de um país específico." -"directSett" = "Opções de Conexão Direta" + [pages.xray] "title" = "Configurações Xray" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index 59196c0089..7ddc95c87b 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -316,7 +316,7 @@ "muxSett" = "Mux Настройки" "direct" = "Прямая связь" "directDesc" = "Напрямую устанавливает соединения с доменами или диапазонами IP конкретной страны." -"directSett" = "Варианты прямого подключения" + [pages.xray] "title" = "Настройки Xray" diff --git a/web/translation/translate.tr_TR.toml b/web/translation/translate.tr_TR.toml index 1274941f93..f21a292779 100644 --- a/web/translation/translate.tr_TR.toml +++ b/web/translation/translate.tr_TR.toml @@ -316,7 +316,7 @@ "muxSett" = "Mux Ayarları" "direct" = "Doğrudan Bağlantı" "directDesc" = "Belirli bir ülkenin alan adları veya IP aralıkları ile doğrudan bağlantı kurar." -"directSett" = "Doğrudan Bağlantı Seçenekleri" + [pages.xray] "title" = "Xray Yapılandırmaları" diff --git a/web/translation/translate.uk_UA.toml b/web/translation/translate.uk_UA.toml index 221c34d5e4..1ed68eab32 100644 --- a/web/translation/translate.uk_UA.toml +++ b/web/translation/translate.uk_UA.toml @@ -316,7 +316,7 @@ "muxSett" = "Налаштування Mux" "direct" = "Пряме підключення" "directDesc" = "Безпосередньо встановлює з’єднання з доменами або діапазонами IP певної країни." -"directSett" = "Параметри прямого підключення" + [pages.xray] "title" = "Xray конфігурації" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index e45c664b77..edcf56bb85 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -316,7 +316,7 @@ "muxSett" = "Mux Cài đặt" "direct" = "Kết nối trực tiếp" "directDesc" = "Trực tiếp thiết lập kết nối với tên miền hoặc dải IP của một quốc gia cụ thể." -"directSett" = "Tùy chọn kết nối trực tiếp" + [pages.xray] "title" = "Cài đặt Xray" diff --git a/web/translation/translate.zh_CN.toml b/web/translation/translate.zh_CN.toml index 0314b0ab10..65a2a6ea79 100644 --- a/web/translation/translate.zh_CN.toml +++ b/web/translation/translate.zh_CN.toml @@ -316,7 +316,7 @@ "muxSett" = "复用器设置" "direct" = "直接连接" "directDesc" = "直接与特定国家的域或IP范围建立连接" -"directSett" = "直接连接选项" + [pages.xray] "title" = "Xray 配置"