Skip to content

Commit 44fc56d

Browse files
committed
feat: 域名解析支持多个自定义 DNS, 支持设置 DNS 超时和单独的 DNS 缓存时长
1 parent 63c0646 commit 44fc56d

5 files changed

Lines changed: 117 additions & 27 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.27.0",
3+
"version": "2.27.1",
44
"private": true,
55
"packageManager": "pnpm@11.0.9",
66
"scripts": {

src/locales/en.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,12 +621,18 @@ export default {
621621
"IPv6 Only",
622622
],
623623
cache: ["Enabled", "Disabled"],
624-
customDns: "Default Custom DNS (DoH on all platforms; DoT and TCP/UDP DNS additionally in Node.js)",
625-
customDnsPlaceholder: "Enter DoH, [udp://]1.1.1.1[:53], tcp://1.1.1.1[:53], or tls://223.5.5.5[:853] (brackets are optional)",
624+
customDns: "Custom DNS (one per line; DoH on all platforms; DoT and TCP/UDP DNS additionally in Node.js)",
625+
customDnsPlaceholder: "One DNS per line: DoH, [udp://]1.1.1.1[:53], tcp://1.1.1.1[:53], or tls://223.5.5.5[:853] (brackets are optional)",
626626
tlsSkipCertVerify: "DoH/DoT Server Certificate",
627627
tlsSkipCertVerifyOptions: ["Verify", "Do Not Verify"],
628+
dnsConcurrency: "Multi-DNS Concurrency",
629+
dnsConcurrencyPlaceholder: "Default 2",
628630
concurrency: "Request Concurrency",
629631
concurrencyPlaceholder: "Default 10. Keep proxy apps at 20 or less",
632+
timeout: "DNS Timeout",
633+
timeoutPlaceholder: "Default: global request timeout (ms)",
634+
cacheTtl: "Cache TTL",
635+
cacheTtlPlaceholder: "Default: global cache TTL (seconds)",
630636
tipsTitle: "domain Tips",
631637
tipsDes: "Operation instructions for node domain name resolution",
632638
},

src/locales/ru.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,18 @@ export default {
606606
"Включено",
607607
"Отключено"
608608
],
609-
"customDns": "DNS по умолчанию (DoH на всех платформах; DoT и TCP/UDP DNS дополнительно в Node.js)",
610-
"customDnsPlaceholder": "Введите DoH, [udp://]1.1.1.1[:53], tcp://1.1.1.1[:53] или tls://223.5.5.5[:853] (скобки необязательны)",
609+
"customDns": "Custom DNS (по одному в строке; DoH на всех платформах; DoT и TCP/UDP DNS дополнительно в Node.js)",
610+
"customDnsPlaceholder": "По одному DNS в строке: DoH, [udp://]1.1.1.1[:53], tcp://1.1.1.1[:53] или tls://223.5.5.5[:853] (скобки необязательны)",
611611
"tlsSkipCertVerify": "Сертификат сервера DoH/DoT",
612612
"tlsSkipCertVerifyOptions": ["Проверять", "Не проверять"],
613+
"dnsConcurrency": "Параллельность нескольких DNS",
614+
"dnsConcurrencyPlaceholder": "По умолчанию 2",
613615
"concurrency": "Конкурентность запросов",
614616
"concurrencyPlaceholder": "По умолчанию 10. Рекомендуется ставить не более 20",
617+
"timeout": "DNS timeout",
618+
"timeoutPlaceholder": "По умолчанию глобальный таймаут запросов (мс)",
619+
"cacheTtl": "Время жизни кэша",
620+
"cacheTtlPlaceholder": "По умолчанию глобальное время жизни кэша (сек)",
615621
"tipsTitle": "Подсказки по резолву",
616622
"tipsDes": "Инструкции по разрешению доменных имен узлов в IP-адреса"
617623
},

src/locales/zh.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,18 @@ export default {
653653
types: ['IPv4', 'IPv6'],
654654
filters: ['不过滤', '移除失败', '只保留 IP', '只保留 IPv4', '只保留 IPv6'],
655655
cache: ['启用', '禁用'],
656-
customDns: '默认自定义 DNS(全平台支持 DoH, Node.js 额外支持 DoT 和 TCP/UDP DNS)',
657-
customDnsPlaceholder: '请输入 DoH 或 [udp://]1.1.1.1[:53] 或 tcp://1.1.1.1[:53] 或 tls://223.5.5.5[:853] (括号内可省略)',
656+
customDns: '自定义 DNS(每行一个; 全平台支持 DoH, Node.js 额外支持 DoT 和 TCP/UDP DNS)',
657+
customDnsPlaceholder: '每行一个 DNS: DoH 或 [udp://]1.1.1.1[:53] 或 tcp://1.1.1.1[:53] 或 tls://223.5.5.5[:853] (括号内可省略)',
658658
tlsSkipCertVerify: 'DoH/DoT 服务器证书',
659659
tlsSkipCertVerifyOptions: ['验证', '不验证'],
660+
dnsConcurrency: '多 DNS 并发数',
661+
dnsConcurrencyPlaceholder: '默认 2',
660662
concurrency: '请求并发数',
661663
concurrencyPlaceholder: '默认 10. 在代理 App 中建议不超过 20',
664+
timeout: 'DNS 超时',
665+
timeoutPlaceholder: '默认使用全局请求超时(毫秒)',
666+
cacheTtl: '缓存时长',
667+
cacheTtlPlaceholder: '默认使用全局缓存时长(秒)',
662668
tipsTitle: '域名解析操作提示',
663669
tipsDes: '将节点域名解析成为 IP 地址,减少一次额外的 DNS 请求',
664670
},

src/views/editor/components/ActionRadio.vue

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,14 @@
2323
<p class="des-label">
2424
{{ $t(`editorPage.subConfig.nodeActions['${type}'].customDns`) }}
2525
</p>
26-
<div
27-
v-if="shouldUseCompactCustomDnsTextarea"
28-
class="input-wrapper compact-textarea-wrapper compact-textarea-wrapper--custom-dns"
29-
>
26+
<div class="input-wrapper compact-textarea-wrapper compact-textarea-wrapper--custom-dns">
3027
<nut-textarea
3128
:placeholder="$t(`editorPage.subConfig.nodeActions['${type}'].customDnsPlaceholder`)"
3229
:rows="2"
3330
:autosize="{ minHeight: 40 }"
3431
v-model="rdoUrl"
3532
/>
3633
</div>
37-
<div
38-
v-else
39-
class="input-wrapper compact-input-wrapper compact-input-wrapper--custom-dns"
40-
>
41-
<nut-input
42-
:placeholder="$t(`editorPage.subConfig.nodeActions['${type}'].customDnsPlaceholder`)"
43-
v-model="rdoUrl"
44-
/>
45-
</div>
4634
</div>
4735
<div
4836
v-if="value === 'Custom'"
@@ -66,12 +54,35 @@
6654
</nut-radio>
6755
</nut-radiogroup>
6856
</div>
57+
<div
58+
v-if="value === 'Custom'"
59+
class="radio-wrapper options-radio inline-input-option"
60+
>
61+
<p class="des-label">{{ $t(`editorPage.subConfig.nodeActions['${type}'].dnsConcurrency`) }}</p>
62+
<div class="input-wrapper compact-input-wrapper compact-input-wrapper--concurrency">
63+
<nut-input
64+
type="number"
65+
:placeholder="$t(`editorPage.subConfig.nodeActions['${type}'].dnsConcurrencyPlaceholder`)"
66+
v-model="rdoDnsConcurrency"
67+
/>
68+
</div>
69+
</div>
6970
<div class="radio-wrapper options-radio edns-input-option">
7071
<p class="des-label">EDNS(Google, Ali, Tencent, 自定义 DNS 会携带此参数, 可能会影响解析结果)</p>
7172
<div class="input-wrapper compact-input-wrapper compact-input-wrapper--edns">
7273
<nut-input placeholder="请输入纯 IP, 默认为 223.6.6.6" v-model="rdoEdns" />
7374
</div>
7475
</div>
76+
<div class="radio-wrapper options-radio inline-input-option">
77+
<p class="des-label">{{ $t(`editorPage.subConfig.nodeActions['${type}'].timeout`) }}</p>
78+
<div class="input-wrapper compact-input-wrapper compact-input-wrapper--concurrency">
79+
<nut-input
80+
type="number"
81+
:placeholder="$t(`editorPage.subConfig.nodeActions['${type}'].timeoutPlaceholder`)"
82+
v-model="rdoTimeout"
83+
/>
84+
</div>
85+
</div>
7586
<div class="radio-wrapper options-radio inline-input-option">
7687
<p class="des-label">{{ $t(`editorPage.subConfig.nodeActions['${type}'].concurrency`) }}</p>
7788
<div class="input-wrapper compact-input-wrapper compact-input-wrapper--concurrency">
@@ -82,7 +93,7 @@
8293
/>
8394
</div>
8495
</div>
85-
<div class="radio-wrapper options-radio">
96+
<div class="radio-wrapper options-radio rdo-type-option">
8697
<p class="des-label" style="cursor: pointer" @click="rdoTypeInfo">解析类型(IPv6 兼容 IP4P <font-awesome-icon icon="fa-solid fa-circle-question"/>)</p>
8798
<nut-radiogroup direction="horizontal" v-model="rdoType">
8899
<nut-radio v-for="(key, index) in rdoTypeOpt" :label="key" :key="index"
@@ -114,6 +125,19 @@
114125
</nut-radio>
115126
</nut-radiogroup>
116127
</div>
128+
<div
129+
v-if="rdoCache === 'enabled'"
130+
class="radio-wrapper options-radio inline-input-option"
131+
>
132+
<p class="des-label">{{ $t(`editorPage.subConfig.nodeActions['${type}'].cacheTtl`) }}</p>
133+
<div class="input-wrapper compact-input-wrapper compact-input-wrapper--concurrency">
134+
<nut-input
135+
type="number"
136+
:placeholder="$t(`editorPage.subConfig.nodeActions['${type}'].cacheTtlPlaceholder`)"
137+
v-model="rdoCacheTtl"
138+
/>
139+
</div>
140+
</div>
117141
</template>
118142
<template v-if="type === 'Flag Operator' && foNewVersion && value === 'add'">
119143
<div class="radio-wrapper options-radio">
@@ -140,20 +164,15 @@
140164
import semverGt from 'semver/functions/gt';
141165
import { useAppNotifyStore } from '@/store/appNotify';
142166
import { storeToRefs } from 'pinia';
143-
import { useWideScreenNarrowMode } from '@/hooks/useWideScreenNarrowMode';
144167
import { useGlobalStore } from '@/store/global';
145-
import { computed, inject, onMounted, ref, watch } from 'vue';
168+
import { inject, onMounted, ref, watch } from 'vue';
146169
import tw from '@/assets/icons/tw.png';
147170
148171
const globalStore = useGlobalStore();
149172
150173
const { showNotify } = useAppNotifyStore();
151174
152175
const { env } = storeToRefs(globalStore);
153-
const { isWideScreen, isWideScreenNarrowModeActive } = useWideScreenNarrowMode();
154-
const shouldUseCompactCustomDnsTextarea = computed(
155-
() => !isWideScreen.value || isWideScreenNarrowModeActive.value
156-
);
157176
158177
const { type, id } = defineProps<{
159178
type: string;
@@ -197,7 +216,10 @@
197216
const rdoTlsSkipCertVerify = ref('disabled');
198217
const rdoUrl = ref('');
199218
const rdoEdns = ref('');
219+
const rdoDnsConcurrency = ref('');
200220
const rdoConcurrency = ref('');
221+
const rdoTimeout = ref('');
222+
const rdoCacheTtl = ref('');
201223
202224
const normalizeRdoConcurrency = () => {
203225
const value = `${rdoConcurrency.value ?? ''}`.trim();
@@ -208,6 +230,33 @@
208230
return `${value ?? ''}`.trim();
209231
};
210232
233+
const normalizeRdoDnsConcurrency = () => {
234+
const value = `${rdoDnsConcurrency.value ?? ''}`.trim();
235+
return value || undefined;
236+
};
237+
238+
const getInitialRdoDnsConcurrency = (value) => {
239+
return `${value ?? ''}`.trim();
240+
};
241+
242+
const normalizeRdoTimeout = () => {
243+
const value = `${rdoTimeout.value ?? ''}`.trim();
244+
return value || undefined;
245+
};
246+
247+
const getInitialRdoTimeout = (value) => {
248+
return `${value ?? ''}`.trim();
249+
};
250+
251+
const normalizeRdoCacheTtl = () => {
252+
const value = `${rdoCacheTtl.value ?? ''}`.trim();
253+
return value || undefined;
254+
};
255+
256+
const getInitialRdoCacheTtl = (value) => {
257+
return `${value ?? ''}`.trim();
258+
};
259+
211260
const showTwTips = () => {
212261
Toast.text('免责声明: 本操作仅将 Emoji 旗帜进行替换以便于显示, 不包含任何政治意味');
213262
};
@@ -256,7 +305,12 @@
256305
item.args?.tlsSkipCertVerify ?? 'disabled';
257306
rdoUrl.value = item.args?.url ?? '';
258307
rdoEdns.value = item.args?.edns;
308+
rdoDnsConcurrency.value = getInitialRdoDnsConcurrency(
309+
item.args?.dnsConcurrency
310+
);
259311
rdoConcurrency.value = getInitialRdoConcurrency(item.args?.concurrency);
312+
rdoTimeout.value = getInitialRdoTimeout(item.args?.timeout);
313+
rdoCacheTtl.value = getInitialRdoCacheTtl(item.args?.cacheTtl);
260314
break;
261315
}
262316
}
@@ -270,7 +324,10 @@
270324
rdoTlsSkipCertVerify,
271325
rdoUrl,
272326
rdoEdns,
327+
rdoDnsConcurrency,
273328
rdoConcurrency,
329+
rdoTimeout,
330+
rdoCacheTtl,
274331
rdoType,
275332
foTw,
276333
], () => {
@@ -300,7 +357,13 @@
300357
tlsSkipCertVerify: rdoTlsSkipCertVerify.value,
301358
url: rdoUrl.value,
302359
edns: rdoEdns.value,
360+
dnsConcurrency: normalizeRdoDnsConcurrency(),
303361
concurrency: normalizeRdoConcurrency(),
362+
timeout: normalizeRdoTimeout(),
363+
cacheTtl:
364+
rdoCache.value === 'enabled'
365+
? normalizeRdoCacheTtl()
366+
: undefined,
304367
};
305368
break;
306369
}
@@ -408,6 +471,12 @@
408471
flex: 0 1 280px;
409472
max-width: 280px;
410473
}
474+
.custom-dns-input-option {
475+
margin-top: 8px;
476+
}
477+
.tls-skip-cert-option {
478+
margin-top: 10px;
479+
}
411480
.custom-dns-input-option,
412481
.tls-skip-cert-option,
413482
.edns-input-option {
@@ -431,4 +500,7 @@
431500
min-width: 0;
432501
}
433502
}
503+
.rdo-type-option {
504+
margin-top: 10px;
505+
}
434506
</style>

0 commit comments

Comments
 (0)