Skip to content

Commit cb22b4a

Browse files
authored
chore: add new dns features from v25.6.8
* chore: add new dns params * chore: add `DNS Presets` modal * chore: edit file names
1 parent 6a2e007 commit cb22b4a

20 files changed

+354
-203
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{{define "modals/dnsPresetsModal"}}
2+
<a-modal id="dnsPresets-modal" v-model="dnsPresetsModal.visible" :title="dnsPresetsModal.title" :closable="true"
3+
:mask-closable="false" :footer="null" :class="themeSwitcher.currentTheme">
4+
<a-list class="ant-dns-presets-list" bordered :style="{ width: '100%' }">
5+
<a-list-item v-for="dns in dnsPresetsDatabase" :style="{ padding: '12px 16px' }">
6+
<a-row justify="space-between" align="middle">
7+
<a-col :span="12">
8+
<a-space direction="vertical" size="small">
9+
<span class="ant-dns-presets-list-name">[[ dns.name ]]</span>
10+
<a-tag :color="dns.family ? 'purple' : 'green'">[[ dns.family ? '{{ i18n "pages.xray.dns.dnsPresetFamily" }}' : 'DNS' ]]</a-tag>
11+
</a-space>
12+
</a-col>
13+
<a-col :span="12" :style="{ textAlign: 'right' }">
14+
<a-button type="primary" @click="dnsPresetsModal.install(dns.data)">{{ i18n "install" }}</a-button>
15+
</a-col>
16+
</a-row>
17+
</a-list-item>
18+
</a-list>
19+
</a-modal>
20+
21+
<style>
22+
.dark .ant-dns-presets-list {
23+
border-color: var(--dark-color-stroke)
24+
}
25+
26+
.dark .ant-dns-presets-list-name {
27+
color: var(--dark-color-text-primary);
28+
}
29+
</style>
30+
31+
<script>
32+
const dnsPresetsDatabase = [
33+
{
34+
name: 'Google DNS',
35+
family: false,
36+
data: [
37+
"8.8.8.8",
38+
"8.8.4.4",
39+
"2001:4860:4860::8888",
40+
"2001:4860:4860::8844"
41+
]
42+
},
43+
{
44+
name: 'Cloudflare DNS',
45+
family: false,
46+
data: [
47+
"1.1.1.1",
48+
"1.0.0.1",
49+
"2606:4700:4700::1111",
50+
"2606:4700:4700::1001"
51+
]
52+
},
53+
{
54+
name: 'Adguard DNS',
55+
family: false,
56+
data: [
57+
"94.140.14.14",
58+
"94.140.15.15",
59+
"2a10:50c0::ad1:ff",
60+
"2a10:50c0::ad2:ff"
61+
]
62+
},
63+
{
64+
name: 'Adguard Family DNS',
65+
family: true,
66+
data: [
67+
"94.140.14.14",
68+
"94.140.15.15",
69+
"2a10:50c0::ad1:ff",
70+
"2a10:50c0::ad2:ff"
71+
]
72+
},
73+
{
74+
name: 'Cloudflare Family DNS',
75+
family: true,
76+
data: [
77+
"1.1.1.3",
78+
"1.0.0.3",
79+
"2606:4700:4700::1113",
80+
"2606:4700:4700::1003"
81+
]
82+
}
83+
]
84+
85+
const dnsPresetsModal = {
86+
title: '',
87+
visible: false,
88+
selected: null,
89+
install(selectedPreset) {
90+
return ObjectUtil.execute(dnsPresetsModal.selected, selectedPreset);
91+
},
92+
show({ title = '', selected = (selectedPreset) => { }, isEdit = false }) {
93+
this.title = title;
94+
this.selected = selected;
95+
this.visible = true;
96+
},
97+
close() {
98+
dnsPresetsModal.visible = false;
99+
},
100+
};
101+
102+
new Vue({
103+
delimiters: ['[[', ']]'],
104+
el: '#dnsPresets-modal',
105+
data: {
106+
dnsPresetsModal: dnsPresetsModal,
107+
}
108+
});
109+
</script>
110+
{{end}}

web/html/modals/fakedns_modal.html

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
<a-form-item label='{{ i18n "pages.xray.outbound.address" }}'>
77
<a-input v-model.trim="dnsModal.dnsServer.address"></a-input>
88
</a-form-item>
9+
<a-form-item label='{{ i18n "pages.inbounds.port" }}'>
10+
<a-input-number v-model.number="dnsModal.dnsServer.port" :min="1" :max="65531"></a-input-number>
11+
</a-form-item>
12+
<a-form-item label='{{ i18n "pages.xray.dns.strategy" }}'>
13+
<a-select v-model="dnsModal.dnsServer.queryStrategy" :style="{ width: '100%' }"
14+
:dropdown-class-name="themeSwitcher.currentTheme">
15+
<a-select-option :value="l" :label="l" v-for="l in ['UseSystem', 'UseIP', 'UseIPv4', 'UseIPv6']"> [[ l ]] </a-select-option>
16+
</a-select>
17+
</a-form-item>
18+
<a-divider :style="{ margin: '5px 0' }"></a-divider>
919
<a-form-item label='{{ i18n "pages.xray.dns.domains" }}'>
1020
<a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.domains.push('')"></a-button>
1121
<template v-for="(domain, index) in dnsModal.dnsServer.domains">
@@ -15,15 +25,6 @@
1525
</a-input>
1626
</template>
1727
</a-form-item>
18-
<a-form-item label='{{ i18n "pages.xray.dns.strategy" }}' v-if="isAdvanced">
19-
<a-select v-model="dnsModal.dnsServer.queryStrategy" :style="{ width: '100%' }"
20-
:dropdown-class-name="themeSwitcher.currentTheme">
21-
<a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']"> [[ l ]] </a-select-option>
22-
</a-select>
23-
</a-form-item>
24-
<a-form-item label='Skip Fallback' v-if="isAdvanced">
25-
<a-switch v-model="dnsModal.dnsServer.skipFallback"></a-switch>
26-
</a-form-item>
2728
<a-form-item label='{{ i18n "pages.xray.dns.expectIPs"}}'>
2829
<a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.expectIPs.push('')"></a-button>
2930
<template v-for="(domain, index) in dnsModal.dnsServer.expectIPs">
@@ -33,31 +34,50 @@
3334
</a-input>
3435
</template>
3536
</a-form-item>
37+
<a-form-item label='{{ i18n "pages.xray.dns.unexpectIPs"}}'>
38+
<a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.unexpectedIPs.push('')"></a-button>
39+
<template v-for="(domain, index) in dnsModal.dnsServer.unexpectedIPs">
40+
<a-input v-model.trim="dnsModal.dnsServer.unexpectedIPs[index]">
41+
<a-button icon="minus" size="small" slot="addonAfter"
42+
@click="dnsModal.dnsServer.unexpectedIPs.splice(index,1)"></a-button>
43+
</a-input>
44+
</template>
45+
</a-form-item>
46+
<a-divider :style="{ margin: '5px 0' }"></a-divider>
47+
<a-form-item label='Skip Fallback'>
48+
<a-switch v-model="dnsModal.dnsServer.skipFallback"></a-switch>
49+
</a-form-item>
50+
<a-form-item label='Disable Cache'>
51+
<a-switch v-model="dnsModal.dnsServer.disableCache"></a-switch>
52+
</a-form-item>
53+
<a-form-item label='Final Query'>
54+
<a-switch v-model="dnsModal.dnsServer.finalQuery"></a-switch>
55+
</a-form-item>
3656
</a-form>
3757
</a-modal>
3858
<script>
59+
const defaultDnsObject = {
60+
address: "localhost",
61+
port: 53,
62+
domains: [],
63+
expectIPs: [],
64+
unexpectedIPs: [],
65+
queryStrategy: 'UseIP',
66+
skipFallback: true,
67+
disableCache: false,
68+
finalQuery: false
69+
}
70+
3971
const dnsModal = {
4072
title: '',
4173
visible: false,
4274
okText: '{{ i18n "confirm" }}',
4375
isEdit: false,
4476
confirm: null,
45-
dnsServer: {
46-
address: "localhost",
47-
domains: [],
48-
expectIPs: [],
49-
queryStrategy: 'UseIP',
50-
skipFallback: true,
77+
dnsServer: { ...defaultDnsObject },
78+
ok() {
79+
ObjectUtil.execute(dnsModal.confirm, { ...dnsModal.dnsServer });
5180
},
52-
ok() {
53-
domains = dnsModal.dnsServer.domains.filter(d => d.length > 0);
54-
expectIPs = dnsModal.dnsServer.expectIPs.filter(ip => ip.length > 0);
55-
dnsModal.dnsServer.domains = domains;
56-
dnsModal.dnsServer.expectIPs = expectIPs;
57-
newDnsServer = (domains.length > 0 || expectIPs.length > 0) ? dnsModal.dnsServer : dnsModal.dnsServer.address;
58-
ObjectUtil.execute(dnsModal.confirm, newDnsServer);
59-
},
60-
6181
show({
6282
title = '',
6383
okText = '{{ i18n "confirm" }}',
@@ -69,28 +89,28 @@
6989
this.okText = okText;
7090
this.confirm = confirm;
7191
this.visible = true;
92+
this.isEdit = isEdit;
93+
7294
if (isEdit) {
73-
if (typeof dnsServer == 'object') {
74-
this.dnsServer = dnsServer;
75-
} else {
76-
this.dnsServer = {
77-
address: dnsServer ?? "",
78-
domains: [],
79-
expectIPs: [],
80-
queryStrategy: 'UseIP',
81-
skipFallback: true,
82-
}
95+
switch (typeof dnsServer) {
96+
case 'string':
97+
const dnsObj = { ...defaultDnsObject };
98+
99+
dnsObj.address = dnsServer;
100+
101+
this.dnsServer = dnsObj;
102+
break;
103+
case 'object':
104+
this.dnsServer = dnsServer;
105+
break;
83106
}
84107
} else {
85-
this.dnsServer = {
86-
address: "localhost",
87-
domains: [],
88-
expectIPs: [],
89-
queryStrategy: 'UseIP',
90-
skipFallback: true,
91-
}
108+
this.dnsServer = { ...defaultDnsObject };
109+
110+
this.dnsServer.domains = [];
111+
this.dnsServer.expectIPs = [];
112+
this.dnsServer.unexpectedIPs = [];
92113
}
93-
this.isEdit = isEdit;
94114
},
95115
close() {
96116
dnsModal.visible = false;
@@ -101,13 +121,6 @@
101121
el: '#dns-modal',
102122
data: {
103123
dnsModal: dnsModal,
104-
},
105-
computed: {
106-
isAdvanced: {
107-
get: function () {
108-
return dnsModal.dnsServer.domains.length > 0;
109-
}
110-
}
111124
}
112125
});
113126
</script>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{define "modals/fakednsModal"}}
2+
<a-modal id="fakedns-modal" v-model="fakednsModal.visible" :title="fakednsModal.title" @ok="fakednsModal.ok"
3+
:closable="true" :mask-closable="false" :ok-text="fakednsModal.okText" cancel-text='{{ i18n "close" }}'
4+
:class="themeSwitcher.currentTheme">
5+
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
6+
<a-form-item label='{{ i18n "pages.xray.fakedns.ipPool" }}'>
7+
<a-input v-model.trim="fakednsModal.fakeDns.ipPool"></a-input>
8+
</a-form-item>
9+
<a-form-item label='{{ i18n "pages.xray.fakedns.poolSize" }}'>
10+
<a-input-number v-model.number="fakednsModal.fakeDns.poolSize" :min="1"></a-input-number>
11+
</a-form-item>
12+
</a-form>
13+
</a-modal>
14+
<script>
15+
const fakednsDefaultData = {
16+
ipPool: "198.18.0.0/16",
17+
poolSize: 65535,
18+
}
19+
20+
const fakednsModal = {
21+
title: '',
22+
visible: false,
23+
okText: '{{ i18n "confirm" }}',
24+
isEdit: false,
25+
confirm: null,
26+
fakeDns: { ...fakednsDefaultData },
27+
ok() {
28+
ObjectUtil.execute(fakednsModal.confirm, fakednsModal.fakeDns);
29+
},
30+
show({ title = '', okText = '{{ i18n "confirm" }}', fakeDns, confirm = (fakeDns) => { }, isEdit = false }) {
31+
this.title = title;
32+
this.okText = okText;
33+
this.confirm = confirm;
34+
this.visible = true;
35+
if (isEdit) {
36+
this.fakeDns = fakeDns;
37+
} else {
38+
this.fakeDns = { ...fakednsDefaultData }
39+
}
40+
this.isEdit = isEdit;
41+
},
42+
close() {
43+
fakednsModal.visible = false;
44+
},
45+
};
46+
47+
new Vue({
48+
delimiters: ['[[', ']]'],
49+
el: '#fakedns-modal',
50+
data: {
51+
fakednsModal: fakednsModal,
52+
}
53+
});
54+
55+
</script>
56+
{{end}}

0 commit comments

Comments
 (0)