mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-09-17 01:53:12 +08:00
fix: DoH 结果过滤
This commit is contained in:
parent
9abeb4ce7b
commit
f0acf4a2a7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.364",
|
"version": "2.14.365",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -392,18 +392,23 @@ const DOMAIN_RESOLVERS = {
|
|||||||
const id = hex_md5(`CUSTOM:${url}:${domain}:${type}`);
|
const id = hex_md5(`CUSTOM:${url}:${domain}:${type}`);
|
||||||
const cached = resourceCache.get(id);
|
const cached = resourceCache.get(id);
|
||||||
if (!noCache && cached) return cached;
|
if (!noCache && cached) return cached;
|
||||||
|
const answerType = type === 'IPv6' ? 'AAAA' : 'A';
|
||||||
const res = await doh({
|
const res = await doh({
|
||||||
url,
|
url,
|
||||||
domain,
|
domain,
|
||||||
type: type === 'IPv6' ? 'AAAA' : 'A',
|
type: answerType,
|
||||||
timeout,
|
timeout,
|
||||||
edns,
|
edns,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { answers } = res;
|
const { answers } = res;
|
||||||
if (!Array.isArray(answers) || answers.length === 0) {
|
if (!Array.isArray(answers) || answers.length === 0) {
|
||||||
throw new Error('No answers');
|
throw new Error('No answers');
|
||||||
}
|
}
|
||||||
const result = answers.map((i) => i?.data).filter((i) => i);
|
const result = answers
|
||||||
|
.filter((i) => i?.type === answerType)
|
||||||
|
.map((i) => i?.data)
|
||||||
|
.filter((i) => i);
|
||||||
if (result.length === 0) {
|
if (result.length === 0) {
|
||||||
throw new Error('No answers');
|
throw new Error('No answers');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user