#3
Prevent DNS setup host mismatches
Summary
- show DNS host fields in registrar-safe relative form (
@,_dmarc, and the DKIM selector) - detect records copied to doubled domain names and distinguish host, value, and combined mismatches
- normalize chunked TXT responses so valid DKIM records do not remain falsely missing
- add regression coverage for doubled hostnames, registrar host formatting, and chunked DKIM answers
Validation
corepack pnpm test(8 passed)- focused ESLint on all changed source and test files
corepack pnpm buildgit diff --check origin/main...HEAD- browser-tested mismatch guidance and verified that copying the apex host writes
@
Activity
4mikeyreviewed3mo ago
dd61b43 into main3mo ago
Reviewed the diff against
main(base8a1a3d7, head37dbd21) plus the surrounding call sites inlib/dns/records.ts,lib/demo/provider.ts, andlib/stalwart/provider.ts.What changed:
verifyRecordsnow takes the domain apex, tries an exact-match lookup first (matchingAnswer), then re-queries a doubled hostname (host.domain) to distinguish "record copied to the wrong host" from "record present but value differs," andnormalizenow extracts and concatenates quoted TXT chunks so multi-string DKIM answers compare correctly against the unquoted DB value. The UI renders a relative host (@,_dmarc, etc.) via the newrelativeDnsHost, consistent with the existingnormalizeHost/isRequiredKindconventions inrecords.ts.Correctness check:
doubledHostnormalization matchesnormalizeHostsemantics (trailing dot, case) used elsewhere, and both call sites (demo/provider.ts,stalwart/provider.ts) now passcurrent.nameconsistently, soverifyRecords/relativeDnsHostsee the same apex string.statusternary incomponents/shell/dns-records.tsx(lines ~263-277) is misleadingly indented (the: optional ? "Not added" : "Missing"block reads as if it closes an earlier branch), but ternaries are right-associative regardless of whitespace — I traced the actual nesting and it falls through correctly whenmismatchis undefined. Not a bug, just worth a reflow for readability if you touch this block again.matchingAnswerreplaces the old loose substring check (value.includes(expected) || expected.includes(value)) with strict post-normalize equality (plus an MX priority-suffix allowance). This is a real behavior tightening — any TXT answer that isn't an exact match to the stored value will now report as a mismatch instead of silently passing. That looks intentional here (it's what makes the doubled-host/chunked-TXT detection meaningful) and is covered bydoh.test.mjs, so not flagging as blocking, but call it out in case any production domain currently relies on the old fuzzy matching to show "Live" for TXT records with extra content.try/catch, so a failed second lookup still falls back to{ ok: false }rather than throwing.Tests:
doh.test.mjscovers doubled-host detection (host vs host-and-value mismatch) and chunked-DKIM acceptance;parse-zone.test.mjsadds coverage forrelativeDnsHost. These exercise the new branches reasonably well.No blocking correctness or security issues found. CI (
Validate application) is green and the branch is mergeable.Non-blocking observation: the
wrongHostAnswers[0]used for the "host-and-value" mismatch could, in principle, pick up an unrelated pre-existing record at the doubled hostname (not necessarily the user's own misconfiguration) and still label it as a mismatch. Given this is a heuristic UX hint rather than an authoritative check, that seems acceptable, but worth being aware of if support tickets come in about a confusing "found a different record" message.