Skip to content

Commit

Permalink
Fix: update domains alive check
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Nov 5, 2024
1 parent d8336a1 commit 9d42a06
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Build/validate-domain-alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { newQueue } from '@henrygd/queue';
import asyncRetry from 'async-retry';
import * as whoiser from 'whoiser';
import picocolors from 'picocolors';
import createKeywordFilter from './lib/aho-corasick';

const dohServers: Array<[string, DNS2.DnsResolver]> = ([
'8.8.8.8',
Expand Down Expand Up @@ -97,6 +98,12 @@ const resolve: DNS2.DnsResolver<DnsResponse> = async (...args) => {
console.log('done');
})();

const whoisNotFoundKeywordTest = createKeywordFilter([
'no match for',
'does not exist',
'not found'
]);

const domainAliveMap = new Map<string, boolean>();
async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]> {
if (domainAliveMap.has(apexDomain)) {
Expand All @@ -120,7 +127,7 @@ async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]>

if (Object.keys(whois).length > 0) {
// TODO: this is a workaround for https://github.com/LayeredStudio/whoiser/issues/117
if ('text' in whois && Array.isArray(whois.text) && whois.text.some(value => value.includes('No match for'))) {
if ('text' in whois && Array.isArray(whois.text) && whois.text.some(value => whoisNotFoundKeywordTest(value.toLowerCase()))) {
console.log(picocolors.red('[domain dead]'), 'whois no match', { domain: apexDomain });
domainAliveMap.set(apexDomain, false);
return [apexDomain, false];
Expand Down

0 comments on commit 9d42a06

Please sign in to comment.