Chore: minor changes
Some checks failed
Build / Build (push) Has been cancelled
Build / Diff output (push) Has been cancelled
Build / Deploy to Cloudflare Pages (push) Has been cancelled
Build / Deploy to GitHub and GitLab (push) Has been cancelled

This commit is contained in:
SukkaW 2025-02-15 22:49:41 +08:00
parent f2bdf54737
commit 2ebe91189c
4 changed files with 23 additions and 10 deletions

View File

@ -143,7 +143,7 @@ export async function isDomainAlive(domain: string, isSuffix: boolean): Promise<
const aaaaDns: string[] = [];
// test 2 times before make sure record is empty
const servers = pickRandom(dohServers, 3);
const servers = pickRandom(dohServers, 2);
for (let i = 0; i < 2; i++) {
// eslint-disable-next-line no-await-in-loop -- sequential
const aRecords = (await $resolve($domain, 'A', servers[i]));
@ -180,23 +180,36 @@ export async function isDomainAlive(domain: string, isSuffix: boolean): Promise<
return onDomainDead($domain);
}
const apexDomainNsResolvePromiseMap = new Map<string, Promise<DnsResponse>>();
const apexDomainNsResolvePromiseMap = new Map<string, Promise<boolean>>();
async function getNS(domain: string) {
const servers = pickRandom(dohServers, 2);
for (let i = 0, len = servers.length; i < len; i++) {
const server = servers[i];
// eslint-disable-next-line no-await-in-loop -- one by one
const resp = await $resolve(domain, 'NS', server);
if (resp.answers.length > 0) {
return true;
}
}
return false;
}
async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]> {
if (domainAliveMap.has(apexDomain)) {
return [apexDomain, domainAliveMap.get(apexDomain)!];
}
let resp: DnsResponse;
let hasNS: boolean;
if (apexDomainNsResolvePromiseMap.has(apexDomain)) {
resp = await apexDomainNsResolvePromiseMap.get(apexDomain)!;
hasNS = await apexDomainNsResolvePromiseMap.get(apexDomain)!;
} else {
const promise = $resolve(apexDomain, 'NS', pickOne(dohServers));
const promise = getNS(apexDomain);
apexDomainNsResolvePromiseMap.set(apexDomain, promise);
resp = await promise;
hasNS = await promise;
}
if (resp.answers.length > 0) {
if (hasNS) {
return onDomainAlive(apexDomain);
}

4
Build/mod.d.ts vendored
View File

@ -8,9 +8,7 @@ declare module 'dns2' {
/** @example dns.google.com */
dns: string,
/** @description whether to use HTTP or HTTPS */
http: boolean,
get?: (url: string) => any
http: boolean
}
export type PacketQuestion = keyof typeof Packet.TYPE;

View File

@ -439,6 +439,7 @@ xy-log.tagtic.cn
.igexin.com
.gepush.com
.getui.net
.getui.com
.mobileservice.cn
.img.adnyg.com
.img.adnyg.com.w.kunlungr.com

View File

@ -385,6 +385,7 @@ DOMAIN-SUFFIX,gov.cn
DOMAIN-SUFFIX,edu.cn
DOMAIN-SUFFIX,org.cn
DOMAIN-SUFFIX,com.cn
DOMAIN-SUFFIX,net.cn
DOMAIN,cn.download.nvidia.com
DOMAIN-SUFFIX,jetbrains.com.cn