diff options
| -rw-r--r-- | names/server.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/names/server.js b/names/server.js index 83996d7..92e6fd8 100644 --- a/names/server.js +++ b/names/server.js @@ -40,7 +40,7 @@ import { accountOf, accountBlockers, forgetAccount } from './forget.js'; const CFG = JSON.parse(readFileSync(process.env.NAMES_CONFIG || join(import.meta.dir, 'config.json'), 'utf8')); -// { port, domains: { '<domain>': { zoneId, welcome? } }, domain (default), cfEmail, cfKey, +// { port, domains: { '<domain>': { zoneId, welcome?, dns? } }, domain (default), cfEmail, cfKey, // dbFile (SQLite state), stateFile (the old JSON state, imported once), // ln: { kind:'socket', path } — the ASP's CLN, for per-name bolt12 offers, // forwarder: { mnemonic, ark, esplora, network } — a small float ark wallet @@ -88,6 +88,15 @@ const cfHeaders = { const recordName = (name, domain) => `${name}.user._bitcoin-payment.${domain}`; async function cfWrite(name, domain, uri, existingId) { + // A domain whose config says dns: false gets no BIP-353 records: its names + // are LNURL and NIP-05 only. paff.club: every browser's tipping wallet + // claims a name there, the zone hit Cloudflare's record quota ("Record quota + // exceeded", 81045) and claims failed, while its records were never usable + // (DNSSEC is off there). A record kept from before goes as its name updates. + if (DOMAINS[domain]?.dns === false) { + if (existingId) await cfDelete(domain, existingId).catch((e) => log(`dns record ${existingId} stayed: ${e.message}`)); + return null; + } // TXT character-strings cap at 255 bytes; BIP-353 readers concatenate the // chunks in order, so a long ark+lno URI just spans several quoted strings. const zoneId = DOMAINS[domain]?.zoneId; @@ -105,6 +114,7 @@ async function cfWrite(name, domain, uri, existingId) { return j.result.id; } async function cfDelete(domain, recordId) { + if (!recordId) return; // a name on a domain without records (dns: false) const zoneId = DOMAINS[domain]?.zoneId; if (!zoneId) throw new Error('unknown domain'); const r = await fetch(`${CF}/zones/${zoneId}/dns_records/${recordId}`, { |
