From 3690a7e67f740d10c991bf76ce43c5b5d24aabb1 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 5 Jan 2025 20:29:21 +0800 Subject: [PATCH] Feat: detect SOA as domain not alive --- Build/lib/is-domain-alive.test.ts | 8 ++++++++ Build/lib/is-domain-alive.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Build/lib/is-domain-alive.test.ts b/Build/lib/is-domain-alive.test.ts index afcee1316..d49545075 100644 --- a/Build/lib/is-domain-alive.test.ts +++ b/Build/lib/is-domain-alive.test.ts @@ -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); + }); }); diff --git a/Build/lib/is-domain-alive.ts b/Build/lib/is-domain-alive.ts index 4175f7deb..b5f56ff02 100644 --- a/Build/lib/is-domain-alive.ts +++ b/Build/lib/is-domain-alive.ts @@ -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 { @@ -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); }