ソースを参照

Fix: update domains alive check

SukkaW 1 年間 前
コミット
27a68c0e34
1 ファイル変更8 行追加1 行削除
  1. 8 1
      Build/validate-domain-alive.ts

+ 8 - 1
Build/validate-domain-alive.ts

@@ -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',
@@ -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)) {
@@ -121,7 +128,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 && (whois.text as string[]).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];