mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Refactor: enable more DNS to validate alive domains
This commit is contained in:
parent
76f5a722cd
commit
c16931e175
@ -35,7 +35,7 @@ const dohServers: Array<[string, DNS2.DnsResolver]> = ([
|
|||||||
// 'zero.dns0.eu',
|
// 'zero.dns0.eu',
|
||||||
'dns.nextdns.io',
|
'dns.nextdns.io',
|
||||||
'anycast.dns.nextdns.io',
|
'anycast.dns.nextdns.io',
|
||||||
// 'wikimedia-dns.org',
|
'wikimedia-dns.org',
|
||||||
// 'ordns.he.net',
|
// 'ordns.he.net',
|
||||||
// 'dns.mullvad.net',
|
// 'dns.mullvad.net',
|
||||||
'basic.rethinkdns.com'
|
'basic.rethinkdns.com'
|
||||||
@ -181,24 +181,41 @@ export async function isDomainAlive(domain: string, isSuffix: boolean): Promise<
|
|||||||
return [domain, false] as const;
|
return [domain, false] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSuffix) {
|
|
||||||
const $domain = domain[0] === '.' ? domain.slice(1) : domain;
|
const $domain = domain[0] === '.' ? domain.slice(1) : domain;
|
||||||
|
|
||||||
const aRecords = (await resolve($domain, 'A'));
|
if (!isSuffix) {
|
||||||
if (aRecords.answers.length === 0) {
|
const aDns: string[] = [];
|
||||||
const aaaaRecords = (await resolve($domain, 'AAAA'));
|
const aaaaDns: string[] = [];
|
||||||
if (aaaaRecords.answers.length === 0) {
|
|
||||||
console.log(picocolors.red('[domain dead]'), 'no A/AAAA records', { domain, a: aRecords.dns, aaaa: aaaaRecords.dns });
|
|
||||||
domainAliveMap.set($domain, false);
|
|
||||||
return [domain, false] as const;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// test 2 times before make sure record is empty
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
|
const aRecords = (await resolve($domain, 'A'));
|
||||||
|
if (aRecords.answers.length !== 0) {
|
||||||
domainAliveMap.set(domain, true);
|
domainAliveMap.set(domain, true);
|
||||||
return [domain, true] as const;
|
return [domain, true] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aDns.push(aRecords.dns);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
|
const aaaaRecords = (await resolve($domain, 'AAAA'));
|
||||||
|
if (aaaaRecords.answers.length !== 0) {
|
||||||
|
domainAliveMap.set(domain, true);
|
||||||
|
return [domain, true] as const;
|
||||||
|
}
|
||||||
|
|
||||||
|
aaaaDns.push(aaaaRecords.dns);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(picocolors.red('[domain dead]'), 'no A/AAAA records', { domain, a: aDns, aaaa: aaaaDns });
|
||||||
|
}
|
||||||
|
|
||||||
|
domainAliveMap.set($domain, false);
|
||||||
|
return [domain, false] as const;
|
||||||
|
}
|
||||||
|
|
||||||
export async function runAgainstRuleset(filepath: string) {
|
export async function runAgainstRuleset(filepath: string) {
|
||||||
const extname = path.extname(filepath);
|
const extname = path.extname(filepath);
|
||||||
if (extname !== '.conf') {
|
if (extname !== '.conf') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user