Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web/html
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2024-02-19 23:04:25 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2024-02-19 23:04:25 +0300
commit02239c8f2d727d4149e45c4b31b92ea1ea3bb424 (patch)
tree99dbe50d2d58b173af9b4092d0601773c7ac7c37 /web/html
parent70b3db074aa6c82182219aa13f048d41632d8ed0 (diff)
[xray] dns - new
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/html')
-rw-r--r--web/html/xui/dns_modal.html86
-rw-r--r--web/html/xui/xray.html125
-rw-r--r--web/html/xui/xray_reverse_modal.html2
3 files changed, 207 insertions, 6 deletions
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"}}
+<a-modal id="dns-modal" v-model="dnsModal.visible" :title="dnsModal.title" @ok="dnsModal.ok"
+ :closable="true" :mask-closable="false"
+ :ok-text="dnsModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme">
+ <a-form :colon="false" :label-col="{ md: {span:6} }" :wrapper-col="{ md: {span:14} }">
+ <a-form-item label='{{ i18n "pages.xray.outbound.address" }}'>
+ <a-input v-model.trim="dnsModal.dnsServer.address"></a-input>
+ </a-form-item>
+ <a-form-item label='{{ i18n "pages.xray.dns.domains" }}'>
+ <a-button size="small" type="primary" @click="dnsModal.dnsServer.domains.push('')">+</a-button>
+ <template v-for="(domain, index) in dnsModal.dnsServer.domains">
+ <a-input v-model.trim="dnsModal.dnsServer.domains[index]">
+ <a-button size="small" slot="addonAfter" @click="dnsModal.dnsServer.domains.splice(index,1)">-</a-button>
+ </a-input>
+ </template>
+ </a-form-item>
+ <a-form-item label='{{ i18n "pages.xray.dns.strategy" }}' v-if="isAdvanced">
+ <a-select
+ v-model="dnsModal.dnsServer.queryStrategy"
+ style="width: 100%"
+ :dropdown-class-name="themeSwitcher.currentTheme">
+ <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
+ [[ l ]]
+ </a-select-option>
+ </a-select>
+ </a-form-item>
+ </a-form>
+</a-modal>
+<script>
+ const dnsModal = {
+ title: '',
+ visible: false,
+ okText: '{{ i18n "confirm" }}',
+ isEdit: false,
+ confirm: null,
+ dnsServer: {
+ address: "localhost",
+ domains: [],
+ queryStrategy: 'UseIP',
+ },
+ ok() {
+ domains = dnsModal.dnsServer.domains.filter(d => d.length>0);
+ dnsModal.dnsServer.domains = domains;
+ newDnsServer = domains.length > 0 ? dnsModal.dnsServer : dnsModal.dnsServer.address;
+ ObjectUtil.execute(dnsModal.confirm, newDnsServer);
+ },
+ show({ title='', okText='{{ i18n "confirm" }}', dnsServer, confirm=(dnsServer)=>{}, isEdit=false }) {
+ this.title = title;
+ this.okText = okText;
+ this.confirm = confirm;
+ this.visible = true;
+ if(isEdit) {
+ if (typeof dnsServer == 'object'){
+ this.dnsServer = dnsServer;
+ } else {
+ this.dnsServer.address = dnsServer?? '';
+ }
+ } else {
+ this.dnsServer = {
+ address: "localhost",
+ domains: [],
+ queryStrategy: 'UseIP',
+ }
+ }
+ this.isEdit = isEdit;
+ },
+ close() {
+ dnsModal.visible = false;
+ },
+ };
+
+ new Vue({
+ delimiters: ['[[', ']]'],
+ el: '#dns-modal',
+ data: {
+ dnsModal: dnsModal,
+ },
+ computed: {
+ isAdvanced: {
+ get: function () { return dnsModal.dnsServer.domains.length>0 }
+ }
+ }
+ });
+
+</script>
+{{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" }}' />
</a-col>
<a-col :lg="24" :xl="12">
- <template>
<a-select v-model="routingStrategy" :dropdown-class-name="themeSwitcher.currentTheme"
style="width: 100%">
<a-select-option v-for="s in routingDomainStrategies" :value="s">[[ s ]]</a-select-option>
</a-select>
- </template>
</a-col>
</a-row>
</a-list-item>
@@ -516,6 +514,61 @@
</template>
</a-table>
</a-tab-pane>
+ <a-tab-pane key="tpl-5" tab='DNS' style="padding-top: 20px;" force-render="true">
+ <setting-list-item type="switch" title='{{ i18n "pages.xray.dns.enable" }}' desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item>
+ <template v-if="enableDNS">
+ <a-list-item>
+ <a-row style="padding: 20px">
+ <a-col :lg="24" :xl="12">
+ <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}' description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
+ </a-col>
+ <a-col :lg="24" :xl="12">
+ <a-select
+ v-model="dnsStrategy"
+ style="width: 100%"
+ :dropdown-class-name="themeSwitcher.currentTheme">
+ <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
+ [[ l ]]
+ </a-select-option>
+ </a-select>
+ </a-col>
+ </a-row>
+ </a-list-item>
+ <a-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n "pages.xray.dns.add" }}</a-button>
+ <a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0"
+ :row-key="r => r.key"
+ :data-source="dnsServers"
+ :scroll="isMobile ? {} : { x: 200 }"
+ :pagination="false"
+ :indent-size="0"
+ :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
+ <template slot="action" slot-scope="text,dns,index">
+ [[ index+1 ]]
+ <a-dropdown :trigger="['click']">
+ <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
+ <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
+ <a-menu-item @click="editDNSServer(index)">
+ <a-icon type="edit"></a-icon>
+ {{ i18n "edit" }}
+ </a-menu-item>
+ <a-menu-item @click="deleteDNSServer(index)">
+ <span style="color: #FF4D4F">
+ <a-icon type="delete"></a-icon> {{ i18n "delete"}}
+ </span>
+ </a-menu-item>
+ </a-menu>
+ </a-dropdown>
+ </template>
+ <template slot="address" slot-scope="dns,index">
+ <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
+ <span v-else>[[ dns ]]</span>
+ </template>
+ <template slot="domain" slot-scope="dns,index">
+ <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
+ </template>
+ </a-table>
+ </template>
+ </a-tab-pane>
<a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
<a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
<a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
@@ -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;
+ }
+ }
},
});
</script>
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: {
- }
});
</script>