mirror of
https://github.com/jakejarvis/rdapper.git
synced 2025-10-18 20:14:27 -04:00
Refactor WHOIS handling: move WHOIS_TLD_EXCEPTIONS to servers.ts, update imports in discovery and index files, and add DEFAULT_TIMEOUT_MS constant to bootstrap and client modules for consistency.
This commit is contained in:
@@ -4,13 +4,13 @@ import { getRdapBaseUrlsForTld } from "./rdap/bootstrap.js";
|
||||
import { fetchRdapDomain } from "./rdap/client.js";
|
||||
import { normalizeRdap } from "./rdap/normalize.js";
|
||||
import type { DomainRecord, LookupOptions, LookupResult } from "./types.js";
|
||||
import { WHOIS_TLD_EXCEPTIONS } from "./whois/catalog.js";
|
||||
import { whoisQuery } from "./whois/client.js";
|
||||
import {
|
||||
extractWhoisReferral,
|
||||
ianaWhoisServerForTld,
|
||||
} from "./whois/discovery.js";
|
||||
import { normalizeWhois } from "./whois/normalize.js";
|
||||
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers.js";
|
||||
|
||||
/**
|
||||
* High-level lookup that prefers RDAP and falls back to WHOIS.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import { withTimeout } from "../lib/async.js";
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import type { LookupOptions } from "../types.js";
|
||||
|
||||
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import { withTimeout } from "../lib/async.js";
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import type { LookupOptions } from "../types.js";
|
||||
|
||||
// Use global fetch (Node 18+). For large JSON we keep it simple.
|
||||
|
@@ -1,60 +0,0 @@
|
||||
// Centralized WHOIS data catalog.
|
||||
// - tldExceptions: curated non-standard authoritative WHOIS servers by TLD
|
||||
// - centralnicZones: known CentralNic-operated second-level public suffix zones
|
||||
|
||||
export const WHOIS_CATALOG = {
|
||||
tldExceptions: {
|
||||
// gTLDs
|
||||
com: "whois.verisign-grs.com",
|
||||
net: "whois.verisign-grs.com",
|
||||
org: "whois.pir.org",
|
||||
info: "whois.afilias.net",
|
||||
biz: "whois.nic.biz",
|
||||
edu: "whois.educause.edu",
|
||||
gov: "whois.dotgov.gov",
|
||||
|
||||
// ccTLDs and others
|
||||
de: "whois.denic.de",
|
||||
jp: "whois.jprs.jp",
|
||||
fr: "whois.nic.fr",
|
||||
it: "whois.nic.it",
|
||||
pl: "whois.dns.pl",
|
||||
nl: "whois.domain-registry.nl",
|
||||
be: "whois.dns.be",
|
||||
se: "whois.iis.se",
|
||||
no: "whois.norid.no",
|
||||
fi: "whois.fi",
|
||||
cz: "whois.nic.cz",
|
||||
es: "whois.nic.es",
|
||||
br: "whois.registro.br",
|
||||
ca: "whois.cira.ca",
|
||||
dk: "whois.dk-hostmaster.dk",
|
||||
hk: "whois.hkirc.hk",
|
||||
sg: "whois.sgnic.sg",
|
||||
in: "whois.registry.in",
|
||||
nz: "whois.srs.net.nz",
|
||||
ch: "whois.nic.ch",
|
||||
li: "whois.nic.li",
|
||||
io: "whois.nic.io",
|
||||
ai: "whois.nic.ai",
|
||||
ru: "whois.tcinet.ru",
|
||||
su: "whois.tcinet.ru",
|
||||
"xn--p1ai": "whois.tcinet.ru", // .рф
|
||||
|
||||
// CentralNic-operated second-level zones (treat as exceptions here for simplicity)
|
||||
"uk.com": "whois.centralnic.com",
|
||||
"uk.net": "whois.centralnic.com",
|
||||
"gb.com": "whois.centralnic.com",
|
||||
"gb.net": "whois.centralnic.com",
|
||||
"eu.com": "whois.centralnic.com",
|
||||
"us.com": "whois.centralnic.com",
|
||||
"se.com": "whois.centralnic.com",
|
||||
"de.com": "whois.centralnic.com",
|
||||
"br.com": "whois.centralnic.com",
|
||||
"ru.com": "whois.centralnic.com",
|
||||
"cn.com": "whois.centralnic.com",
|
||||
"sa.com": "whois.centralnic.com",
|
||||
} as Record<string, string>,
|
||||
} as const;
|
||||
|
||||
export const WHOIS_TLD_EXCEPTIONS = WHOIS_CATALOG.tldExceptions;
|
@@ -1,6 +1,6 @@
|
||||
import { createConnection } from "node:net";
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import { withTimeout } from "../lib/async.js";
|
||||
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
|
||||
import type { LookupOptions } from "../types.js";
|
||||
|
||||
export interface WhoisQueryResult {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import type { LookupOptions } from "../types.js";
|
||||
import { WHOIS_TLD_EXCEPTIONS } from "./catalog.js";
|
||||
import { whoisQuery } from "./client.js";
|
||||
import { WHOIS_TLD_EXCEPTIONS } from "./servers.js";
|
||||
|
||||
/**
|
||||
* Best-effort discovery of the authoritative WHOIS server for a TLD via IANA root DB.
|
||||
|
53
src/whois/servers.ts
Normal file
53
src/whois/servers.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// Curated non-standard authoritative WHOIS servers by TLD
|
||||
export const WHOIS_TLD_EXCEPTIONS = {
|
||||
// gTLDs
|
||||
com: "whois.verisign-grs.com",
|
||||
net: "whois.verisign-grs.com",
|
||||
org: "whois.pir.org",
|
||||
info: "whois.afilias.net",
|
||||
biz: "whois.nic.biz",
|
||||
edu: "whois.educause.edu",
|
||||
gov: "whois.dotgov.gov",
|
||||
|
||||
// ccTLDs and others
|
||||
de: "whois.denic.de",
|
||||
jp: "whois.jprs.jp",
|
||||
fr: "whois.nic.fr",
|
||||
it: "whois.nic.it",
|
||||
pl: "whois.dns.pl",
|
||||
nl: "whois.domain-registry.nl",
|
||||
be: "whois.dns.be",
|
||||
se: "whois.iis.se",
|
||||
no: "whois.norid.no",
|
||||
fi: "whois.fi",
|
||||
cz: "whois.nic.cz",
|
||||
es: "whois.nic.es",
|
||||
br: "whois.registro.br",
|
||||
ca: "whois.cira.ca",
|
||||
dk: "whois.dk-hostmaster.dk",
|
||||
hk: "whois.hkirc.hk",
|
||||
sg: "whois.sgnic.sg",
|
||||
in: "whois.registry.in",
|
||||
nz: "whois.srs.net.nz",
|
||||
ch: "whois.nic.ch",
|
||||
li: "whois.nic.li",
|
||||
io: "whois.nic.io",
|
||||
ai: "whois.nic.ai",
|
||||
ru: "whois.tcinet.ru",
|
||||
su: "whois.tcinet.ru",
|
||||
"xn--p1ai": "whois.tcinet.ru", // .рф
|
||||
|
||||
// CentralNic-operated second-level zones (treat as exceptions here for simplicity)
|
||||
"uk.com": "whois.centralnic.com",
|
||||
"uk.net": "whois.centralnic.com",
|
||||
"gb.com": "whois.centralnic.com",
|
||||
"gb.net": "whois.centralnic.com",
|
||||
"eu.com": "whois.centralnic.com",
|
||||
"us.com": "whois.centralnic.com",
|
||||
"se.com": "whois.centralnic.com",
|
||||
"de.com": "whois.centralnic.com",
|
||||
"br.com": "whois.centralnic.com",
|
||||
"ru.com": "whois.centralnic.com",
|
||||
"cn.com": "whois.centralnic.com",
|
||||
"sa.com": "whois.centralnic.com",
|
||||
} as Record<string, string>;
|
Reference in New Issue
Block a user