Skip to content

Commit

Permalink
Feat: detect SOA as domain not alive
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jan 5, 2025
1 parent e66ccf1 commit 3690a7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Build/lib/is-domain-alive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@ describe('isDomainAlive', function () {
it('discount-deal.org', async () => {
expect((await isDomainAlive('discount-deal.org', false))[1]).toEqual(false);
});

it('ithome.com.tw', async () => {
expect((await isDomainAlive('ithome.com.tw', false))[1]).toEqual(true);
});

it('flipkart.com', async () => {
expect((await isDomainAlive('flipkart.com', false))[1]).toEqual(true);
});
});
11 changes: 10 additions & 1 deletion Build/lib/is-domain-alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]>
return onDomainAlive(apexDomain);
}

if ('authorities' in resp && Array.isArray(resp.authorities) && resp.authorities.length > 0) {
for (const authority of resp.authorities) {
if (authority.type === 6) {
console.log(picocolors.red('[domain dead]'), 'NS returns SOA', { domain: apexDomain });
return onDomainDead(apexDomain);
}
}
}

let whois;

try {
Expand All @@ -213,7 +222,7 @@ async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]>
// console.log(JSON.stringify(whois, null, 2));

if (whoisExists(whois)) {
console.log(picocolors.gray('[domain alive]'), 'whois found', { domain: apexDomain });
console.log(picocolors.green('[domain alive]'), 'whois found', { domain: apexDomain }, whois);
return onDomainAlive(apexDomain);
}

Expand Down

0 comments on commit 3690a7e

Please sign in to comment.