mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-14 18:20:35 +08:00
Ignore DNS error when checking alive domains
This commit is contained in:
parent
a4ae24ecb6
commit
d3179cc2cd
@ -111,7 +111,9 @@ export async function isDomainAlive(
|
|||||||
|
|
||||||
// test 2 times before make sure record is empty
|
// test 2 times before make sure record is empty
|
||||||
const servers = pickRandom(dohServers, 2);
|
const servers = pickRandom(dohServers, 2);
|
||||||
|
// TODO: increase limit when there is an error
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop -- sequential
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
const aRecords = (await $resolve(domain, 'A', servers[i]));
|
const aRecords = (await $resolve(domain, 'A', servers[i]));
|
||||||
if (aRecords.answers.length > 0) {
|
if (aRecords.answers.length > 0) {
|
||||||
@ -120,20 +122,24 @@ export async function isDomainAlive(
|
|||||||
}
|
}
|
||||||
|
|
||||||
aDns.push(aRecords.dns);
|
aDns.push(aRecords.dns);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop -- sequential
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
const aaaaRecords = (await $resolve(domain, 'AAAA', servers[i]));
|
const aaaaRecords = await $resolve(domain, 'AAAA', servers[i]);
|
||||||
if (aaaaRecords.answers.length > 0) {
|
if (aaaaRecords.answers.length > 0) {
|
||||||
domainAliveMap.set(domain, true);
|
domainAliveMap.set(domain, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
aaaaDns.push(aaaaRecords.dns);
|
aaaaDns.push(aaaaRecords.dns);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only then, let's test twice with domesticDohServers
|
// only then, let's test twice with domesticDohServers
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop -- sequential
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
const aRecords = (await $resolve(domain, 'A', pickOne(domesticDohServers)));
|
const aRecords = (await $resolve(domain, 'A', pickOne(domesticDohServers)));
|
||||||
if (aRecords.answers.length > 0) {
|
if (aRecords.answers.length > 0) {
|
||||||
@ -141,8 +147,10 @@ export async function isDomainAlive(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
aDns.push(aRecords.dns);
|
aDns.push(aRecords.dns);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop -- sequential
|
// eslint-disable-next-line no-await-in-loop -- sequential
|
||||||
const aaaaRecords = (await $resolve(domain, 'AAAA', pickOne(domesticDohServers)));
|
const aaaaRecords = (await $resolve(domain, 'AAAA', pickOne(domesticDohServers)));
|
||||||
if (aaaaRecords.answers.length > 0) {
|
if (aaaaRecords.answers.length > 0) {
|
||||||
@ -150,6 +158,7 @@ export async function isDomainAlive(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
aaaaDns.push(aaaaRecords.dns);
|
aaaaDns.push(aaaaRecords.dns);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(picocolors.red('[domain dead]'), 'no A/AAAA records', { domain, a: aDns, aaaa: aaaaDns });
|
console.log(picocolors.red('[domain dead]'), 'no A/AAAA records', { domain, a: aDns, aaaa: aaaaDns });
|
||||||
@ -170,12 +179,14 @@ function isApexDomainAlive(apexDomain: string) {
|
|||||||
const servers = pickRandom(dohServers, 2);
|
const servers = pickRandom(dohServers, 2);
|
||||||
for (let i = 0, len = servers.length; i < len; i++) {
|
for (let i = 0, len = servers.length; i < len; i++) {
|
||||||
const server = servers[i];
|
const server = servers[i];
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop -- one by one
|
// eslint-disable-next-line no-await-in-loop -- one by one
|
||||||
const resp = await $resolve(apexDomain, 'NS', server);
|
const resp = await $resolve(apexDomain, 'NS', server);
|
||||||
if (resp.answers.length > 0) {
|
if (resp.answers.length > 0) {
|
||||||
domainAliveMap.set(apexDomain, true);
|
domainAliveMap.set(apexDomain, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let whois;
|
let whois;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user