Fix RDAP lookup deployment failure by using static DNS data

Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-19 15:54:31 +00:00
parent 7b5fffd888
commit 6b850a2ade
2 changed files with 5373 additions and 21 deletions

5366
server/data/rdap-dns.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,33 +4,19 @@ const { log, TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD } = require("../../src/u
const { parse: parseTld } = require("tldts");
const { setting, setSetting } = require("../util-server");
const { Notification } = require("../notification");
const { default: NodeFetchCache, MemoryCache } = require("node-fetch-cache");
const TranslatableError = require("../translatable-error");
const dayjs = require("dayjs");
const cachedFetch = process.env.NODE_ENV
? NodeFetchCache.create({
// cache for 8h
cache: new MemoryCache({ ttl: 1000 * 60 * 60 * 8 }),
})
: fetch;
// Load static RDAP DNS data from local file
const rdapDnsData = require("../data/rdap-dns.json");
/**
* Find the RDAP server for a given TLD
* @param {string} tld TLD
* @returns {Promise<string>} First RDAP server found
* @returns {string|null} First RDAP server found
*/
async function getRdapServer(tld) {
let rdapList;
try {
const res = await cachedFetch("https://data.iana.org/rdap/dns.json");
rdapList = await res.json();
} catch (error) {
log.debug("rdap", error);
return null;
}
const services = rdapList["services"] ?? [];
function getRdapServer(tld) {
const services = rdapDnsData["services"] ?? [];
const rootTld = tld?.split(".").pop();
if (rootTld) {
for (const [tlds, urls] of services) {
@ -50,7 +36,7 @@ async function getRdapServer(tld) {
*/
async function getRdapDomainExpiryDate(domain) {
const tld = DomainExpiry.parseTld(domain).publicSuffix;
const rdapServer = await getRdapServer(tld);
const rdapServer = getRdapServer(tld);
if (rdapServer === null) {
log.warn("rdap", `No RDAP server found, TLD ${tld} not supported.`);
return null;
@ -178,7 +164,7 @@ class DomainExpiry extends BeanModel {
const publicSuffix = tld.publicSuffix;
const rootTld = publicSuffix.split(".").pop();
const rdap = await getRdapServer(publicSuffix);
const rdap = getRdapServer(publicSuffix);
if (!rdap) {
throw new TranslatableError("domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint", {
publicSuffix,