mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Chore: minor changes
This commit is contained in:
parent
f2bdf54737
commit
2ebe91189c
@ -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
4
Build/mod.d.ts
vendored
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user