domains: fresh DNS walks down from the registrable domain (#724)
Astra R2 fixes, each invariant one piece of code with one guard test. Zone discovery is now top-down and authoritative. The walk starts at the name's ICANN registrable domain (private and wildcard public-suffix rules are climbed past, so eu.github.io is never assumed to exist), takes its NS set from the cache (positive for a registered domain), verifies every zone's SOA owner before trusting it, and follows only referrals strictly down the name's path, at most freshMaxZones of them. The cached nearest-first parent walk and the cached CNAME shortcut are gone, so no cached query is ever sent for the name or any label between it and the registrable domain. Glue is used only for nameservers inside the referred zone and passes publicNameserver. FreshResolver.Forget, wired as Config.FreshForget: a fresh-first name that ends a pass "pointing" has its fresh failure backoff cleared, so an onboarding failure never suppresses the look that keeps it published. Census claims for domainsTickConfig, FreshResolver.query and .exchange.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+688
−698
docs/superpowers/notes/census-proposal-no-negative-prime-724.md+11 −4internal/domains/export_test.go+3 −0internal/domains/freshdns.go+244 −148internal/domains/freshdns_stamp_test.go+103 −0internal/domains/freshdns_test.go+282 −531internal/domains/reconcile.go+20 −0internal/host/agent.go+10 −8internal/host/host_test.go+2 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv+12 −4
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md| index abe5a8442..c94cb1509 100644 |
| --- a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md |
| +++ b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md |
| @@ -1,19 +1,26 @@ |
| # Census approval: no-negative-prime-724 |
| -Ruling `census-ruling-no-negative-prime-724`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-no-negative-prime-724`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| -| `internal/domains/reconcile.go` `StampHealth` | sites | -registry:Alias, +registry:DNSStatus ×2, -registry:Host, -whole:Route, -whole:RouteAlias | section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) | |
| +| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) | |
| +| `internal/domains/reconcile.go` `StampHealth` | sites | -registry:Alias, +registry:DNSStatus ×2, -registry:Host, -whole:Route, -whole:RouteAlias | section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) | |
| -Envelopes re-pinned: `internal/domains`. |
| +Envelopes re-pinned: `internal/domains`, `internal/host`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| Recorded dispositions, which each change must still satisfy: |
| +- `internal/host/agent.go` `domainsTickConfig`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724) |
| - `internal/domains/reconcile.go` `StampHealth`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724) |
| -Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `1fc14572275cc3e3fc7a889f4672d867dc3982204c8909cd87a60024f0909829`. |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/domains/freshdns.go:FreshResolver.query`: reads +file:Read; written legacy, accepted-legacy, frozen |
| +- quiet `internal/domains/freshdns.go:FreshResolver.exchange`: reads nothing now; retired while it reads nothing (or its row keeps no sites) |
| + |
| +Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `638b1b2c6720713927139989c74a0f133de77f765df4e3a0c0a333137582b2ca`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/domains/export_test.go b/internal/domains/export_test.go| index 6084f6713..c1cdec26f 100644 |
| --- a/internal/domains/export_test.go |
| +++ b/internal/domains/export_test.go |
| @@ -16,3 +16,6 @@ func SetFreshPassMax(n int) (restore func()) { |
| // PublicNameserver is publicNameserver, the fresh lookup's destination |
| // policy. |
| var PublicNameserver = publicNameserver |
| + |
| +// RegistrableDomain is registrableDomain, where the fresh walk starts. |
| +var RegistrableDomain = registrableDomain |
diff --git a/internal/domains/freshdns.go b/internal/domains/freshdns.go| index 300253e04..107d76b9c 100644 |
| --- a/internal/domains/freshdns.go |
| +++ b/internal/domains/freshdns.go |
| @@ -17,18 +17,22 @@ import ( |
| // FreshResolver answers "what does this hostname resolve to right now" |
| // without any cache in the way (#724). It finds the zone that holds the |
| -// name, asks that zone's own nameservers, and trusts only an authoritative |
| -// reply to the exact question it sent. Config.ResolveFresh is its Resolve. |
| +// name by asking authoritative servers top-down from the name's registrable |
| +// domain, asks that zone's own nameservers, and trusts only an |
| +// authoritative reply to the exact question it sent. Config.ResolveFresh is |
| +// its Resolve and Config.FreshForget its Forget. |
| // |
| // Why not just skip the box's cache: systemd-resolved is not the only |
| // cache between us and the customer's zone. The upstream (VPC) resolver |
| // behind it may hold a "no such name" for the same SOA minimum. Asking the |
| // zone's own nameservers is the one answer no cache can hold back. |
| // |
| -// The cached resolver (LookupNS, LookupHost) is still used for the names |
| -// around the answer that we are not waiting on: the zone's NS set, the |
| -// nameservers' own addresses, and a CNAME target outside the zone (in |
| -// practice the deployment's own edge name). |
| +// The cached resolver is still used, only for names that exist whatever |
| +// the customer has done yet: the registrable domain's NS set (LookupNS), |
| +// nameserver host addresses and a CNAME target outside the zone (in |
| +// practice the deployment's own edge name) (LookupHost). It is never asked |
| +// about the name or any label between it and the registrable domain; see |
| +// resolve. |
| // |
| // The nameservers are named by tenant DNS, so their addresses are tenant |
| // input: every one passes publicNameserver before a socket is opened, and |
| @@ -37,10 +41,6 @@ import ( |
| type FreshResolver struct { |
| LookupNS func(ctx context.Context, name string) ([]*net.NS, error) |
| LookupHost func(ctx context.Context, host string) ([]string, error) |
| - // LookupCNAME is the cached resolver's canonical name, used only to |
| - // skip a level that is an alias; nil skips that shortcut (verifyZone |
| - // still refuses a wrong zone). |
| - LookupCNAME func(ctx context.Context, host string) (string, error) |
| // Dial opens the UDP socket to a nameserver that has already passed |
| // publicNameserver; nil is a net.Dialer. A seam for tests, which point |
| // a public test address at a loopback server. |
| @@ -48,12 +48,13 @@ type FreshResolver struct { |
| // Timeout bounds one whole Resolve; 0 is 4 s: two silent servers at |
| // AttemptTimeout each, then a verified zone's two queries. |
| Timeout time.Duration |
| - // AttemptTimeout bounds one nameserver inside it; 0 is 1 s, so a |
| - // silent server leaves time for the next. |
| + // AttemptTimeout bounds one exchange with one nameserver inside it; 0 |
| + // is 1 s, so a silent server leaves time for the next. |
| AttemptTimeout time.Duration |
| // Backoff is how long a name whose lookup FAILED is answered with the |
| // failure again without asking anyone; 0 is 30 minutes. A dead or lame |
| - // nameserver would otherwise cost a full Timeout on every pass. |
| + // nameserver would otherwise cost a full Timeout on every pass. Forget |
| + // ends it early. |
| Backoff time.Duration |
| // Now is the clock seam; nil is time.Now. |
| Now func() time.Time |
| @@ -158,124 +159,138 @@ func (r *FreshResolver) Resolve(host string) ([]string, error) { |
| return ips, err |
| } |
| +// Forget ends host's failure backoff, so the next Resolve asks again. |
| +// Section 4 calls it when a name it looked at fresh before publication is |
| +// published by any path: a failure recorded while the name was unpublished |
| +// must never stop the look that keeps it published (Astra R2 on #724). |
| +func (r *FreshResolver) Forget(host string) { |
| + name := strings.ToLower(strings.TrimSuffix(host, ".")) |
| + r.mu.Lock() |
| + delete(r.failedAt, name) |
| + r.mu.Unlock() |
| +} |
| + |
| func isNotFound(err error) bool { |
| var dnsErr *net.DNSError |
| return errors.As(err, &dnsErr) && dnsErr.IsNotFound |
| } |
| -// resolve finds the zone that holds name WITHOUT the cached resolver ever |
| -// hearing about a level that may not exist yet, and asks that zone's |
| -// nameservers until one gives a definitive authoritative answer (the |
| -// addresses, or "no such name"). In order: |
| +// registrableDomain is name's ICANN registrable domain: the one label of |
| +// name below its ICANN public suffix (example.com for shop.eu.example.com, |
| +// github.io for shop.api.eu.github.io, shop.co.uk for itself). Private |
| +// public-suffix entries (eu.github.io's own rules) and wildcard rules are |
| +// climbed past until an ICANN entry is found: a private or wildcard |
| +// boundary does not prove the label below it exists, while a customer must |
| +// have registered the ICANN registrable domain for the name to resolve at |
| +// all. With no ICANN entry (an unlisted TLD) it is the last two labels. |
| +// false when name is itself a public suffix. |
| +func registrableDomain(name string) (string, bool) { |
| + suffix := "" |
| + for x := name; ; { |
| + ps, icann := publicsuffix.PublicSuffix(x) |
| + if icann { |
| + suffix = ps |
| + break |
| + } |
| + i := strings.Index(ps, ".") |
| + if i < 0 { |
| + break |
| + } |
| + x = ps[i+1:] |
| + } |
| + if suffix == "" { |
| + labels := strings.Split(name, ".") |
| + return strings.Join(labels[len(labels)-2:], "."), true |
| + } |
| + rest, ok := strings.CutSuffix(name, "."+suffix) |
| + if !ok { |
| + return "", false |
| + } |
| + return rest[strings.LastIndex(rest, ".")+1:] + "." + suffix, true |
| +} |
| + |
| +// resolve finds the zone that holds name and asks it, top-down from the |
| +// registrable domain, without the cached resolver ever hearing about the |
| +// name or any label between it and the registrable domain: |
| // |
| -// 1. the name's registrable domain (example.com for shop.eu.example.com), |
| -// when it is neither the name nor its immediate parent; |
| -// 2. the zones above name, nearest first, skipping the level step 1 |
| -// tried, and stopping below the top level (a TLD's servers only refer |
| -// back down); |
| -// 3. the name ITSELF, last, only when nothing above gave a definitive |
| -// answer. |
| +// 1. zone = registrableDomain(name). Its NS set comes from the cached |
| +// LookupNS: the domain is registered, so the answer is positive and |
| +// primes nothing. This is the ONLY cached NS (or any) query on the |
| +// name's path. |
| +// 2. Each of up to freshMaxServers public addresses of the zone's servers |
| +// is verified to hold zone (verifyZone: an authoritative SOA owned by |
| +// exactly zone) and then asked for name (ask). |
| +// 3. A definitive answer (addresses, or an authoritative not-found) ends |
| +// the lookup. A REFERRAL (no authority, NS records whose owner is |
| +// strictly below zone and at or above name) is followed: the owner |
| +// becomes zone, its servers come from the referral (glue only for |
| +// nameservers inside the child zone, the cached LookupHost for the |
| +// rest), and step 2 runs again, verifying the child before trusting |
| +// it. At most freshMaxZones referrals. Anything else from a server |
| +// (an error, a referral off the path, an unverified zone) moves on to |
| +// the next server, and when none is left the lookup fails. |
| // |
| // Why: the cached resolver (systemd-resolved, then the VPC resolver) caches |
| // a "no such name" for a NAME, whatever type was asked (RFC 2308 section |
| // 5), for the zone's SOA minimum, and a resolver doing NXDOMAIN cuts (RFC |
| // 8020) denies every name below it too. A customer attaches a hostname |
| -// before adding its record, so a cached LookupCNAME or LookupNS on the |
| -// name, or on a label between it and the registrable domain that does not |
| -// exist (eu.example.com), would plant exactly that negative entry, and the |
| -// cert issuer reading the same caches would wait it out. The registrable |
| -// domain exists before anyone can attach a name under it, so asking the |
| -// cache for its NS set primes nothing. |
| +// before adding its record, so a cached query for the name, or for a label |
| +// on the way to it that does not exist (eu.example.com), would plant |
| +// exactly that negative entry, and the cert issuer reading the same caches |
| +// would wait it out. Discovering the zone from authoritative servers |
| +// needs no such query. The remaining ways a name gets a cached query are |
| +// outside this function: section 4's cached fallback after a fresh failure |
| +// and for names past the per-pass budget. |
| // |
| -// The guarantee, precisely: for a name under a registrable domain whose |
| -// servers answer it definitively, no cached query carries the name or any |
| -// label between it and the registrable domain. What can still prime: a |
| -// delegated child zone under the registrable domain (its referral sends the |
| -// walk through the intermediate labels, one of which may not exist), |
| -// parents whose servers do not answer (the walk then reaches the name |
| -// itself), and, in section 4, names past the per-pass budget, which get the |
| -// cached look. The name-itself attempt covers a name that is its own zone |
| -// (an apex, or a delegated sub-zone whose parent only refers down); such a |
| -// name exists before anyone attaches it. freshMaxZones bounds step 2 only: |
| -// steps 1 and 3 each have their own allowance, and step 3 gets its turn |
| -// unless the overall deadline (Timeout) has already expired. |
| +// Cost, worst case: 1 + freshMaxZones zones, each up to freshMaxServers |
| +// servers, each an SOA and an A exchange: 16 authoritative exchanges, all |
| +// inside Timeout (each also inside AttemptTimeout). Cached: one LookupNS, |
| +// LookupHost for nameserver hosts until freshMaxServers IPv4 addresses are |
| +// found per zone, and at most one LookupHost for an out-of-zone CNAME |
| +// target. |
| // |
| -// A zone is only used once it is VERIFIED: the server about to be asked |
| -// answers, with authority, an SOA record owned by exactly that name. The |
| -// cached LookupNS cannot be trusted to name the zone on its own, because an |
| -// NS query follows a CNAME and Go drops the owner of the records it returns: |
| -// a cached "shop.example.com CNAME old-provider.net" hands back |
| -// old-provider.net's servers as if they were shop.example.com's. Verifying |
| -// at the server keeps every fresh answer, and the in-zone test on a CNAME |
| -// target, tied to the zone that really holds the name. A level the cached |
| -// resolver already knows to be an alias is skipped without asking anyone, |
| -// since a CNAME cannot sit at a zone apex. |
| +// Verification is what makes a referral or an NS set safe to follow: a |
| +// server only answers once it has shown, with authority, an SOA owned by |
| +// exactly the zone it was found for, so a lame or hostile server for some |
| +// other zone cannot supply the answer, and the in-zone test on a CNAME |
| +// target is tied to the zone that really holds the name. |
| func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, error) { |
| - last := fmt.Errorf("%w: no zone found for %s", errNoAuthority, name) |
| - // try asks one level; stop is true at a definitive answer or once the |
| - // deadline has passed. |
| - try := func(zone string, zones *int) (stop bool, ips []string, err error) { |
| - ips, err = r.tryZone(ctx, name, zone, zones) |
| - if err == nil || isNotFound(err) { |
| - return true, ips, err |
| - } |
| - if !errors.Is(err, errNotAZone) { |
| - last = err |
| - } |
| - return ctx.Err() != nil, nil, last |
| + zone, ok := registrableDomain(name) |
| + if !ok { |
| + return nil, fmt.Errorf("%w: %s is a public suffix", errNoAuthority, name) |
| } |
| - parent := name[strings.Index(name, ".")+1:] |
| - registrable, err := publicsuffix.EffectiveTLDPlusOne(name) |
| - if err != nil || registrable == name || registrable == parent { |
| - registrable = "" |
| + nss, err := r.LookupNS(ctx, zone) |
| + if err != nil || len(nss) == 0 { |
| + return nil, fmt.Errorf("%w: no NS set for %s", errNoAuthority, zone) |
| } |
| - if registrable != "" { |
| - if stop, ips, err := try(registrable, new(int)); stop { |
| - return ips, err |
| - } |
| + hosts := make([]string, len(nss)) |
| + for i, ns := range nss { |
| + hosts[i] = ns.Host |
| } |
| - zones := 0 |
| - for zone := parent; strings.Contains(zone, ".") && zones < freshMaxZones; zone = zone[strings.Index(zone, ".")+1:] { |
| - if zone == registrable { |
| - continue |
| - } |
| - if stop, ips, err := try(zone, &zones); stop { |
| + servers := r.serverAddrs(ctx, zone, hosts, nil) |
| + for referrals := 0; ; referrals++ { |
| + ips, ref, err := r.askZone(ctx, servers, name, zone) |
| + if ref == nil { |
| return ips, err |
| } |
| + if referrals >= freshMaxZones { |
| + return nil, fmt.Errorf("%w: delegation to %s is more than %d levels below the registrable domain", errNoAuthority, name, freshMaxZones) |
| + } |
| + zone = ref.zone |
| + servers = r.serverAddrs(ctx, zone, ref.hosts, ref.glue) |
| } |
| - // Nothing above gave a definitive answer. Now the name itself, with |
| - // its own allowance outside freshMaxZones. |
| - _, ips, err := try(name, new(int)) |
| - return ips, err |
| } |
| -// errNotAZone is a level tryZone skipped without asking anyone: a cached |
| -// alias, or no NS set. |
| -var errNotAZone = errors.New("fresh dns: not a zone") |
| - |
| -// tryZone asks zone's nameservers about name and returns the first |
| -// definitive answer (addresses, or an authoritative not-found), else the |
| -// last failure, or errNotAZone for a level that is not a zone. *zones |
| -// counts the levels that had an NS set. |
| -func (r *FreshResolver) tryZone(ctx context.Context, name, zone string, zones *int) ([]string, error) { |
| - if r.aliased(ctx, zone) { |
| - return nil, errNotAZone |
| - } |
| - nss, err := r.LookupNS(ctx, zone) |
| - if err != nil || len(nss) == 0 { |
| - return nil, errNotAZone |
| - } |
| - *zones++ |
| - servers := r.nameserverAddrs(ctx, nss) |
| - if len(servers) == 0 { |
| - return nil, fmt.Errorf("%w: no public address for any nameserver of %s", errNoAuthority, zone) |
| - } |
| - var last error |
| +// askZone asks servers, which the caller found for zone, about name, one |
| +// at a time: each is verified to hold zone first. It returns the first |
| +// definitive answer or valid referral, else the last failure. |
| +func (r *FreshResolver) askZone(ctx context.Context, servers []netip.AddrPort, name, zone string) ([]string, *referral, error) { |
| + var last error = fmt.Errorf("%w: no public address for any nameserver of %s", errNoAuthority, zone) |
| for _, s := range servers { |
| if last = r.verifyZone(ctx, s, zone); last == nil { |
| - ips, err := r.ask(ctx, s, name, zone) |
| - if err == nil || isNotFound(err) { |
| - return ips, err |
| + ips, ref, err := r.ask(ctx, s, name, zone) |
| + if ref != nil || err == nil || isNotFound(err) { |
| + return ips, ref, err |
| } |
| last = err |
| } |
| @@ -283,36 +298,44 @@ func (r *FreshResolver) tryZone(ctx context.Context, name, zone string, zones *i |
| break |
| } |
| } |
| - return nil, last |
| + return nil, nil, last |
| } |
| -// aliased reports whether the cached resolver says zone is a CNAME to some |
| -// other name. Only a definite answer counts; a failed lookup is not one. |
| -func (r *FreshResolver) aliased(ctx context.Context, zone string) bool { |
| - if r.LookupCNAME == nil { |
| - return false |
| - } |
| - canon, err := r.LookupCNAME(ctx, zone) |
| - if err != nil || canon == "" { |
| - return false |
| - } |
| - return !strings.EqualFold(strings.TrimSuffix(canon, "."), zone) |
| +// referral is a server's "ask the child zone": the child's apex, its NS |
| +// hosts, and glue addresses for the hosts inside it. |
| +type referral struct { |
| + zone string |
| + hosts []string |
| + glue map[string][]netip.Addr |
| } |
| -// nameserverAddrs resolves the NS hosts (in random order) through the |
| -// cached resolver and keeps up to freshMaxServers addresses that pass |
| -// publicNameserver, IPv4 first: a box without a working IPv6 route would |
| -// otherwise spend its attempts on silence. |
| -func (r *FreshResolver) nameserverAddrs(ctx context.Context, nss []*net.NS) []netip.AddrPort { |
| +// serverAddrs resolves zone's NS hosts (in random order) and keeps up to |
| +// freshMaxServers addresses that pass publicNameserver, IPv4 first: a box |
| +// without a working IPv6 route would otherwise spend its attempts on |
| +// silence. For a referred zone (glue non-nil) a host inside the zone is |
| +// taken from glue only, never the cache: the cache would be asked about a |
| +// name below the registrable domain. Other hosts go to the cached |
| +// LookupHost. |
| +func (r *FreshResolver) serverAddrs(ctx context.Context, zone string, hosts []string, glue map[string][]netip.Addr) []netip.AddrPort { |
| var v4, v6 []netip.AddrPort |
| - for _, i := range rand.Perm(len(nss)) { |
| - addrs, err := r.LookupHost(ctx, nss[i].Host) |
| - if err != nil { |
| - continue |
| + for _, i := range rand.Perm(len(hosts)) { |
| + host := strings.ToLower(strings.TrimSuffix(hosts[i], ".")) |
| + var addrs []netip.Addr |
| + if glue != nil && (host == zone || strings.HasSuffix(host, "."+zone)) { |
| + addrs = glue[host] |
| + } else { |
| + found, err := r.LookupHost(ctx, host) |
| + if err != nil { |
| + continue |
| + } |
| + for _, a := range found { |
| + if ip, err := netip.ParseAddr(a); err == nil { |
| + addrs = append(addrs, ip) |
| + } |
| + } |
| } |
| - for _, a := range addrs { |
| - ip, err := netip.ParseAddr(a) |
| - if err != nil || !publicNameserver(ip) { |
| + for _, ip := range addrs { |
| + if !publicNameserver(ip) { |
| continue |
| } |
| ap := netip.AddrPortFrom(ip.Unmap(), 53) |
| @@ -367,10 +390,25 @@ func publicNameserver(ip netip.Addr) bool { |
| return true |
| } |
| -// exchange sends one non-recursive IN query of type qtype for name to |
| -// server and returns the reply to exactly that question, which must carry |
| -// authority and not be truncated. The RCODE is the caller's to read. |
| +// exchange is query for a reply that must carry authority and not be |
| +// truncated. The RCODE is the caller's to read. |
| func (r *FreshResolver) exchange(ctx context.Context, server netip.AddrPort, name string, qtype dnsmessage.Type) (*dnsmessage.Message, error) { |
| + reply, err := r.query(ctx, server, name, qtype) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if !reply.Authoritative { |
| + return nil, fmt.Errorf("%w: %s is not authoritative for %s", errNoAuthority, server, name) |
| + } |
| + if reply.Truncated { |
| + return nil, fmt.Errorf("%w: truncated reply from %s", errNoAuthority, server) |
| + } |
| + return reply, nil |
| +} |
| + |
| +// query sends one non-recursive IN query of type qtype for name to server |
| +// and returns the reply to exactly that question, whatever its flags. |
| +func (r *FreshResolver) query(ctx context.Context, server netip.AddrPort, name string, qtype dnsmessage.Type) (*dnsmessage.Message, error) { |
| if !publicNameserver(server.Addr()) { |
| return nil, fmt.Errorf("%w: refusing non-public nameserver %s", errNoAuthority, server) |
| } |
| @@ -423,12 +461,6 @@ func (r *FreshResolver) exchange(ctx context.Context, server netip.AddrPort, nam |
| } |
| // Not the reply to this question; keep reading until the deadline. |
| } |
| - if !reply.Authoritative { |
| - return nil, fmt.Errorf("%w: %s is not authoritative for %s", errNoAuthority, server, name) |
| - } |
| - if reply.Truncated { |
| - return nil, fmt.Errorf("%w: truncated reply from %s", errNoAuthority, server) |
| - } |
| return &reply, nil |
| } |
| @@ -453,16 +485,80 @@ func (r *FreshResolver) verifyZone(ctx context.Context, server netip.AddrPort, z |
| } |
| // ask sends one non-recursive IN A query for name to server, which |
| -// verifyZone has shown holds zone, and reads the answer. A CNAME chain in |
| -// the reply is followed; if it ends outside zone with no address in the |
| -// reply, the target goes to the cached LookupHost. A chain that loops, runs |
| -// past freshMaxCNAMEs, or ends inside zone with no address is not an |
| -// answer. |
| -func (r *FreshResolver) ask(ctx context.Context, server netip.AddrPort, name, zone string) ([]string, error) { |
| - reply, err := r.exchange(ctx, server, name, dnsmessage.TypeA) |
| +// verifyZone has shown holds zone, and reads the answer. A reply without |
| +// authority is only usable as a referral down the name's path (see |
| +// referralFrom). A CNAME chain in an authoritative reply is followed; if it |
| +// ends outside zone with no address in the reply, the target goes to the |
| +// cached LookupHost. A chain that loops, runs past freshMaxCNAMEs, or ends |
| +// inside zone with no address is not an answer. |
| +func (r *FreshResolver) ask(ctx context.Context, server netip.AddrPort, name, zone string) ([]string, *referral, error) { |
| + reply, err := r.query(ctx, server, name, dnsmessage.TypeA) |
| if err != nil { |
| - return nil, err |
| + return nil, nil, err |
| + } |
| + if reply.Truncated { |
| + return nil, nil, fmt.Errorf("%w: truncated reply from %s", errNoAuthority, server) |
| } |
| + if !reply.Authoritative { |
| + ref, err := referralFrom(reply, name, zone) |
| + if err != nil { |
| + return nil, nil, fmt.Errorf("%w (from %s)", err, server) |
| + } |
| + return nil, ref, nil |
| + } |
| + ips, err := r.answer(ctx, reply, server, name, zone) |
| + return ips, nil, err |
| +} |
| + |
| +// referralFrom reads a non-authoritative reply as a delegation. It must |
| +// carry no answer and only NS records, all owned by one child zone that is |
| +// strictly below zone and at or above name: a referral sideways, upward or |
| +// to itself (a loop) is refused. Glue is kept only for NS hosts inside the |
| +// child. |
| +func referralFrom(reply *dnsmessage.Message, name, zone string) (*referral, error) { |
| + if reply.RCode != dnsmessage.RCodeSuccess || len(reply.Answers) != 0 { |
| + return nil, fmt.Errorf("%w: no authority for %s", errNoAuthority, name) |
| + } |
| + ref := &referral{glue: map[string][]netip.Addr{}} |
| + for _, rr := range reply.Authorities { |
| + ns, ok := rr.Body.(*dnsmessage.NSResource) |
| + if !ok || rr.Header.Class != dnsmessage.ClassINET { |
| + continue |
| + } |
| + owner := strings.ToLower(strings.TrimSuffix(rr.Header.Name.String(), ".")) |
| + if ref.zone == "" { |
| + ref.zone = owner |
| + } else if owner != ref.zone { |
| + return nil, fmt.Errorf("%w: referral for %s names more than one zone", errNoAuthority, name) |
| + } |
| + ref.hosts = append(ref.hosts, strings.ToLower(strings.TrimSuffix(ns.NS.String(), "."))) |
| + } |
| + if ref.zone == "" { |
| + return nil, fmt.Errorf("%w: no authority and no referral for %s", errNoAuthority, name) |
| + } |
| + if !strings.HasSuffix(ref.zone, "."+zone) || (ref.zone != name && !strings.HasSuffix(name, "."+ref.zone)) { |
| + return nil, fmt.Errorf("%w: referral to %s is not between %s and %s", errNoAuthority, ref.zone, zone, name) |
| + } |
| + for _, rr := range reply.Additionals { |
| + if rr.Header.Class != dnsmessage.ClassINET { |
| + continue |
| + } |
| + owner := strings.ToLower(strings.TrimSuffix(rr.Header.Name.String(), ".")) |
| + if owner != ref.zone && !strings.HasSuffix(owner, "."+ref.zone) { |
| + continue |
| + } |
| + switch b := rr.Body.(type) { |
| + case *dnsmessage.AResource: |
| + ref.glue[owner] = append(ref.glue[owner], netip.AddrFrom4(b.A)) |
| + case *dnsmessage.AAAAResource: |
| + ref.glue[owner] = append(ref.glue[owner], netip.AddrFrom16(b.AAAA)) |
| + } |
| + } |
| + return ref, nil |
| +} |
| + |
| +// answer reads an authoritative reply to name's A query from server. |
| +func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, server netip.AddrPort, name, zone string) ([]string, error) { |
| fqdn := name + "." |
| switch reply.RCode { |
| case dnsmessage.RCodeSuccess: |
diff --git a/internal/domains/freshdns_stamp_test.go b/internal/domains/freshdns_stamp_test.go| index 1137c5f31..29c8f3547 100644 |
| --- a/internal/domains/freshdns_stamp_test.go |
| +++ b/internal/domains/freshdns_stamp_test.go |
| @@ -5,9 +5,12 @@ import ( |
| "errors" |
| "fmt" |
| "net" |
| + "sync/atomic" |
| "testing" |
| "time" |
| + "golang.org/x/net/dns/dnsmessage" |
| + |
| "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/registry" |
| ) |
| @@ -522,3 +525,103 @@ func TestStampHealthUpgradesBeforeFreshFirst(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// realFresh is one FreshResolver kept across passes, as in production, |
| +// for example.com served by a fake authority whose A answers can be |
| +// switched off (silent) and on (pointing here). cached is what the box's |
| +// cached resolver says about shop.example.com. |
| +type realFresh struct { |
| + fa *fakeAuthority |
| + live *atomic.Bool |
| + cached *func(string) ([]string, error) |
| + now *time.Time |
| + cfg domains.Config |
| +} |
| + |
| +func newRealFresh(t *testing.T) *realFresh { |
| + t.Helper() |
| + live := &atomic.Bool{} |
| + fa := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + if !live.Load() { |
| + return false |
| + } |
| + r.Authoritative = true |
| + r.Answers = []dnsmessage.Resource{aRecord("shop.example.com.", edgeIP)} |
| + return true |
| + }) |
| + rf := &realFresh{fa: fa, live: live, now: clock()} |
| + cached := nxdomain |
| + rf.cached = &cached |
| + fresh := oneZone(fa).resolver(rf.now) |
| + rf.cfg = domains.Config{ |
| + AppsDomain: "oncarlos.test", |
| + EdgeIPs: func() []string { return []string{edgeIP} }, |
| + Resolve: func(h string) ([]string, error) { |
| + if h == "shop.example.com" { |
| + return (*rf.cached)(h) |
| + } |
| + return pointingAt(h) |
| + }, |
| + ResolveFresh: fresh.Resolve, |
| + FreshForget: fresh.Forget, |
| + Now: func() time.Time { return *rf.now }, |
| + } |
| + return rf |
| +} |
| + |
| +func (rf *realFresh) pass(t *testing.T, reg *registry.Registry, live bool, cached func(string) ([]string, error)) { |
| + t.Helper() |
| + rf.live.Store(live) |
| + *rf.cached = cached |
| + if err := domains.StampHealth(context.Background(), reg, rf.cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// INVARIANT GUARD (Astra R2 P1-1 on #724): a fresh failure recorded while |
| +// a name was unpublished never suppresses a look after it is published. |
| +// Pass A: the new name's fresh look fails (silent zone, backoff recorded) |
| +// and the cache says pointing, so it is published. Pass B, inside the |
| +// backoff: the cache has gone negative while the record still points |
| +// here. The upgrade look must really be sent, and the name stays |
| +// published. |
| +func TestStampHealthPublicationClearsAnOnboardingBackoff(t *testing.T) { |
| + rf := newRealFresh(t) |
| + reg := regWithAlias(t, "shop.example.com") |
| + rf.pass(t, reg, false, pointingAt) |
| + if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" { |
| + t.Fatalf("pass A: alias = %q, want pointing from the cached fallback", got) |
| + } |
| + sent := rf.fa.queries.Load() |
| + *rf.now = rf.now.Add(10 * time.Minute) |
| + rf.pass(t, reg, true, nxdomain) |
| + if rf.fa.queries.Load() == sent { |
| + t.Fatal("pass B: the upgrade look was suppressed by the onboarding failure's backoff") |
| + } |
| + if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" { |
| + t.Fatalf("pass B: alias = %q, want pointing (unpublished by a stale backoff)", got) |
| + } |
| +} |
| + |
| +// Control: a failure incurred while the name is published still backs off. |
| +// The published name's upgrade look fails (pass A, cache negative: the |
| +// record was really removed, so it stamps ""); inside the backoff no look |
| +// is sent, however the authority answers now. |
| +func TestStampHealthPublishedFailureStillBacksOff(t *testing.T) { |
| + rf := newRealFresh(t) |
| + reg := regWithAlias(t, "shop.example.com") |
| + stampAlias(t, reg, "shop.example.com", "pointing") |
| + rf.pass(t, reg, false, nxdomain) |
| + if got := aliasStatus(t, reg, "shop.example.com"); got != "" { |
| + t.Fatalf("pass A: alias = %q, want \"\" (cached removal stands)", got) |
| + } |
| + sent := rf.fa.queries.Load() |
| + if sent == 0 { |
| + t.Fatal("pass A sent no fresh look") |
| + } |
| + *rf.now = rf.now.Add(10 * time.Minute) |
| + rf.pass(t, reg, true, nxdomain) |
| + if rf.fa.queries.Load() != sent { |
| + t.Fatalf("pass B asked inside the backoff (%d -> %d)", sent, rf.fa.queries.Load()) |
| + } |
| +} |
diff --git a/internal/domains/freshdns_test.go b/internal/domains/freshdns_test.go| index 760a796dc..0957fbac9 100644 |
| --- a/internal/domains/freshdns_test.go |
| +++ b/internal/domains/freshdns_test.go |
| @@ -3,6 +3,7 @@ package domains_test |
| import ( |
| "context" |
| "errors" |
| + "fmt" |
| "net" |
| "net/netip" |
| "strings" |
| @@ -122,36 +123,54 @@ type world struct { |
| ns map[string][]string // zone -> NS hosts |
| hosts map[string][]string // name -> addresses (the cache) |
| routes map[string]*fakeAuthority // "ip:53" -> server |
| - cnames map[string]string // name -> cached canonical name |
| mu sync.Mutex |
| dialed []string |
| - cached []string // every name the cached resolver was asked about, in order |
| + cached []string // "NS name" or "HOST name", every cached query in order |
| } |
| -// note records a cached-resolver query for name. |
| -func (w *world) note(name string) { |
| +// note records a cached-resolver query of kind ("NS" or "HOST") for name. |
| +func (w *world) note(kind, name string) { |
| w.mu.Lock() |
| - w.cached = append(w.cached, strings.TrimSuffix(name, ".")) |
| + w.cached = append(w.cached, kind+" "+strings.TrimSuffix(name, ".")) |
| w.mu.Unlock() |
| } |
| -// cachedFor counts the cached-resolver queries sent for name. |
| +// cachedFor counts the cached-resolver queries, of any kind, for name. |
| func (w *world) cachedFor(name string) int { |
| w.mu.Lock() |
| defer w.mu.Unlock() |
| n := 0 |
| for _, c := range w.cached { |
| - if c == name { |
| + if c[strings.Index(c, " ")+1:] == name { |
| n++ |
| } |
| } |
| return n |
| } |
| +// noCachedBelow is the #724 guard: the cache heard nothing about name or |
| +// any label between it and registrable, and no NS query went to anything |
| +// but registrable itself. |
| +func noCachedBelow(t *testing.T, w *world, name, registrable string) { |
| + t.Helper() |
| + for l := name; l != registrable && strings.Contains(l, "."); l = l[strings.Index(l, ".")+1:] { |
| + if n := w.cachedFor(l); n != 0 { |
| + t.Fatalf("cached resolver asked about %s %d times: %v", l, n, w.cached) |
| + } |
| + } |
| + w.mu.Lock() |
| + defer w.mu.Unlock() |
| + for _, c := range w.cached { |
| + if strings.HasPrefix(c, "NS ") && c != "NS "+registrable { |
| + t.Fatalf("cached NS query other than for %s: %v", registrable, w.cached) |
| + } |
| + } |
| +} |
| + |
| func (w *world) resolver(now *time.Time) *domains.FreshResolver { |
| return &domains.FreshResolver{ |
| LookupNS: func(_ context.Context, name string) ([]*net.NS, error) { |
| - w.note(name) |
| + w.note("NS", name) |
| hs, ok := w.ns[name] |
| if !ok { |
| return nil, errNotFound |
| @@ -163,19 +182,12 @@ func (w *world) resolver(now *time.Time) *domains.FreshResolver { |
| return out, nil |
| }, |
| LookupHost: func(_ context.Context, host string) ([]string, error) { |
| - w.note(host) |
| + w.note("HOST", host) |
| if a, ok := w.hosts[strings.TrimSuffix(host, ".")]; ok { |
| return a, nil |
| } |
| return nil, errNotFound |
| }, |
| - LookupCNAME: func(_ context.Context, host string) (string, error) { |
| - w.note(host) |
| - if c, ok := w.cnames[host]; ok { |
| - return c, nil |
| - } |
| - return "", errNotFound |
| - }, |
| Dial: func(ctx context.Context, network, address string) (net.Conn, error) { |
| w.mu.Lock() |
| w.dialed = append(w.dialed, address) |
| @@ -209,10 +221,12 @@ func clock() *time.Time { t := time.Unix(1000, 0); return &t } |
| func TestFreshResolverReadsTheAuthoritativeA(t *testing.T) { |
| fa := startAuthority(t, "example.com", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - ips, err := oneZone(fa).resolver(clock()).Resolve("shop.example.com") |
| + w := oneZone(fa) |
| + ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| } |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| if got := fa.asked.Load(); got != "shop.example.com." { |
| t.Fatalf("authority asked for %v, want shop.example.com.", got) |
| } |
| @@ -234,11 +248,15 @@ func TestFreshResolverReportsAuthoritativeNXDOMAIN(t *testing.T) { |
| r.RCode = dnsmessage.RCodeNameError |
| return true |
| }) |
| - _, err := oneZone(fa).resolver(clock()).Resolve("shop.example.com") |
| + w := oneZone(fa) |
| + _, err := w.resolver(clock()).Resolve("shop.example.com") |
| var dnsErr *net.DNSError |
| if !errors.As(err, &dnsErr) || !dnsErr.IsNotFound { |
| t.Fatalf("Resolve error = %v, want a not-found DNSError", err) |
| } |
| + // #724: the record does not exist yet, and nothing of ours asked the |
| + // cache about it. |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| } |
| func TestFreshResolverIgnoresNonAuthoritativeAnswers(t *testing.T) { |
| @@ -328,32 +346,6 @@ func TestFreshResolverMovesPastASilentServer(t *testing.T) { |
| } |
| } |
| -// Astra R1 P2-2: a cached CNAME at the name makes the nearest NS set the |
| -// CNAME target's zone. Its refusal must pass the question up to the zone |
| -// that really holds the name. |
| -func TestFreshResolverClimbsPastAWrongZone(t *testing.T) { |
| - wrong := startAuthority(t, "oldprovider.net", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.RCode = dnsmessage.RCodeRefused |
| - return true |
| - }) |
| - right := startAuthority(t, "example.com", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "shop.example.com": {"ns.oldprovider.net."}, |
| - "example.com": {"ns1.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.oldprovider.net": {"192.0.2.9"}, |
| - "ns1.example.com": {"192.0.2.53"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.9:53": wrong, "192.0.2.53:53": right}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the enclosing zone's answer", ips, err) |
| - } |
| -} |
| - |
| // Astra R1 P2-6: only a completed chain is an answer. |
| func TestFreshResolverRefusesBrokenCNAMEChains(t *testing.T) { |
| cases := map[string][]dnsmessage.Resource{ |
| @@ -416,8 +408,8 @@ func TestFreshResolverBacksOffAfterAFailure(t *testing.T) { |
| } |
| func TestFreshResolverStopsAtTheTopLevel(t *testing.T) { |
| - // No zone found below the TLD: an error, and the TLD's own servers are |
| - // never asked (they would only refer us back down). |
| + // The registrable domain has no NS set: an error. Only the registrable |
| + // domain is asked for one; never the TLD, never a label below. |
| var asked []string |
| r := &domains.FreshResolver{ |
| LookupNS: func(_ context.Context, name string) ([]*net.NS, error) { |
| @@ -433,10 +425,8 @@ func TestFreshResolverStopsAtTheTopLevel(t *testing.T) { |
| if _, err := r.Resolve("a.b.nowhere.org"); err == nil { |
| t.Fatal("Resolve with no zone succeeded") |
| } |
| - for _, n := range asked { |
| - if n == "org" { |
| - t.Fatalf("asked the TLD for NS: %v", asked) |
| - } |
| + if len(asked) != 1 || asked[0] != "nowhere.org" { |
| + t.Fatalf("asked for NS sets %v, want only [nowhere.org]", asked) |
| } |
| } |
| @@ -457,69 +447,11 @@ func TestFreshResolverSkipsSpecialUseNames(t *testing.T) { |
| } |
| } |
| -// Astra R2 P2-1: a cached CNAME at the name hands LookupNS the target's |
| -// servers. A server that is not the name's authority must never supply the |
| -// answer, even when it marks its reply authoritative. |
| -func TestFreshResolverNeverTrustsAWrongZoneServer(t *testing.T) { |
| - wrong := startAuthority(t, "oldprovider.net", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - right := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.Authoritative = true |
| - r.RCode = dnsmessage.RCodeNameError |
| - return true |
| - }) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "shop.example.com": {"ns.oldprovider.net."}, |
| - "example.com": {"ns1.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.oldprovider.net": {"192.0.2.9"}, |
| - "ns1.example.com": {"192.0.2.53"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.9:53": wrong, "192.0.2.53:53": right}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| - if !isNotFoundErr(err) { |
| - t.Fatalf("Resolve = %v, %v; want the real zone's NXDOMAIN, not the wrong zone's address", ips, err) |
| - } |
| -} |
| - |
| -// A level the cache already knows to be an alias is not a zone: its |
| -// (silent, here) servers are never dialled, so they cannot use up the time. |
| -func TestFreshResolverSkipsAnAliasedLevel(t *testing.T) { |
| - silent := startAuthority(t, "oldprovider.net", nil) |
| - right := startAuthority(t, "example.com", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "shop.example.com": {"ns.oldprovider.net."}, |
| - "example.com": {"ns1.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.oldprovider.net": {"192.0.2.9", "192.0.2.10"}, |
| - "ns1.example.com": {"192.0.2.53"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.9:53": silent, "192.0.2.10:53": silent, "192.0.2.53:53": right}, |
| - cnames: map[string]string{"shop.example.com": "old-provider.net."}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| - } |
| - for _, d := range w.dialed { |
| - if d != "192.0.2.53:53" { |
| - t.Fatalf("dialled %v, want only the real zone's server", w.dialed) |
| - } |
| - } |
| -} |
| - |
| -// Astra R2 P2-2: with a cached "shop.example.com CNAME example.com", |
| -// LookupNS(shop.example.com) returns example.com's own servers. The zone |
| -// must still come out as example.com, so an in-zone target with no |
| -// address is refused rather than filled in from a stale cache. |
| +// Astra R2 P2-2: an in-zone CNAME target the verified zone gives no |
| +// address for is refused rather than filled in from a stale cache. |
| func TestFreshResolverInZoneTestUsesTheVerifiedZone(t *testing.T) { |
| fa := startAuthority(t, "example.com", authoritative(cnameRecord("shop.example.com.", "www.example.com."))) |
| w := oneZone(fa) |
| - w.ns["shop.example.com"] = []string{"ns1.example.com."} |
| w.hosts["www.example.com"] = []string{edgeIP} // stale cache |
| if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| t.Fatalf("Resolve = %v, want an error: the in-zone target has no address", ips) |
| @@ -531,89 +463,8 @@ func isNotFoundErr(err error) bool { |
| return errors.As(err, &dnsErr) && dnsErr.IsNotFound |
| } |
| -// A sloppy server puts its own apex's SOA in the answer section whatever |
| -// name it is asked about. Only an SOA owned by the asked name verifies a |
| -// zone, or shop.example.com would pass as a zone and www.example.com would |
| -// look out-of-zone, open to the stale cache. |
| -func TestFreshResolverVerifiesTheSOAOwner(t *testing.T) { |
| - fa := startAuthority(t, "", func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.Authoritative = true |
| - if q.Type == dnsmessage.TypeSOA { |
| - r.Answers = []dnsmessage.Resource{soaRecord("example.com")} |
| - return true |
| - } |
| - r.Answers = []dnsmessage.Resource{cnameRecord("shop.example.com.", "www.example.com.")} |
| - return true |
| - }) |
| - w := oneZone(fa) |
| - w.ns["shop.example.com"] = []string{"ns1.example.com."} |
| - w.hosts["www.example.com"] = []string{edgeIP} // stale cache |
| - if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| - t.Fatalf("Resolve = %v, want an error", ips) |
| - } |
| -} |
| - |
| -// #724 follow-up: the box's own lookups must never plant a "no such name" |
| -// for a hostname that does not exist yet. A cached query for the name |
| -// itself (any type: RFC 2308 caches NXDOMAIN per name) through |
| -// systemd-resolved and the VPC resolver would sit there for the zone's SOA |
| -// minimum, and the cert issuer reads those same caches. So the walk asks |
| -// the parent zones first and the cached resolver hears nothing about the |
| -// name while they answer. |
| -func TestFreshResolverNeverPrimesTheCacheForAMissingName(t *testing.T) { |
| - fa := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.Authoritative = true |
| - r.RCode = dnsmessage.RCodeNameError |
| - return true |
| - }) |
| - w := oneZone(fa) |
| - _, err := w.resolver(clock()).Resolve("shop.example.com") |
| - if !isNotFoundErr(err) { |
| - t.Fatalf("Resolve error = %v, want the authoritative not-found", err) |
| - } |
| - if n := w.cachedFor("shop.example.com"); n != 0 { |
| - t.Fatalf("cached resolver asked about shop.example.com %d times (%v), want 0", n, w.cached) |
| - } |
| -} |
| - |
| -func TestFreshResolverNeverAsksTheCacheAboutAPresentName(t *testing.T) { |
| - fa := startAuthority(t, "example.com", authoritative(cnameRecord("shop.example.com.", "edge.oncarlos.test."))) |
| - w := oneZone(fa) |
| - ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| - } |
| - if n := w.cachedFor("shop.example.com"); n != 0 { |
| - t.Fatalf("cached resolver asked about shop.example.com %d times (%v), want 0", n, w.cached) |
| - } |
| -} |
| - |
| -// nameAfterParents fails unless every cached query for name came after the |
| -// last cached query for any other level of it: the parent walk is over |
| -// before the name itself is looked at. |
| -func nameAfterParents(t *testing.T, w *world, name string) { |
| - t.Helper() |
| - w.mu.Lock() |
| - defer w.mu.Unlock() |
| - firstName, lastParent := -1, -1 |
| - for i, c := range w.cached { |
| - switch { |
| - case c == name: |
| - if firstName < 0 { |
| - firstName = i |
| - } |
| - case strings.HasSuffix(name, "."+c): |
| - lastParent = i |
| - } |
| - } |
| - if firstName >= 0 && firstName < lastParent { |
| - t.Fatalf("cached query for %s before the parent walk finished: %v", name, w.cached) |
| - } |
| -} |
| - |
| -// The custom domain is a zone apex with its own A records. No enclosing |
| -// zone below the TLD exists to ask, so the name itself is tried as a zone. |
| -// An apex exists before anyone can attach it, so that query primes nothing. |
| +// The custom domain is its registrable domain, a zone apex with its own A |
| +// records: the walk starts and ends there. |
| func TestFreshResolverResolvesAnApex(t *testing.T) { |
| fa := startAuthority(t, "example.com", authoritative(aRecord("example.com.", edgeIP))) |
| w := oneZone(fa) |
| @@ -621,194 +472,66 @@ func TestFreshResolverResolvesAnApex(t *testing.T) { |
| if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| } |
| + noCachedBelow(t, w, "example.com", "example.com") |
| } |
| -// shop.example.co.uk is its own zone. example.co.uk's servers only refer |
| -// down (no authority), so the walk falls through to the name itself, and |
| -// only after every parent level has been tried. |
| -func TestFreshResolverResolvesADelegatedSubZoneApex(t *testing.T) { |
| - parent := startAuthority(t, "example.co.uk", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - // A referral: no authority, the child's NS in the authority section. |
| - r.Authorities = []dnsmessage.Resource{{ |
| - Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName("shop.example.co.uk."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| - Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName("ns.shop.example.co.uk.")}, |
| - }} |
| - return true |
| - }) |
| - child := startAuthority(t, "shop.example.co.uk", authoritative(aRecord("shop.example.co.uk.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "example.co.uk": {"ns.example.co.uk."}, |
| - "shop.example.co.uk": {"ns.shop.example.co.uk."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.example.co.uk": {"192.0.2.20"}, |
| - "ns.shop.example.co.uk": {"192.0.2.21"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.20:53": parent, "192.0.2.21:53": child}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.example.co.uk") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the sub-zone's own answer", ips, err) |
| - } |
| - if parent.queries.Load() == 0 { |
| - t.Fatal("the parent zone was never asked") |
| - } |
| - nameAfterParents(t, w, "shop.example.co.uk") |
| -} |
| - |
| -// The parent zone's servers are silent: the walk still reaches the name |
| -// itself, after the parents, and the whole lookup stays inside Timeout. |
| -func TestFreshResolverFallsToTheNameWhenParentsAreSilent(t *testing.T) { |
| - silent := startAuthority(t, "example.com", nil) |
| - child := startAuthority(t, "shop.example.com", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "example.com": {"ns1.example.com."}, |
| - "shop.example.com": {"ns.shop.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns1.example.com": {"192.0.2.53"}, |
| - "ns.shop.example.com": {"192.0.2.54"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.53:53": silent, "192.0.2.54:53": child}, |
| - } |
| - r := w.resolver(clock()) |
| - start := time.Now() |
| - ips, err := r.Resolve("shop.example.com") |
| - if took := time.Since(start); took > r.Timeout+500*time.Millisecond { |
| - t.Fatalf("Resolve took %s, past Timeout %s", took, r.Timeout) |
| - } |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the name's own zone's answer", ips, err) |
| - } |
| - if silent.queries.Load() == 0 { |
| - t.Fatal("the parent zone was never asked") |
| - } |
| - nameAfterParents(t, w, "shop.example.com") |
| -} |
| - |
| -// With every parent level silent and nothing at the name either, the walk |
| -// gives up within Timeout. |
| -func TestFreshResolverSilentEverywhereStaysInsideTimeout(t *testing.T) { |
| - silent := startAuthority(t, "", nil) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "a.b.example.com": {"ns.a.b.example.com."}, |
| - "b.example.com": {"ns.b.example.com."}, |
| - "example.com": {"ns.example.com."}, |
| - "x.a.b.example.com": {"ns.x.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.a.b.example.com": {"192.0.2.1", "192.0.2.2"}, |
| - "ns.b.example.com": {"192.0.2.3", "192.0.2.4"}, |
| - "ns.example.com": {"192.0.2.5", "192.0.2.6"}, |
| - "ns.x.example.com": {"192.0.2.7"}, |
| - }, |
| - routes: map[string]*fakeAuthority{}, |
| - } |
| - for _, a := range []string{"192.0.2.1:53", "192.0.2.2:53", "192.0.2.3:53", "192.0.2.4:53", "192.0.2.5:53", "192.0.2.6:53", "192.0.2.7:53"} { |
| - w.routes[a] = silent |
| - } |
| - r := w.resolver(clock()) |
| - start := time.Now() |
| - if _, err := r.Resolve("x.a.b.example.com"); err == nil { |
| - t.Fatal("Resolve against silent servers succeeded") |
| - } |
| - if took := time.Since(start); took > r.Timeout+500*time.Millisecond { |
| - t.Fatalf("Resolve took %s, past Timeout %s", took, r.Timeout) |
| - } |
| -} |
| - |
| -// The name-itself attempt has its own allowance: parents that use up |
| -// freshMaxZones (each with an NS set, none holding the name) do not stop |
| -// the walk from trying the name as its own zone. |
| -func TestFreshResolverTriesTheNameAfterTheZoneBudget(t *testing.T) { |
| - refusing := startAuthority(t, "", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.RCode = dnsmessage.RCodeRefused |
| - return true |
| - }) |
| - child := startAuthority(t, "x.a.b.c.example.com", authoritative(aRecord("x.a.b.c.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "a.b.c.example.com": {"ns.p.example.net."}, |
| - "b.c.example.com": {"ns.p.example.net."}, |
| - "c.example.com": {"ns.p.example.net."}, |
| - "example.com": {"ns.p.example.net."}, |
| - "x.a.b.c.example.com": {"ns.x.example.net."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.p.example.net": {"192.0.2.30"}, |
| - "ns.x.example.net": {"192.0.2.31"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.30:53": refusing, "192.0.2.31:53": child}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("x.a.b.c.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the name's own zone's answer", ips, err) |
| - } |
| +func nxdomainAnswer(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative = true |
| + r.RCode = dnsmessage.RCodeNameError |
| + return true |
| } |
| -// A parent level the cache knows to be an alias is still skipped: its |
| -// (silent) servers are never dialled. |
| -func TestFreshResolverSkipsAnAliasedParent(t *testing.T) { |
| - silent := startAuthority(t, "oldprovider.net", nil) |
| - right := startAuthority(t, "example.com", authoritative(aRecord("www.shop.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "shop.example.com": {"ns.oldprovider.net."}, |
| - "example.com": {"ns1.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.oldprovider.net": {"192.0.2.9", "192.0.2.10"}, |
| - "ns1.example.com": {"192.0.2.53"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.9:53": silent, "192.0.2.10:53": silent, "192.0.2.53:53": right}, |
| - cnames: map[string]string{"shop.example.com": "old-provider.net."}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("www.shop.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| - } |
| - for _, d := range w.dialed { |
| - if d != "192.0.2.53:53" { |
| - t.Fatalf("dialled %v, want only the real zone's server", w.dialed) |
| - } |
| - } |
| -} |
| - |
| -// referral answers every non-SOA query like a parent that has delegated the |
| -// name away: no authority, an NS record in the authority section. |
| -func referral(child string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| +// referral answers every non-SOA query as a parent that delegated child: |
| +// no authority, child's NS record (host ns.<child>) in the authority |
| +// section, and glue for it when glueIP is set. |
| +func referral(child, glueIP string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| return func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| r.Authorities = []dnsmessage.Resource{{ |
| Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(child + "."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName("ns." + child + ".")}, |
| }} |
| + if glueIP != "" { |
| + r.Additionals = []dnsmessage.Resource{aRecord("ns."+child+".", glueIP)} |
| + } |
| return true |
| } |
| } |
| -// Astra R1 P2-1 on #724 follow-up: a nonexistent INTERMEDIATE label is |
| -// primed just like the name (RFC 8020 NXDOMAIN cuts deny every descendant). |
| -// The registrable domain is asked first, so neither shop.eu.example.com nor |
| -// eu.example.com reaches the cache when example.com answers. |
| -func TestFreshResolverNestedNameAsksTheRegistrableDomainFirst(t *testing.T) { |
| +func TestRegistrableDomain(t *testing.T) { |
| + for name, want := range map[string]string{ |
| + "example.com": "example.com", |
| + "shop.example.com": "example.com", |
| + "shop.eu.example.com": "example.com", |
| + "shop.co.uk": "shop.co.uk", |
| + "shop.example.co.uk": "example.co.uk", |
| + "shop.api.eu.github.io": "github.io", // private PSL rules climbed past |
| + "shop.api.missing.eu.compute.amazonaws.com": "amazonaws.com", |
| + "shop.example.foo.ck": "example.foo.ck", // ICANN wildcard *.ck |
| + "shop.example.test": "example.test", // unlisted TLD |
| + "co.uk": "", |
| + } { |
| + got, ok := domains.RegistrableDomain(name) |
| + if want == "" && ok || want != "" && got != want { |
| + t.Errorf("RegistrableDomain(%s) = %q, %v; want %q", name, got, ok, want) |
| + } |
| + } |
| +} |
| + |
| +// #724 / Astra R1 P2-1: a nonexistent intermediate label (eu.example.com) |
| +// is primed just like the name, and RFC 8020 NXDOMAIN cuts deny every |
| +// descendant. The registrable domain answers for the whole path, so the |
| +// cache hears about neither. |
| +func TestFreshResolverNestedNameWithAMissingIntermediate(t *testing.T) { |
| cases := map[string]struct { |
| answer func(dnsmessage.Question, *dnsmessage.Message) bool |
| found bool |
| }{ |
| - "record absent": {func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.Authoritative = true |
| - r.RCode = dnsmessage.RCodeNameError |
| - return true |
| - }, false}, |
| + "record absent": {nxdomainAnswer, false}, |
| "record present": {authoritative(cnameRecord("shop.eu.example.com.", "edge.oncarlos.test.")), true}, |
| } |
| for name, tc := range cases { |
| t.Run(name, func(t *testing.T) { |
| - fa := startAuthority(t, "example.com", tc.answer) |
| - w := oneZone(fa) |
| + w := oneZone(startAuthority(t, "example.com", tc.answer)) |
| ips, err := w.resolver(clock()).Resolve("shop.eu.example.com") |
| if tc.found && (err != nil || len(ips) != 1 || ips[0] != edgeIP) { |
| t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| @@ -816,211 +539,239 @@ func TestFreshResolverNestedNameAsksTheRegistrableDomainFirst(t *testing.T) { |
| if !tc.found && !isNotFoundErr(err) { |
| t.Fatalf("Resolve error = %v, want the authoritative not-found", err) |
| } |
| - for _, n := range []string{"shop.eu.example.com", "eu.example.com"} { |
| - if c := w.cachedFor(n); c != 0 { |
| - t.Fatalf("cached resolver asked about %s %d times (%v), want 0", n, c, w.cached) |
| - } |
| + noCachedBelow(t, w, "shop.eu.example.com", "example.com") |
| + }) |
| + } |
| +} |
| + |
| +// Astra R2 P1-2: public-suffix entries outside the ICANN section, and |
| +// wildcard rules, do not prove the label below them exists. The walk |
| +// starts at the ICANN registrable domain, and the absent labels between |
| +// it and the name never reach the cache. |
| +func TestFreshResolverPrivateAndWildcardSuffixes(t *testing.T) { |
| + for name, reg := range map[string]string{ |
| + "shop.api.eu.github.io": "github.io", |
| + "shop.api.missing.eu.compute.amazonaws.com": "amazonaws.com", |
| + "shop.example.foo.ck": "example.foo.ck", |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + fa := startAuthority(t, reg, nxdomainAnswer) |
| + w := &world{ |
| + ns: map[string][]string{reg: {"ns1." + reg + "."}}, |
| + hosts: map[string][]string{"ns1." + reg: {"192.0.2.53"}}, |
| + routes: map[string]*fakeAuthority{"192.0.2.53:53": fa}, |
| + } |
| + if _, err := w.resolver(clock()).Resolve(name); !isNotFoundErr(err) { |
| + t.Fatalf("Resolve error = %v, want the authoritative not-found", err) |
| } |
| + noCachedBelow(t, w, name, reg) |
| }) |
| } |
| } |
| -// eu.example.com is a delegated child zone: the registrable domain only |
| -// refers down, and the walk finds the child. |
| -func TestFreshResolverNestedNameInADelegatedChildZone(t *testing.T) { |
| - parent := startAuthority(t, "example.com", referral("eu.example.com")) |
| - child := startAuthority(t, "eu.example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| +// shop.co.uk is its own registrable domain: it is asked directly, and |
| +// co.uk never is. |
| +func TestFreshResolverNameUnderAnICANNSuffix(t *testing.T) { |
| + fa := startAuthority(t, "shop.co.uk", authoritative(aRecord("shop.co.uk.", edgeIP))) |
| w := &world{ |
| - ns: map[string][]string{ |
| - "example.com": {"ns1.example.com."}, |
| - "eu.example.com": {"ns.eu.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns1.example.com": {"192.0.2.53"}, |
| - "ns.eu.example.com": {"192.0.2.40"}, |
| - "edge.oncarlos.test": {edgeIP}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.53:53": parent, "192.0.2.40:53": child}, |
| + ns: map[string][]string{"shop.co.uk": {"ns.provider.net."}}, |
| + hosts: map[string][]string{"ns.provider.net": {"192.0.2.61"}}, |
| + routes: map[string]*fakeAuthority{"192.0.2.61:53": fa}, |
| } |
| - ips, err := w.resolver(clock()).Resolve("shop.eu.example.com") |
| + ips, err := w.resolver(clock()).Resolve("shop.co.uk") |
| if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the child zone's answer", ips, err) |
| + t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| } |
| - if w.cachedFor("shop.eu.example.com") != 0 { |
| - t.Fatalf("cached resolver asked about the name: %v", w.cached) |
| + if w.cachedFor("co.uk") != 0 { |
| + t.Fatalf("asked the cache about co.uk: %v", w.cached) |
| } |
| } |
| -// The registrable domain's servers are silent: the lookup falls through to |
| -// the walk, which does not ask the registrable domain a second time, and |
| -// stays inside Timeout. |
| -func TestFreshResolverSilentRegistrableDomainFallsThrough(t *testing.T) { |
| - silent := startAuthority(t, "example.com", nil) |
| - child := startAuthority(t, "eu.example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "example.com": {"ns1.example.com."}, |
| - "eu.example.com": {"ns.eu.example.com."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns1.example.com": {"192.0.2.53"}, |
| - "ns.eu.example.com": {"192.0.2.40"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.53:53": silent, "192.0.2.40:53": child}, |
| - } |
| - r := w.resolver(clock()) |
| - start := time.Now() |
| - ips, err := r.Resolve("shop.eu.example.com") |
| - if took := time.Since(start); took > r.Timeout+500*time.Millisecond { |
| - t.Fatalf("Resolve took %s, past Timeout %s", took, r.Timeout) |
| - } |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the child zone's answer", ips, err) |
| - } |
| - if n := silent.queries.Load(); n != 1 { |
| - t.Fatalf("the registrable domain's server got %d queries, want 1 (asked once, not again by the walk)", n) |
| +// eu.example.com is a delegated child zone: example.com refers down, the |
| +// child is verified and answers. Its nameserver comes from glue when it is |
| +// inside the child (the cache would be asked about a label below the |
| +// registrable domain otherwise) and from the cache when it is not. |
| +func TestFreshResolverFollowsAReferralToTheChildZone(t *testing.T) { |
| + for _, tc := range []struct { |
| + name, nsHost, glue string |
| + }{ |
| + {"in-zone nameserver, glue", "ns.eu.example.com", "192.0.2.40"}, |
| + {"out-of-zone nameserver, cache", "ns.provider.net", ""}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + child := startAuthority(t, "eu.example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| + parent := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authorities = []dnsmessage.Resource{{ |
| + Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName("eu.example.com."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| + Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName(tc.nsHost + ".")}, |
| + }} |
| + if tc.glue != "" { |
| + r.Additionals = []dnsmessage.Resource{aRecord(tc.nsHost+".", tc.glue)} |
| + } |
| + return true |
| + }) |
| + w := oneZone(parent) |
| + w.hosts["ns.provider.net"] = []string{"192.0.2.40"} |
| + w.routes["192.0.2.40:53"] = child |
| + ips, err := w.resolver(clock()).Resolve("shop.eu.example.com") |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("Resolve = %v, %v; want the child zone's answer", ips, err) |
| + } |
| + if child.queries.Load() < 2 { |
| + t.Fatalf("child got %d queries, want its SOA verified and then the A", child.queries.Load()) |
| + } |
| + noCachedBelow(t, w, "shop.eu.example.com", "example.com") |
| + }) |
| } |
| } |
| -// Where the walk already starts at the registrable domain (the name is an |
| -// apex, a name under a public suffix like co.uk, or a direct child of its |
| -// registrable domain) there is no separate first step: each level is asked |
| -// once, nearest parent first. |
| -func TestFreshResolverRegistrableStepSkippedWhereTheWalkCoversIt(t *testing.T) { |
| - t.Run("apex", func(t *testing.T) { |
| - silent := startAuthority(t, "example.com", nil) |
| - w := oneZone(silent) |
| - if _, err := w.resolver(clock()).Resolve("example.com"); err == nil { |
| - t.Fatal("Resolve against a silent apex succeeded") |
| - } |
| - if n := silent.queries.Load(); n != 1 { |
| - t.Fatalf("apex server got %d queries, want 1", n) |
| - } |
| - }) |
| - t.Run("under a public suffix", func(t *testing.T) { |
| - suffix := startAuthority(t, "co.uk", nil) |
| - apex := startAuthority(t, "shop.co.uk", authoritative(aRecord("shop.co.uk.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "co.uk": {"ns.co.uk."}, |
| - "shop.co.uk": {"ns.shop.co.uk."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns.co.uk": {"192.0.2.60"}, |
| - "ns.shop.co.uk": {"192.0.2.61"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.60:53": suffix, "192.0.2.61:53": apex}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.co.uk") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edgeIP) |
| - } |
| - if len(w.dialed) == 0 || w.dialed[0] != "192.0.2.60:53" { |
| - t.Fatalf("dialled %v, want co.uk's server first", w.dialed) |
| - } |
| - nameAfterParents(t, w, "shop.co.uk") |
| - }) |
| - t.Run("direct child", func(t *testing.T) { |
| - silent := startAuthority(t, "example.com", nil) |
| - w := oneZone(silent) |
| - if _, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| - t.Fatal("Resolve against a silent zone succeeded") |
| - } |
| - if n := silent.queries.Load(); n != 1 { |
| - t.Fatalf("example.com's server got %d queries, want 1", n) |
| +// A referral is only followed DOWN the name's path. Sideways, upward, to |
| +// the same zone (a loop) or below the name: refused, and the server it |
| +// names is never dialled. |
| +func TestFreshResolverRefusesAReferralOffThePath(t *testing.T) { |
| + for _, child := range []string{"other.example.com", "com", "example.com", "x.shop.example.com", "example.net"} { |
| + t.Run(child, func(t *testing.T) { |
| + hostile := startAuthority(t, "", authoritative(aRecord("shop.example.com.", edgeIP))) |
| + w := oneZone(startAuthority(t, "example.com", referral(child, "192.0.2.66"))) |
| + w.hosts["ns."+child] = []string{"192.0.2.66"} |
| + w.routes["192.0.2.66:53"] = hostile |
| + if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want a refusal of the referral to %s", ips, child) |
| + } |
| + if hostile.queries.Load() != 0 { |
| + t.Fatalf("followed the referral to %s: dialled %v", child, w.dialed) |
| + } |
| + }) |
| + } |
| + // A child that refers back up to its parent: a loop, refused. |
| + t.Run("child refers back up", func(t *testing.T) { |
| + child := startAuthority(t, "eu.example.com", referral("example.com", "192.0.2.53")) |
| + w := oneZone(startAuthority(t, "example.com", referral("eu.example.com", "192.0.2.40"))) |
| + w.routes["192.0.2.40:53"] = child |
| + if ips, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want the loop refused", ips) |
| } |
| }) |
| } |
| -// finalAttemptWorld has example.com only refer down, so shop.example.com is |
| -// decided by the last, name-itself attempt, whose NS set leads to hostile. |
| -func finalAttemptWorld(t *testing.T, hostile *fakeAuthority) *world { |
| - t.Helper() |
| - parent := startAuthority(t, "example.com", referral("shop.example.com")) |
| - return &world{ |
| - ns: map[string][]string{ |
| - "example.com": {"ns1.example.com."}, |
| - "shop.example.com": {"ns.oldprovider.net."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns1.example.com": {"192.0.2.53"}, |
| - "ns.oldprovider.net": {"192.0.2.9"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.53:53": parent, "192.0.2.9:53": hostile}, |
| +// Delegation deeper than freshMaxZones referrals fails closed: the zone |
| +// past the bound is never asked. |
| +func TestFreshResolverBoundsTheReferrals(t *testing.T) { |
| + name := "shop.a.b.c.d.example.com" |
| + zones := []string{"example.com", "d.example.com", "c.d.example.com", "b.c.d.example.com", "a.b.c.d.example.com"} |
| + w := &world{ |
| + ns: map[string][]string{"example.com": {"ns1.example.com."}}, |
| + hosts: map[string][]string{"ns1.example.com": {"192.0.2.10"}}, |
| + routes: map[string]*fakeAuthority{}, |
| + } |
| + var last *fakeAuthority |
| + for i, z := range zones { |
| + addr := fmt.Sprintf("192.0.2.%d", 10+i) |
| + var fa *fakeAuthority |
| + if i+1 < len(zones) { |
| + fa = startAuthority(t, z, referral(zones[i+1], fmt.Sprintf("192.0.2.%d", 11+i))) |
| + } else { |
| + fa = startAuthority(t, z, authoritative(aRecord(name+".", edgeIP))) |
| + last = fa |
| + } |
| + w.routes[addr+":53"] = fa |
| + } |
| + if ips, err := w.resolver(clock()).Resolve(name); err == nil { |
| + t.Fatalf("Resolve = %v, want delegation past the bound refused", ips) |
| + } |
| + if last.queries.Load() != 0 { |
| + t.Fatal("asked the zone past the referral bound") |
| } |
| } |
| -// Astra R1 P2-2 on #724 follow-up: the name-itself attempt is where a |
| -// cached CNAME can hand LookupNS another zone's servers. It must verify the |
| -// zone like every other attempt: an authoritative-looking positive answer |
| -// from a server that does not hold the name is refused. |
| -func TestFreshResolverFinalAttemptNeverTrustsAWrongZoneServer(t *testing.T) { |
| - wrong := startAuthority(t, "oldprovider.net", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - w := finalAttemptWorld(t, wrong) |
| - if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| - t.Fatalf("Resolve = %v, want a refusal of the wrong zone's answer", ips) |
| +// Astra R2 P2: every zone is verified before it is trusted, the |
| +// registrable domain's and a referred child's alike. A server for another |
| +// zone, or one whose SOA is owned by another name, offers an |
| +// authoritative-looking positive answer; it is reached, and refused. |
| +func TestFreshResolverVerifiesEveryZone(t *testing.T) { |
| + hostiles := map[string]func(t *testing.T) *fakeAuthority{ |
| + "wrong zone": func(t *testing.T) *fakeAuthority { |
| + return startAuthority(t, "oldprovider.net", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| + }, |
| + "SOA owner mismatch": func(t *testing.T) *fakeAuthority { |
| + return startAuthority(t, "", func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative = true |
| + if q.Type == dnsmessage.TypeSOA { |
| + r.Answers = []dnsmessage.Resource{soaRecord("example.net")} |
| + return true |
| + } |
| + r.Answers = []dnsmessage.Resource{aRecord("shop.eu.example.com.", edgeIP)} |
| + return true |
| + }) |
| + }, |
| } |
| - if wrong.queries.Load() == 0 { |
| - t.Fatal("the final attempt never reached the wrong-zone server") |
| + for kind, mk := range hostiles { |
| + t.Run(kind+" at the registrable domain", func(t *testing.T) { |
| + hostile := mk(t) |
| + w := oneZone(hostile) |
| + if ips, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want the unverified answer refused", ips) |
| + } |
| + if hostile.queries.Load() == 0 { |
| + t.Fatal("the hostile server was never reached") |
| + } |
| + }) |
| + t.Run(kind+" at a referred child", func(t *testing.T) { |
| + hostile := mk(t) |
| + w := oneZone(startAuthority(t, "example.com", referral("eu.example.com", "192.0.2.40"))) |
| + w.routes["192.0.2.40:53"] = hostile |
| + if ips, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want the unverified answer refused", ips) |
| + } |
| + if hostile.queries.Load() == 0 { |
| + t.Fatal("the hostile server was never reached") |
| + } |
| + }) |
| } |
| } |
| -// The same, for a server whose SOA is owned by another name. |
| -func TestFreshResolverFinalAttemptVerifiesTheSOAOwner(t *testing.T) { |
| - sloppy := startAuthority(t, "", func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| - r.Authoritative = true |
| - if q.Type == dnsmessage.TypeSOA { |
| - r.Answers = []dnsmessage.Resource{soaRecord("example.com")} |
| - return true |
| - } |
| - r.Answers = []dnsmessage.Resource{aRecord("shop.example.com.", edgeIP)} |
| - return true |
| - }) |
| - w := finalAttemptWorld(t, sloppy) |
| - if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| - t.Fatalf("Resolve = %v, want a refusal: the SOA is not shop.example.com's", ips) |
| +// Glue is tenant input like any nameserver address: a non-public one is |
| +// never dialled. |
| +func TestFreshResolverNeverDialsNonPublicGlue(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", referral("eu.example.com", "10.0.0.5"))) |
| + if _, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatal("Resolve succeeded") |
| } |
| - if sloppy.queries.Load() == 0 { |
| - t.Fatal("the final attempt never reached the sloppy server") |
| + for _, d := range w.dialed { |
| + if d != "192.0.2.53:53" { |
| + t.Fatalf("dialled %v", w.dialed) |
| + } |
| } |
| } |
| -// A name the cache knows to be an alias is not a zone, on the final attempt |
| -// too: its servers are never dialled. |
| -func TestFreshResolverFinalAttemptSkipsAnAliasedName(t *testing.T) { |
| - hostile := startAuthority(t, "oldprovider.net", authoritative(aRecord("shop.example.com.", edgeIP))) |
| - w := finalAttemptWorld(t, hostile) |
| - w.cnames = map[string]string{"shop.example.com": "old-provider.net."} |
| - if ips, err := w.resolver(clock()).Resolve("shop.example.com"); err == nil { |
| - t.Fatalf("Resolve = %v, want an error", ips) |
| +// The registrable domain's servers are silent: the lookup fails inside |
| +// Timeout and nothing below the registrable domain reaches the cache. |
| +func TestFreshResolverSilentRegistrableFailsInsideTimeout(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", nil)) |
| + w.hosts["ns1.example.com"] = []string{"192.0.2.53", "192.0.2.54"} |
| + w.routes["192.0.2.54:53"] = w.routes["192.0.2.53:53"] |
| + r := w.resolver(clock()) |
| + start := time.Now() |
| + if _, err := r.Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatal("Resolve against silent servers succeeded") |
| } |
| - if hostile.queries.Load() != 0 { |
| - t.Fatalf("dialled the aliased name's servers: %v", w.dialed) |
| + if took := time.Since(start); took > r.Timeout+500*time.Millisecond { |
| + t.Fatalf("Resolve took %s, past Timeout %s", took, r.Timeout) |
| } |
| + noCachedBelow(t, w, "shop.eu.example.com", "example.com") |
| } |
| -// The registrable domain is silent and the intermediate label is not a |
| -// zone: the walk passes over the registrable domain rather than spend the |
| -// deadline asking it again, and the name's own zone answers. |
| -func TestFreshResolverWalkDoesNotReaskTheRegistrableDomain(t *testing.T) { |
| - silent := startAuthority(t, "example.com", nil) |
| - apex := startAuthority(t, "shop.eu.example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| - w := &world{ |
| - ns: map[string][]string{ |
| - "example.com": {"ns1.example.com."}, |
| - "shop.eu.example.com": {"ns.shop.example.net."}, |
| - }, |
| - hosts: map[string][]string{ |
| - "ns1.example.com": {"192.0.2.53"}, |
| - "ns.shop.example.net": {"192.0.2.41"}, |
| - }, |
| - routes: map[string]*fakeAuthority{"192.0.2.53:53": silent, "192.0.2.41:53": apex}, |
| - } |
| - ips, err := w.resolver(clock()).Resolve("shop.eu.example.com") |
| - if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| - t.Fatalf("Resolve = %v, %v; want the name's own zone's answer", ips, err) |
| +// Forget ends a name's backoff: the next Resolve asks again. |
| +func TestFreshResolverForgetEndsTheBackoff(t *testing.T) { |
| + fa := startAuthority(t, "example.com", nil) |
| + r := oneZone(fa).resolver(clock()) |
| + if _, err := r.Resolve("shop.example.com"); err == nil { |
| + t.Fatal("Resolve against a dead server succeeded") |
| } |
| - if n := silent.queries.Load(); n != 1 { |
| - t.Fatalf("the registrable domain's server got %d queries, want 1", n) |
| + sent := fa.queries.Load() |
| + r.Forget("Shop.Example.com.") |
| + _, _ = r.Resolve("shop.example.com") |
| + if fa.queries.Load() == sent { |
| + t.Fatal("Resolve after Forget did not ask again") |
| } |
| } |
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go| index b11a9b879..ca9a5ce12 100644 |
| --- a/internal/domains/reconcile.go |
| +++ b/internal/domains/reconcile.go |
| @@ -45,6 +45,10 @@ type Config struct { |
| // ResolveFresh asks without any cache (#724); see dnsVerdicts. nil |
| // leaves every verdict to Resolve alone. |
| ResolveFresh func(host string) ([]string, error) |
| + // FreshForget ends ResolveFresh's failure backoff for a host (the same |
| + // resolver's Forget); dnsVerdicts calls it when a name it looked at |
| + // fresh before publication is published. nil skips that. |
| + FreshForget func(host string) |
| // AcmeDir is the edge's autocert DirCache directory; "" skips TLS |
| // stamping entirely. |
| AcmeDir string |
| @@ -666,6 +670,22 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) |
| upgrades = append(upgrades, c) |
| } |
| } |
| + // INVARIANT (Astra R2 on #724): a fresh failure recorded while a name |
| + // was unpublished never suppresses a look after it is published. A |
| + // fresh-first name that ends this pass "pointing", by the fresh look or |
| + // the cached fallback, has its backoff cleared, so its next upgrade look |
| + // is really sent. A failure recorded while the name is published (an |
| + // upgrade look) still backs off as before. |
| + defer func() { |
| + if cfg.FreshForget == nil { |
| + return |
| + } |
| + for _, c := range firsts { |
| + if *c.status == "pointing" { |
| + cfg.FreshForget(c.host) |
| + } |
| + } |
| + }() |
| rand.Shuffle(len(upgrades), func(i, j int) { upgrades[i], upgrades[j] = upgrades[j], upgrades[i] }) |
| rand.Shuffle(len(firsts), func(i, j int) { firsts[i], firsts[j] = firsts[j], firsts[i] }) |
| pending := append(upgrades, firsts...) |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 60fca0784..454731a0e 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -3822,15 +3822,17 @@ func domainsTickConfig(getenv func(string) string, publicIP string) (domains.Con |
| AcmeDir: filepath.Join(dd, "acme"), |
| Now: time.Now, |
| Resolve: resolveHost, |
| - // #724: the uncached second look, for a customer hostname the |
| - // cached answer says does not point here yet. The cached resolver |
| - // still finds the zone's nameservers and our own CNAME target. |
| - ResolveFresh: (&domains.FreshResolver{ |
| - LookupNS: net.DefaultResolver.LookupNS, |
| - LookupHost: net.DefaultResolver.LookupHost, |
| - LookupCNAME: net.DefaultResolver.LookupCNAME, |
| - }).Resolve, |
| } |
| + // #724: the uncached look, first for a customer hostname that is not |
| + // published yet and as a second look for one whose cached answer stops |
| + // pointing here. The cached resolver only finds the registrable |
| + // domain's nameservers, nameserver addresses and our own CNAME target. |
| + fresh := &domains.FreshResolver{ |
| + LookupNS: net.DefaultResolver.LookupNS, |
| + LookupHost: net.DefaultResolver.LookupHost, |
| + } |
| + cfg.ResolveFresh = fresh.Resolve |
| + cfg.FreshForget = fresh.Forget |
| // EdgeIPs is deliberately left nil here — a Config out of this function |
| // alone stamps nothing. domainsLoop installs the fold once it has a |
| // store; see the doc comment. |
diff --git a/internal/host/host_test.go b/internal/host/host_test.go| index c52acf253..09be8bf0f 100644 |
| --- a/internal/host/host_test.go |
| +++ b/internal/host/host_test.go |
| @@ -772,8 +772,8 @@ func TestDomainsTickConfig(t *testing.T) { |
| } |
| // #724: the uncached second look for a customer's hostname is wired in |
| // production, not only in the domains tests. |
| - if got.ResolveFresh == nil { |
| - t.Error("ResolveFresh not populated on a configured deployment") |
| + if got.ResolveFresh == nil || got.FreshForget == nil { |
| + t.Error("ResolveFresh/FreshForget not populated on a configured deployment") |
| } |
| // No explicit edge IPs: the box's own public IP (IMDS) is the default. |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 87b325dbf..4ea615b9a 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -144,4 +144,4 @@ plan14-root-reads-deploy-edge-718.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f |
| plan14-root-reads-demo-slice-adopt.tsv 707018faaa1fee3b47abb78389ae7854264e76621cc316889061adb69bf13e10 |
| plan14-root-reads-security-review-mitigations.tsv a6f3f9eec4aac5ea88f20d0e52eaa0651fce80c0d49b60883ff61ceade33d288 |
| plan14-root-reads-cli-registry-words.tsv 8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6 |
| -plan14-root-reads-no-negative-prime-724.tsv 1fc14572275cc3e3fc7a889f4672d867dc3982204c8909cd87a60024f0909829 |
| +plan14-root-reads-no-negative-prime-724.tsv 638b1b2c6720713927139989c74a0f133de77f765df4e3a0c0a333137582b2ca |
diff --git a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv| index bb3b5cd0b..a5f3f61b5 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv |
| @@ -1,5 +1,13 @@ |
| # Census overlay no-negative-prime-724, written by census-propose (#369). census-ruling-no-negative-prime-724, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-no-negative-prime-724.md. |
| -# 0 body, 1 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -@legacy 67e3f48ab223547023032d72333a170328d9127bd9c26afd6f8c360cfcf5f6e8 internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f |
| -internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f |
| -@coverage internal/domains 465f93499339830fad65dce7feacc563fb7f6df3c3591f297d48e55e6877ad8c |
| +# 1 body, 1 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| +@legacy 727531fde7bbe7f11167a33b377ce1582223f96714e712f7c5d1342e90697a50 internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 133e8f1ce245512bb3a8b5e0fddb32e86fcc0afe39c0e12cff4a4debf2f6366e |
| +@legacy 5d212a8ac7796a96174c8f1eb2aa31288c958ad7ec7bbd1705715a2577614e34 internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| +@legacy 47d88f7e405dfbee51b1270d2d0c22c35a29bc750806a9955847be63b25310dd internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f |
| +internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 133e8f1ce245512bb3a8b5e0fddb32e86fcc0afe39c0e12cff4a4debf2f6366e |
| +internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| +internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f |
| +@remove internal/domains/freshdns.go FreshResolver.exchange |
| +@removed internal/domains/freshdns.go FreshResolver.exchange H3 census-ruling-no-negative-prime-724;basis=quiet: now a wrapper over query that keeps the authority and truncation checks; its socket read moved to FreshResolver.query (#724) |
| +@coverage internal/domains 5d57b36e2d02560f18b9ab1df42f88f8f1d58e7c46d233af7ac8f669bd448321 |
| +@coverage internal/host 401b918c04add12a03702679ba47fdf8cbad5139586ab505aef86b029149855b |