mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-12-03 01:59:29 +03:00
Fixes Google DoH lookups always falling back to Cloudflare (#49)
This commit is contained in:
2 files changed
+6
-3
No files matched your search
@@ -46,7 +46,7 @@ interface IndividualRecord {
|
||||
// DNS over HTTPS endpoints
|
||||
const DOH_ENDPOINTS = {
|
||||
cloudflare: 'https://cloudflare-dns.com/dns-query',
|
||||
google: 'https://dns.google/dns-query',
|
||||
google: 'https://dns.google/resolve',
|
||||
quad9: 'https://dns.quad9.net/dns-query',
|
||||
opendns: 'https://doh.opendns.com/dns-query',
|
||||
};
|
||||
|
||||
@@ -97,9 +97,12 @@
|
||||
}) as DnsResult[];
|
||||
if (successfulResults.length === 0) return false;
|
||||
|
||||
const firstAnswer = successfulResults[0].result!.Answer!.map((a) => a.data).sort();
|
||||
// Cloudflare quotes TXT strings and splits long ones, Google returns them joined
|
||||
const normalize = (data: string) =>
|
||||
lastQuery?.type === 'TXT' ? data.replace(/^"(.*)"$/, '$1').replace(/" "/g, '') : data;
|
||||
const firstAnswer = successfulResults[0].result!.Answer!.map((a) => normalize(a.data)).sort();
|
||||
return successfulResults.every((r) => {
|
||||
const answers = r.result!.Answer!.map((a) => a.data).sort();
|
||||
const answers = r.result!.Answer!.map((a) => normalize(a.data)).sort();
|
||||
return JSON.stringify(answers) === JSON.stringify(firstAnswer);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user