Skip to content

Commit

Permalink
fix: DoH 结果过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Aug 29, 2024
1 parent 9abeb4c commit f0acf4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.364",
"version": "2.14.365",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions backend/src/core/proxy-utils/processors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,23 @@ const DOMAIN_RESOLVERS = {
const id = hex_md5(`CUSTOM:${url}:${domain}:${type}`);
const cached = resourceCache.get(id);
if (!noCache && cached) return cached;
const answerType = type === 'IPv6' ? 'AAAA' : 'A';
const res = await doh({
url,
domain,
type: type === 'IPv6' ? 'AAAA' : 'A',
type: answerType,
timeout,
edns,
});

const { answers } = res;
if (!Array.isArray(answers) || answers.length === 0) {
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) {
throw new Error('No answers');
}
Expand Down

0 comments on commit f0acf4a

Please sign in to comment.