Wire up Dead Domain CI Check for Node.js 26 [skip ci]

This commit is contained in:
SukkaW
2026-08-09 18:32:00 +08:00
parent 14f5811242
commit f141253cfe
5 changed files with 41 additions and 13 deletions

View File

@@ -174,6 +174,8 @@ const agent = new Agent({
})
);
export { agent as fetchAgent };
export interface FetchResponseProgress {
onResponseStart?: (contentEncoding: string | null) => void,
onEncodedBodyChunk?: (bytes: number) => void,

View File

@@ -0,0 +1,20 @@
import { describe, it } from 'mocha';
import { expect } from 'earl';
import { DOMAIN_ALIVE_REASON_MESSAGES, DOMAIN_ALIVE_REASONS } from 'domain-alive';
import { createDomainAliveMethods } from './is-domain-alive';
describe('domain-alive integration', () => {
it('constructs the checkers with the custom DoH agent', async () => {
const { isDomainAlive, isRegisterableDomainAlive } = createDomainAliveMethods({});
const [domainResult, registerableDomainResult] = await Promise.all([
isDomainAlive(''),
isRegisterableDomainAlive('')
]);
expect(domainResult.reason).toEqual(DOMAIN_ALIVE_REASONS.INVALID_DOMAIN);
expect(registerableDomainResult.reason).toEqual(DOMAIN_ALIVE_REASONS.INVALID_DOMAIN);
expect(DOMAIN_ALIVE_REASON_MESSAGES[domainResult.reason]).toEqual(
'No registerable domain could be extracted.'
);
});
});

View File

@@ -1,5 +1,5 @@
import { createDomainAliveChecker, createRegisterableDomainAliveChecker } from 'domain-alive';
import { $$fetch, fetchForDoH } from './fetch-retry';
import { $$fetch, fetchAgent, fetchForDoH } from './fetch-retry';
const dnsServers = [
'https://8.8.8.8/dns-query', 'https://8.8.4.4/dns-query',
@@ -55,14 +55,13 @@ const dnsServers = [
const resultCache = new Map();
const registerableDomainResultCache = new Map();
export async function getMethods() {
const customWhoisServersMapping = await (await ($$fetch('https://cdn.jsdelivr.net/npm/whois-servers-list@latest/list.json'))).json() as any;
export function createDomainAliveMethods(customWhoisServersMapping: Record<string, string>) {
const isRegisterableDomainAlive = createRegisterableDomainAliveChecker({
dns: {
dnsServers,
maxAttempts: 6,
customFetchForDoH: fetchForDoH as typeof fetch
customFetchForDoH: fetchForDoH as typeof fetch,
customAgentForDoH: fetchAgent
},
registerableDomainResultCache,
whois: {
@@ -74,7 +73,8 @@ export async function getMethods() {
dns: {
dnsServers,
maxAttempts: 6,
customFetchForDoH: fetchForDoH as typeof fetch
customFetchForDoH: fetchForDoH as typeof fetch,
customAgentForDoH: fetchAgent
},
registerableDomainResultCache,
resultCache,
@@ -84,4 +84,10 @@ export async function getMethods() {
});
return { isRegisterableDomainAlive, isDomainAlive };
}
export async function getMethods() {
const customWhoisServersMapping = await (await ($$fetch('https://cdn.jsdelivr.net/npm/whois-servers-list@latest/list.json'))).json() as Record<string, string>;
return createDomainAliveMethods(customWhoisServersMapping);
};

View File

@@ -15,7 +15,7 @@
"build-profile": "pnpm run dexnode -r @swc-node/register ./Build/index.ts",
"bench-download": "pnpm run node ./Build/benchmark-download-client.ts",
"lint": "eslint --format=sukka .",
"test": "SWC_NODE_IGNORE_DYNAMIC=true SWC_NODE_PROJECT=tsconfig.test.json mocha --require @swc-node/register --watch-extensions ts,tsx"
"test": "SWC_NODE_IGNORE_DYNAMIC=true SWC_NODE_PROJECT=tsconfig.test.json mocha --require @swc-node/register --watch-extensions ts,tsx \"Build/**/*.test.ts\""
},
"author": "",
"license": "ISC",
@@ -26,7 +26,7 @@
"ci-info": "^4.4.0",
"cli-progress": "^3.12.0",
"csv-parse": "^7.0.2",
"domain-alive": "^0.1.24",
"domain-alive": "^0.1.25",
"fast-cidr-tools": "^0.3.4",
"fast-escape-regexp": "^1.0.1",
"fast-uri": "^4.1.2",

10
pnpm-lock.yaml generated
View File

@@ -33,8 +33,8 @@ importers:
specifier: ^7.0.2
version: 7.0.2
domain-alive:
specifier: ^0.1.24
version: 0.1.24(supports-color@8.1.1)
specifier: ^0.1.25
version: 0.1.25(supports-color@8.1.1)
fast-cidr-tools:
specifier: ^0.3.4
version: 0.3.4
@@ -1161,8 +1161,8 @@ packages:
dom-serializer@1.4.1:
resolution: {integrity: sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==}
domain-alive@0.1.24:
resolution: {integrity: sha512-/KogFcl5dnHaxKMQyWARruBtXthGaiKoIH8G61/0knCEMr59ymrYabsADbJDYjN7O0+K+0qBqdh9ewjOhLkeEw==}
domain-alive@0.1.25:
resolution: {integrity: sha512-S3NXngSmSg2DBQHdrfzSGWe96yqIm19LJORvYqoVDXkLyG0tDoQTwbGorgbCkFkCakBdoq9KTAsjTkFNi2fMbQ==}
domelementtype@2.3.0:
resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==}
@@ -2957,7 +2957,7 @@ snapshots:
domhandler: 4.3.1
entities: 2.2.0
domain-alive@0.1.24(supports-color@8.1.1):
domain-alive@0.1.25(supports-color@8.1.1):
dependencies:
debug: 4.4.3(supports-color@8.1.1)
foxts: 5.9.1