mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10: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[] = [];
|
const aaaaDns: string[] = [];
|
||||||
|
|
||||||
// test 2 times before make sure record is empty
|
// 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++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
// 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]));
|
||||||
@ -180,23 +180,36 @@ export async function isDomainAlive(domain: string, isSuffix: boolean): Promise<
|
|||||||
return onDomainDead($domain);
|
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]> {
|
async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]> {
|
||||||
if (domainAliveMap.has(apexDomain)) {
|
if (domainAliveMap.has(apexDomain)) {
|
||||||
return [apexDomain, domainAliveMap.get(apexDomain)!];
|
return [apexDomain, domainAliveMap.get(apexDomain)!];
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp: DnsResponse;
|
let hasNS: boolean;
|
||||||
if (apexDomainNsResolvePromiseMap.has(apexDomain)) {
|
if (apexDomainNsResolvePromiseMap.has(apexDomain)) {
|
||||||
resp = await apexDomainNsResolvePromiseMap.get(apexDomain)!;
|
hasNS = await apexDomainNsResolvePromiseMap.get(apexDomain)!;
|
||||||
} else {
|
} else {
|
||||||
const promise = $resolve(apexDomain, 'NS', pickOne(dohServers));
|
const promise = getNS(apexDomain);
|
||||||
apexDomainNsResolvePromiseMap.set(apexDomain, promise);
|
apexDomainNsResolvePromiseMap.set(apexDomain, promise);
|
||||||
resp = await promise;
|
hasNS = await promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.answers.length > 0) {
|
if (hasNS) {
|
||||||
return onDomainAlive(apexDomain);
|
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 */
|
/** @example dns.google.com */
|
||||||
dns: string,
|
dns: string,
|
||||||
/** @description whether to use HTTP or HTTPS */
|
/** @description whether to use HTTP or HTTPS */
|
||||||
http: boolean,
|
http: boolean
|
||||||
|
|
||||||
get?: (url: string) => any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PacketQuestion = keyof typeof Packet.TYPE;
|
export type PacketQuestion = keyof typeof Packet.TYPE;
|
||||||
|
|||||||
@ -439,6 +439,7 @@ xy-log.tagtic.cn
|
|||||||
.igexin.com
|
.igexin.com
|
||||||
.gepush.com
|
.gepush.com
|
||||||
.getui.net
|
.getui.net
|
||||||
|
.getui.com
|
||||||
.mobileservice.cn
|
.mobileservice.cn
|
||||||
.img.adnyg.com
|
.img.adnyg.com
|
||||||
.img.adnyg.com.w.kunlungr.com
|
.img.adnyg.com.w.kunlungr.com
|
||||||
|
|||||||
@ -385,6 +385,7 @@ DOMAIN-SUFFIX,gov.cn
|
|||||||
DOMAIN-SUFFIX,edu.cn
|
DOMAIN-SUFFIX,edu.cn
|
||||||
DOMAIN-SUFFIX,org.cn
|
DOMAIN-SUFFIX,org.cn
|
||||||
DOMAIN-SUFFIX,com.cn
|
DOMAIN-SUFFIX,com.cn
|
||||||
|
DOMAIN-SUFFIX,net.cn
|
||||||
|
|
||||||
DOMAIN,cn.download.nvidia.com
|
DOMAIN,cn.download.nvidia.com
|
||||||
DOMAIN-SUFFIX,jetbrains.com.cn
|
DOMAIN-SUFFIX,jetbrains.com.cn
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user