From 02239c8f2d727d4149e45c4b31b92ea1ea3bb424 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 19 Feb 2024 23:34:25 +0330 Subject: [PATCH] [xray] dns - new Co-Authored-By: Alireza Ahmadi --- web/html/xui/dns_modal.html | 86 +++++++++++++++++ web/html/xui/xray.html | 125 ++++++++++++++++++++++++- web/html/xui/xray_reverse_modal.html | 2 - web/translation/translate.en_US.toml | 9 ++ web/translation/translate.es_ES.toml | 9 ++ web/translation/translate.fa_IR.toml | 9 ++ web/translation/translate.id_ID.toml | 9 ++ web/translation/translate.ru_RU.toml | 9 ++ web/translation/translate.vi_VN.toml | 9 ++ web/translation/translate.zh_Hans.toml | 9 ++ 10 files changed, 270 insertions(+), 6 deletions(-) create mode 100644 web/html/xui/dns_modal.html diff --git a/web/html/xui/dns_modal.html b/web/html/xui/dns_modal.html new file mode 100644 index 00000000..8b687ab2 --- /dev/null +++ b/web/html/xui/dns_modal.html @@ -0,0 +1,86 @@ +{{define "dnsModal"}} + + + + + + + + + + + + + + [[ l ]] + + + + + + +{{end}} diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html index 3e6cf851..0ceafeab 100644 --- a/web/html/xui/xray.html +++ b/web/html/xui/xray.html @@ -133,12 +133,10 @@ description='{{ i18n "pages.xray.RoutingStrategyDesc" }}' /> - @@ -516,6 +514,61 @@ + + + + @@ -583,6 +636,12 @@ { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 }, ]; + const dnsColumns = [ + { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } }, + { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } }, + { title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } }, + ]; + const balancerColumns = [ { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } }, { title: '{{ i18n "pages.xray.balancer.tag"}}', dataIndex: 'tag', align: 'center', width: 50 }, @@ -1158,6 +1217,36 @@ this.templateSettings = newTemplateSettings; }, + addDNSServer(){ + dnsModal.show({ + title: '{{ i18n "pages.xray.dns.add" }}', + confirm: (dnsServer) => { + dnsServers = this.dnsServers; + dnsServers.push(dnsServer); + this.dnsServers = dnsServers; + dnsModal.close(); + }, + isEdit: false + }); + }, + editDNSServer(index){ + dnsModal.show({ + title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1), + dnsServer: this.dnsServers[index], + confirm: (dnsServer) => { + dnsServers = this.dnsServers; + dnsServers[index] = dnsServer; + this.dnsServers = dnsServers; + dnsModal.close(); + }, + isEdit: true + }); + }, + deleteDNSServer(index){ + newDnsServers = this.dnsServers; + newDnsServers.splice(index,1); + this.dnsServers = newDnsServers; + }, addRule(){ ruleModal.show({ title: '{{ i18n "pages.xray.rules.add"}}', @@ -1499,14 +1588,14 @@ familyProtectSettings: { get: function () { if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false; - return doAllItemsExist(this.templateSettings.dns.servers, this.settingsData.familyProtectDNS.servers); + return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers); }, set: function (newValue) { newTemplateSettings = this.templateSettings; if (newValue) { newTemplateSettings.dns = this.settingsData.familyProtectDNS; } else { - delete newTemplateSettings.dns; + newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data)) } this.templateSettings = newTemplateSettings; }, @@ -1780,6 +1869,34 @@ } }, }, + enableDNS: { + get: function () { + return this.templateSettings ? this.templateSettings.dns != null : false; + }, + set: function (newValue) { + newTemplateSettings = this.templateSettings; + newTemplateSettings.dns = newValue ? { servers: [], queryStrategy: "UseIP" } : null; + this.templateSettings = newTemplateSettings; + } + }, + dnsStrategy: { + get: function () { + return this.enableDNS ? this.templateSettings.dns.queryStrategy : null; + }, + set: function (newValue) { + newTemplateSettings = this.templateSettings; + newTemplateSettings.dns.queryStrategy = newValue; + this.templateSettings = newTemplateSettings; + } + }, + dnsServers: { + get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; }, + set: function (newValue) { + newTemplateSettings = this.templateSettings; + newTemplateSettings.dns.servers = newValue; + this.templateSettings = newTemplateSettings; + } + } }, }); diff --git a/web/html/xui/xray_reverse_modal.html b/web/html/xui/xray_reverse_modal.html index cb4e7037..724c9825 100644 --- a/web/html/xui/xray_reverse_modal.html +++ b/web/html/xui/xray_reverse_modal.html @@ -132,8 +132,6 @@ reverseModal: reverseModal, reverseTypes: { bridge: '{{ i18n "pages.xray.outbound.bridge" }}', portal:'{{ i18n "pages.xray.outbound.portal" }}'}, }, - methods: { - } }); diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 5e1afa9b..354cda48 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -449,6 +449,15 @@ "psk" = "PreShared Key" "domainStrategy" = "Domain Strategy" +[pages.xray.dns] +"enable" = "Enable DNS" +"enableDesc" = "Enable built-in DNS server" +"strategy" = "Query Strategy" +"strategyDesc" = "Overall strategy to resolve domain names" +"add" = "Add Server" +"edit" = "Edit Server" +"domains" = "Domains" + [pages.settings.security] "admin" = "Admin" "secret" = "Secret Token" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 80d162eb..5fb3eb71 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -449,6 +449,15 @@ "psk" = "Clave precompartida" "domainStrategy" = "Estrategia de dominio" +[pages.xray.dns] +"enable" = "Habilitar DNS" +"enableDesc" = "Habilitar servidor DNS integrado" +"strategy" = "Estrategia de consulta" +"strategyDesc" = "Estrategia general para resolver nombres de dominio" +"add" = "Agregar servidor" +"edit" = "Editar servidor" +"domains" = "Dominios" + [pages.settings.security] "admin" = "Administrador" "secret" = "Token Secreto" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 546712fd..ca9241e0 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -449,6 +449,15 @@ "psk" = "کلید مشترک" "domainStrategy" = "استراتژی حل دامنه" +[pages.xray.dns] +"enable" = "فعال کردن حل دامنه" +"enableDesc" = "سرور حل دامنه داخلی را فعال کنید" +"strategy" = "استراتژی پرس‌وجو" +"strategyDesc" = "استراتژی کلی برای حل نام دامنه" +"add" = "افزودن سرور" +"edit" = "ویرایش سرور" +"domains" = "دامنه‌ها" + [pages.settings.security] "admin" = "مدیر" "secret" = "توکن مخفی" diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml index cfa0210d..0ee07462 100644 --- a/web/translation/translate.id_ID.toml +++ b/web/translation/translate.id_ID.toml @@ -449,6 +449,15 @@ "psk" = "Kunci Pra-Bagi" "domainStrategy" = "Strategi Domain" +[pages.xray.dns] +"enable" = "Aktifkan DNS" +"enableDesc" = "Aktifkan server DNS bawaan" +"strategy" = "Strategi Kueri" +"strategyDesc" = "Strategi keseluruhan untuk menyelesaikan nama domain" +"add" = "Tambahkan Server" +"edit" = "Sunting Server" +"domains" = "Domains" + [pages.settings.security] "admin" = "Admin" "secret" = "Token Rahasia" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index dfb75d4a..ea14a6a5 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -449,6 +449,15 @@ "psk" = "Общий ключ" "domainStrategy" = "Стратегия домена" +[pages.xray.dns] +"enable" = "Включить DNS" +"enableDesc" = "Включить встроенный DNS-сервер" +"strategy" = "Стратегия запроса" +"strategyDesc" = "Общая стратегия разрешения доменных имен" +"add" = "Добавить сервер" +"edit" = "Редактировать сервер" +"domains" = "Домены" + [pages.settings.security] "admin" = "Админ" "secret" = "Секретный токен" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index b6e7fd46..52b655e9 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -449,6 +449,15 @@ "psk" = "Khóa chia sẻ" "domainStrategy" = "Chiến lược tên miền" +[pages.xray.dns] +"enable" = "Kích hoạt DNS" +"enableDesc" = "Kích hoạt máy chủ DNS tích hợp" +"strategy" = "Chiến lược truy vấn" +"strategyDesc" = "Chiến lược tổng thể để phân giải tên miền" +"add" = "Thêm máy chủ" +"edit" = "Chỉnh sửa máy chủ" +"domains" = "Tên miền" + [pages.settings.security] "admin" = "Quản trị viên" "secret" = "Mã thông báo bí mật" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index ba37ae92..0f0afc19 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -449,6 +449,15 @@ "psk" = "共享密钥" "domainStrategy" = "域策略" +[pages.xray.dns] +"enable" = "启用 DNS" +"enableDesc" = "启用内置 DNS 服务器" +"strategy" = "查询策略" +"strategyDesc" = "解析域名的总体策略" +"add" = "添加服务器" +"edit" = "编辑服务器" +"domains" = "域" + [pages.settings.security] "admin" = "管理员" "secret" = "密钥"