Skip to content

Commit

Permalink
Chore: improve domai alive check [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jan 6, 2025
1 parent 20aae1c commit 3faf3ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Build/lib/is-domain-alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ const whoisNotFoundKeywordTest = createKeywordFilter([
'no matching record',
'no information available about domain name',
'not been registered',
'no match!!'
'no match!!',
'status: available'
]);

// whois server can redirect, so whoiser might/will get info from multiple whois servers
Expand Down
25 changes: 20 additions & 5 deletions Build/validate-domain-alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import { fdir as Fdir } from 'fdir';

const queue = newQueue(32);

const deadDomains: string[] = [];
function onDomain(args: [string, boolean]) {
if (!args[1]) {
deadDomains.push(args[0]);
}
}

(async () => {
const domainSets = await new Fdir()
.withFullPaths()
Expand All @@ -24,7 +31,9 @@ const queue = newQueue(32);
...domainRules.map(runAgainstRuleset)
]);

console.log('done');
console.log();
console.log();
console.log(JSON.stringify(deadDomains));
})();

export async function runAgainstRuleset(filepath: string) {
Expand All @@ -34,7 +43,7 @@ export async function runAgainstRuleset(filepath: string) {
return;
}

const promises: Array<Promise<[string, boolean]>> = [];
const promises: Array<Promise<void>> = [];

for await (const l of readFileByLine(filepath)) {
const line = processLine(l);
Expand All @@ -43,7 +52,10 @@ export async function runAgainstRuleset(filepath: string) {
switch (type) {
case 'DOMAIN-SUFFIX':
case 'DOMAIN': {
promises.push(queue.add(() => keyedAsyncMutexWithQueue(domain, () => isDomainAlive(domain, type === 'DOMAIN-SUFFIX'))));
promises.push(
queue.add(() => keyedAsyncMutexWithQueue(domain, () => isDomainAlive(domain, type === 'DOMAIN-SUFFIX')))
.then(onDomain)
);
break;
}
// no default
Expand All @@ -61,12 +73,15 @@ export async function runAgainstDomainset(filepath: string) {
return;
}

const promises: Array<Promise<[string, boolean]>> = [];
const promises: Array<Promise<void>> = [];

for await (const l of readFileByLine(filepath)) {
const line = processLine(l);
if (!line) continue;
promises.push(queue.add(() => keyedAsyncMutexWithQueue(line, () => isDomainAlive(line, line[0] === '.'))));
promises.push(
queue.add(() => keyedAsyncMutexWithQueue(line, () => isDomainAlive(line, line[0] === '.')))
.then(onDomain)
);
}

await Promise.all(promises);
Expand Down

0 comments on commit 3faf3ca

Please sign in to comment.