mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-14 02:00:37 +08:00
Chore: improve domain alive validation
This commit is contained in:
parent
238eb7fa6f
commit
72ac579501
2
.github/workflows/check-source-domain.yml
vendored
2
.github/workflows/check-source-domain.yml
vendored
@ -51,7 +51,7 @@ jobs:
|
|||||||
- run: pnpm install
|
- run: pnpm install
|
||||||
- run: pnpm run node Build/validate-domain-alive.ts
|
- run: pnpm run node Build/validate-domain-alive.ts
|
||||||
env:
|
env:
|
||||||
DEBUG: domain-alive:*
|
DEBUG: domain-alive:dead-domain:*
|
||||||
- name: Cache cache.db
|
- name: Cache cache.db
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/cache/save@v4
|
uses: actions/cache/save@v4
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { createDomainAliveChecker } from 'domain-alive';
|
import { createDomainAliveChecker, createRegisterableDomainAliveChecker } from 'domain-alive';
|
||||||
|
|
||||||
const dnsServers = [
|
const dnsServers = [
|
||||||
'8.8.8.8',
|
'8.8.8.8',
|
||||||
@ -42,10 +42,20 @@ const dnsServers = [
|
|||||||
// 'dns.rabbitdns.org'
|
// 'dns.rabbitdns.org'
|
||||||
].map(dns => 'https://' + dns + '/dns-query');
|
].map(dns => 'https://' + dns + '/dns-query');
|
||||||
|
|
||||||
console.log({ dnsServers });
|
const resultCache = new Map();
|
||||||
|
const registerableDomainResultCache = new Map();
|
||||||
|
|
||||||
|
export const isRegisterableDomainAlive = createRegisterableDomainAliveChecker({
|
||||||
|
dns: {
|
||||||
|
dnsServers
|
||||||
|
},
|
||||||
|
registerableDomainResultCache
|
||||||
|
});
|
||||||
|
|
||||||
export const isDomainAlive = createDomainAliveChecker({
|
export const isDomainAlive = createDomainAliveChecker({
|
||||||
dns: {
|
dns: {
|
||||||
dnsServers
|
dnsServers
|
||||||
}
|
},
|
||||||
|
registerableDomainResultCache,
|
||||||
|
resultCache
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { SOURCE_DIR } from './constants/dir';
|
import { SOURCE_DIR } from './constants/dir';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { isDomainAlive } from './lib/is-domain-alive';
|
import { isDomainAlive, isRegisterableDomainAlive } from './lib/is-domain-alive';
|
||||||
import { fdir as Fdir } from 'fdir';
|
import { fdir as Fdir } from 'fdir';
|
||||||
import runAgainstSourceFile from './lib/run-against-source-file';
|
import runAgainstSourceFile from './lib/run-against-source-file';
|
||||||
|
|
||||||
@ -43,17 +43,24 @@ const deadDomains: string[] = [];
|
|||||||
(domain: string, includeAllSubdomain: boolean) => {
|
(domain: string, includeAllSubdomain: boolean) => {
|
||||||
bar.setTotal(bar.getTotal() + 1);
|
bar.setTotal(bar.getTotal() + 1);
|
||||||
|
|
||||||
return queue.add(
|
return queue.add(async () => {
|
||||||
() => isDomainAlive(domain).then(({ alive, registerableDomainAlive, registerableDomain }) => {
|
let registerableDomainAlive, registerableDomain, alive: boolean | undefined;
|
||||||
bar.increment();
|
|
||||||
|
|
||||||
if (!registerableDomainAlive) {
|
if (includeAllSubdomain) {
|
||||||
deadDomains.push('.' + registerableDomain);
|
// we only need to check apex domain, because we don't know if there is any stripped subdomain
|
||||||
} else if (!alive) {
|
({ alive: registerableDomainAlive, registerableDomain } = await isRegisterableDomainAlive(domain));
|
||||||
deadDomains.push(includeAllSubdomain ? '.' + domain : domain);
|
} else {
|
||||||
}
|
({ alive, registerableDomainAlive, registerableDomain } = await isDomainAlive(domain));
|
||||||
})
|
}
|
||||||
);
|
|
||||||
|
bar.increment();
|
||||||
|
|
||||||
|
if (!registerableDomainAlive) {
|
||||||
|
deadDomains.push('.' + registerableDomain);
|
||||||
|
} else if (!includeAllSubdomain && alive != null && !alive) {
|
||||||
|
deadDomains.push(domain);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
).then(() => console.log('[crawl]', filepath))
|
).then(() => console.log('[crawl]', filepath))
|
||||||
));
|
));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user