Skip to content

Commit

Permalink
Direct Sub Json - geoIP, geoSite
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Sep 24, 2024
1 parent 7c892ac commit c30c6f0
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 23 deletions.
66 changes: 53 additions & 13 deletions web/html/xui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,14 @@
</a-col>
</a-row>
<a-collapse v-if="enableDirect" style="margin-top: 14px;">
<a-collapse-panel header='{{ i18n "pages.settings.directSett"}}'>
<a-collapse-panel header='Geo IP'>
<a-list-item style="padding: 10px 20px">
<a-checkbox-group v-model="directCountries" name="Countries" :options="countryOptions"></a-checkbox-group>
<a-checkbox-group v-model="geoIP" name="Geo IP" :options="geoIPOptions"></a-checkbox-group>
</a-list-item>
</a-collapse-panel>
<a-collapse-panel header='Geo Site'>
<a-list-item style="padding: 10px 20px">
<a-checkbox-group v-model="geoSite" name="Geo Site" :options="geoSiteOptions"></a-checkbox-group>
</a-list-item>
</a-collapse-panel>
</a-collapse>
Expand Down Expand Up @@ -458,8 +463,7 @@
type: "field",
outboundTag: "direct",
domain: [
"geosite:category-ir",
"geosite:cn"
"geosite:category-ir"
],
"enabled": true
},
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.es_ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.fa_IR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"muxSett" = "تنظیمات ماکس"
"direct" = "اتصال مستقیم"
"directDesc" = "به طور مستقیم با دامنه ها یا محدوده آی‌پی یک کشور خاص ارتباط برقرار می کند"
"directSett" = "گزینه های اتصال مستقیم"


[pages.xray]
"title" = "پیکربندی ایکس‌ری"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.id_ID.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.pt_BR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.ru_RU.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"muxSett" = "Mux Настройки"
"direct" = "Прямая связь"
"directDesc" = "Напрямую устанавливает соединения с доменами или диапазонами IP конкретной страны."
"directSett" = "Варианты прямого подключения"


[pages.xray]
"title" = "Настройки Xray"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.tr_TR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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ı"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.uk_UA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"muxSett" = "Налаштування Mux"
"direct" = "Пряме підключення"
"directDesc" = "Безпосередньо встановлює з’єднання з доменами або діапазонами IP певної країни."
"directSett" = "Параметри прямого підключення"


[pages.xray]
"title" = "Xray конфігурації"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.vi_VN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion web/translation/translate.zh_CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"muxSett" = "复用器设置"
"direct" = "直接连接"
"directDesc" = "直接与特定国家的域或IP范围建立连接"
"directSett" = "直接连接选项"


[pages.xray]
"title" = "Xray 配置"
Expand Down

1 comment on commit c30c6f0

@reza211277reza
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

سلام داداش دمت گرم با پنلی که زدی
میشه به ربات پنل این قابلیت رو اضافه کنی که بشه کانفیگ ساخت
ممنونم

Please sign in to comment.