From 02239c8f2d727d4149e45c4b31b92ea1ea3bb424 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 19 Feb 2024 23:34:25 +0330 Subject: [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 - 3 files changed, 207 insertions(+), 6 deletions(-) create mode 100644 web/html/xui/dns_modal.html (limited to 'web/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: { - } }); -- cgit v1.2.3