carlos / platform Public

console: steering CNAME for subdomains under configured ingress

With CONSOLE_REGION_INGRESS set, a non-apex custom domain is still told
to CNAME at the steering hostname (edge.<apps-domain>) where the
deployment steers, with the ingress union as its A alternative; apex
domains keep the ingress A-record advice. Before, configured ingress
dropped the CNAME and advised A records to fixed IPs, which blocked the
G3 retry. The steering host holds fixed boxes only (G3-F4) and, until
the load balancer is the public front door (G5), the same addresses as
the ingress set. Domains-door rows, catch-all heads included, gain an
additive cname_target. Tests drive the domains verifier and cert-warm
gate through a real resolver against a CNAME chain.

Per-app CNAME targets were reviewed for three Astra rounds and cut by
8a3d302 (option 1); they return on a verified DNS path after G3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from cname-app-host into main.
claude agent, operated by paul@keymail.dev 1751f78fa19f2fefeb3c41988212df75ff0a0f22 parent b2f42c1
9 files changed, +429 −11
  • internal/console/apidomains.go +7 −0
  • internal/console/domaincatchall.go +1 −0
  • internal/console/domainstate.go +2 −3
  • internal/console/server.go +12 −1
  • internal/console/steering_ingress_test.go +169 −0
  • internal/console/view.go +19 −6
  • internal/domains/cname_steering_test.go +114 −0
  • internal/edge/cname_steering_test.go +104 −0
  • internal/provision/plan9_b8_census_test.go +1 −1

CI passed — run details

diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go
index e127ee3d3..18ef11bff 100644
--- a/internal/console/apidomains.go
+++ b/internal/console/apidomains.go
@@ -1266,6 +1266,12 @@ type domainListItem struct {
DNSStatus string `json:"dns_status,omitempty"`
CertExpiresAt int64 `json:"cert_expires_at,omitempty"`
Guidance string `json:"guidance,omitempty"`
+ // CNAMETarget is the name Guidance tells the member to CNAME this host
+ // at (cnameTarget, view.go): the deployment's steering hostname, set
+ // exactly when Records carries the CNAME alternative. Omitted for an
+ // apex, for A-record-only advice and when there is nothing to do.
+ // Additive.
+ CNAMETarget string `json:"cname_target,omitempty"`
// Wildcard and Catchall (Task 5) copy the claim's own capability bits
// verbatim — always present, true or false, the same "known state"
// convention Created/Removed use on the attach/detach answers (never
@@ -1462,6 +1468,7 @@ func (s *Server) domainItem(ctx context.Context, c domains.Claim, readings map[s
// same condition so the two can never disagree about whether there is
// anything for the member to do.
item.Records = domainRecords(c.Host, targets, c.Wildcard, s.delegationZone)
+ item.CNAMETarget = cnameTarget(c.Host, targets)
}
if c.Pending {
// The proof record, in BOTH forms, under the same lockstep rule as
diff --git a/internal/console/domaincatchall.go b/internal/console/domaincatchall.go
index 60130c380..de9752f53 100644
--- a/internal/console/domaincatchall.go
+++ b/internal/console/domaincatchall.go
@@ -363,6 +363,7 @@ func (s *Server) catchallListItems(ctx context.Context, acct *Account, app strin
// guidance for "*.<parent>" says exactly that.
head.Guidance = domainGuidance(c.Host, targets)
head.Records = domainRecords(c.Host, targets, false, "")
+ head.CNAMETarget = cnameTarget(c.Host, targets)
}
// Whether the catch-all reserves every label, or only its instances'
// (catchallInstanceName). Said on every listing, with the record to
diff --git a/internal/console/domainstate.go b/internal/console/domainstate.go
index 27bd52aa4..9c5c304e0 100644
--- a/internal/console/domainstate.go
+++ b/internal/console/domainstate.go
@@ -219,10 +219,9 @@ const domainRecordTTL = 300
// with no records behind it.
func domainRecords(host string, t DNSTargets, wildcard bool, delegationZone string) []dnsRecord {
var out []dnsRecord
- steering := t.SteeringHost != "" && !isApexDomain(host)
- if steering {
+ if target := cnameTarget(host, t); target != "" {
out = append(out, dnsRecord{
- Type: "CNAME", Name: host, Value: t.SteeringHost,
+ Type: "CNAME", Name: host, Value: target,
TTL: domainRecordTTL, Set: "cname",
})
}
diff --git a/internal/console/server.go b/internal/console/server.go
index 8f97287b9..3639f5299 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1634,7 +1634,18 @@ func (s *Server) chrome(p *page) {
// counted against that request (see foldedEdgeIPs).
func (s *Server) dnsTargets(ctx context.Context) DNSTargets {
if len(s.cfg.RegionIngress) > 0 {
- return DNSTargets{EdgeIPs: s.edgeIPs(ctx), ConfiguredIngress: true}
+ // Configured ingress replaces the A-record set, not the steering
+ // CNAME. A subdomain still CNAMEs at the steering hostname where the
+ // deployment steers (8a3d302 ruling, 2026-11-08): the converger keeps
+ // it, it holds fixed boxes only (group members are never steering
+ // targets, G3-F4), and until the load balancer becomes the public
+ // front door (G5) its records are the same fixed addresses the
+ // ingress set names. A records go to the ingress union, as before.
+ var steer string
+ if strings.TrimSpace(s.cfg.AppsDomain) != "" {
+ steer = s.steeringHost
+ }
+ return DNSTargets{EdgeIPs: s.edgeIPs(ctx), ConfiguredIngress: true, SteeringHost: steer}
}
return DNSTargets{EdgeIPs: s.edgeIPs(ctx), SteeringHost: s.steeringHost}
}
diff --git a/internal/console/steering_ingress_test.go b/internal/console/steering_ingress_test.go
new file mode 100644
index 000000000..5cd681782
--- /dev/null
+++ b/internal/console/steering_ingress_test.go
@@ -0,0 +1,169 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// Configured ingress replaces the A-record set, not the steering CNAME
+// (8a3d302 ruling, 2026-11-08): where the deployment steers, a subdomain is
+// still told to CNAME at the steering hostname. Without an apps domain the
+// steering hostname means nothing and is dropped, as before.
+func TestConfiguredIngressKeepsTheSteeringHost(t *testing.T) {
+ for _, c := range []struct {
+ name string
+ s *Server
+ want string
+ }{
+ {"steering with an apps domain", &Server{cfg: Config{AppsDomain: "oncarlos.test", RegionIngress: []string{ingressIP}}, steeringHost: "edge.oncarlos.test"}, "edge.oncarlos.test"},
+ {"no apps domain", &Server{cfg: Config{RegionIngress: []string{ingressIP}}, steeringHost: "edge.oncarlos.test"}, ""},
+ {"no steering", &Server{cfg: Config{AppsDomain: "oncarlos.test", RegionIngress: []string{ingressIP}}}, ""},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ got := c.s.dnsTargets(context.Background())
+ if !got.ConfiguredIngress || got.SteeringHost != c.want {
+ t.Fatalf("dnsTargets = %+v, want ingress with steering host %q", got, c.want)
+ }
+ })
+ }
+}
+
+// Under configured ingress a subdomain gets today's steering-CNAME advice
+// with the ingress union as its A alternative; an apex keeps the ingress
+// A-record advice. Sentence, records and cname_target agree.
+func TestConfiguredIngressGuidanceOffersTheSteeringCNAME(t *testing.T) {
+ s := &Server{cfg: Config{AppsDomain: "oncarlos.test", EdgeIPs: []string{"192.0.2.1"}, RegionIngress: []string{ingressIP}}, steeringHost: "edge.oncarlos.test"}
+ targets := s.dnsTargets(context.Background())
+ union := "192.0.2.1, " + ingressIP
+ for host, want := range map[string]string{
+ "shop.example.com": "Point a CNAME for shop.example.com at edge.oncarlos.test. The steering service chooses a healthy edge. An A record for shop.example.com at " + union + " also works. It distributes requests across the listed edges without choosing by location. Checks run every few minutes.",
+ "*.app.example.com": "Point a CNAME for *.app.example.com at edge.oncarlos.test. The steering service chooses a healthy edge. An A record for *.app.example.com at " + union + " also works. It distributes requests across the listed edges without choosing by location. Checks run every few minutes.",
+ "example.com": "example.com is an apex domain and cannot use a CNAME. Point its A record at the configured public ingress addresses: " + union + ". Checks run every few minutes.",
+ "example.co.uk": "example.co.uk is an apex domain and cannot use a CNAME. Point its A record at the configured public ingress addresses: " + union + ". Checks run every few minutes.",
+ } {
+ if got := domainGuidance(host, targets); got != want {
+ t.Errorf("%s:\n got %q\n want %q", host, got, want)
+ }
+ apex := isApexDomain(host)
+ if got := cnameTarget(host, targets); (got == "") != apex || (!apex && got != "edge.oncarlos.test") {
+ t.Errorf("%s cnameTarget = %q", host, got)
+ }
+ cnames := 0
+ for _, r := range domainRecords(host, targets, false, "") {
+ switch r.Type {
+ case "CNAME":
+ cnames++
+ if r.Value != "edge.oncarlos.test" || r.Set != "cname" {
+ t.Errorf("%s CNAME record %+v", host, r)
+ }
+ case "A":
+ if r.Value != "192.0.2.1" && r.Value != ingressIP {
+ t.Errorf("%s A record %+v outside the ingress union", host, r)
+ }
+ }
+ }
+ if cnames != map[bool]int{true: 0, false: 1}[apex] {
+ t.Errorf("%s: %d CNAME records", host, cnames)
+ }
+ }
+}
+
+// Every kind of row on the domains door names the same CNAME target under
+// configured ingress: an alias of an instance, a first-route claim, an alias
+// of another custom name and an instance catch-all all get the steering
+// hostname, and the apex none. The Settings page says the same.
+func TestDomainDoorsNameTheSteeringHostUnderIngress(t *testing.T) {
+ fx, member := instanceFixture(t, "code-dom-steer-ingress")
+ fx.srv.cfg.AppsDomain = "oncarlos.test"
+ fx.srv.cfg.EdgeIPs = []string{"192.0.2.1"}
+ fx.srv.cfg.RegionIngress = []string{ingressIP}
+ fx.srv.steeringHost = "edge.oncarlos.test"
+ sqid := release.OpsAccount
+ attachShopClaim(t, fx, sqid, "titogo", "shop.example.com", "eu.bab.oncarlos.test")
+ attachShopClaim(t, fx, sqid, "titogo", "first.example.com", "")
+ attachShopClaim(t, fx, sqid, "titogo", "raw.example.com", "example.com")
+ attachShopClaim(t, fx, sqid, "titogo", "example.com", "eu.bab.oncarlos.test")
+ if _, _, err := domains.AttachClaim(context.Background(), fx.rel, domains.Claim{
+ Host: "*.app.example.com", Account: sqid, App: "titogo", Instances: true,
+ CreatedAt: time.Now().UTC().Format(time.RFC3339),
+ }); err != nil {
+ t.Fatal(err)
+ }
+ want := map[string]string{
+ "shop.example.com": "edge.oncarlos.test", "first.example.com": "edge.oncarlos.test",
+ "raw.example.com": "edge.oncarlos.test", "*.app.example.com": "edge.oncarlos.test",
+ "example.com": "",
+ }
+ code, _, out := rawReq(t, http.MethodGet, domainsURL(fx, "bab", "titogo"), member, "")
+ if code != http.StatusOK {
+ t.Fatalf("list = %d %s", code, out)
+ }
+ var got struct {
+ Domains []struct {
+ Host string `json:"host"`
+ Guidance string `json:"guidance"`
+ CNAMETarget string `json:"cname_target"`
+ Records []dnsRecord `json:"records"`
+ } `json:"domains"`
+ Deployment struct {
+ SteeringHost string `json:"steering_host"`
+ EdgeIPs []string `json:"edge_ips"`
+ } `json:"deployment"`
+ }
+ if err := json.Unmarshal([]byte(out), &got); err != nil {
+ t.Fatal(err)
+ }
+ targets := fx.srv.dnsTargets(context.Background())
+ seen := 0
+ for _, d := range got.Domains {
+ w, ok := want[d.Host]
+ if !ok {
+ continue
+ }
+ seen++
+ if d.CNAMETarget != w {
+ t.Errorf("%s cname_target = %q, want %q", d.Host, d.CNAMETarget, w)
+ }
+ if g := domainGuidance(d.Host, targets); d.Guidance != g {
+ t.Errorf("%s guidance = %q, want %q", d.Host, d.Guidance, g)
+ }
+ for _, r := range d.Records {
+ if r.Type == "CNAME" && r.Value != w {
+ t.Errorf("%s CNAME record %+v, want %q", d.Host, r, w)
+ }
+ }
+ }
+ if seen != len(want) {
+ t.Fatalf("saw %d of %d rows in %s", seen, len(want), out)
+ }
+ if got.Deployment.SteeringHost != "edge.oncarlos.test" || len(got.Deployment.EdgeIPs) == 0 {
+ t.Errorf("deployment block = %+v", got.Deployment)
+ }
+ code, _, out = rawReq(t, http.MethodGet, domainGetURL(fx, "bab", "titogo", "first.example.com"), member, "")
+ if code != http.StatusOK {
+ t.Fatalf("per-host door = %d %s", code, out)
+ }
+ var one struct {
+ Domain struct {
+ CNAMETarget string `json:"cname_target"`
+ } `json:"domain"`
+ }
+ if err := json.Unmarshal([]byte(out), &one); err != nil || one.Domain.CNAMETarget != "edge.oncarlos.test" {
+ t.Errorf("per-host door cname_target: %v %s", err, out)
+ }
+ acct, err := fx.st.AccountBySqid(sqid)
+ if err != nil || acct == nil {
+ t.Fatal(err)
+ }
+ for _, dv := range fx.srv.settingsDomains(withReqMemo(context.Background()), acct, "titogo", nil) {
+ if _, ok := want[dv.Domain]; ok && dv.Domain != "example.com" && dv.Guidance != domainGuidance(dv.Domain, targets) {
+ t.Errorf("settings %s guidance = %q", dv.Domain, dv.Guidance)
+ }
+ }
+}
diff --git a/internal/console/view.go b/internal/console/view.go
index 297fdcbde..14296169b 100644
--- a/internal/console/view.go
+++ b/internal/console/view.go
@@ -160,7 +160,8 @@ func (d DomainView) Explain() string {
// only on a deployment that STEERS (multi-region ingress spec, Part 4) —
// the steering hostname a non-apex host may CNAME to instead.
type DNSTargets struct {
- // ConfiguredIngress suppresses legacy steering and names the public union.
+ // ConfiguredIngress names the public union for A records. Beside it a
+ // subdomain still gets the steering CNAME (see Server.dnsTargets).
ConfiguredIngress bool
// EdgeIPs is the DNS-only union chosen by Server.edgeIPs: static public
// ingress when configured, otherwise PLATFORM_EDGE_IPS plus live boxes.
@@ -173,10 +174,11 @@ type DNSTargets struct {
SteeringHost string
}
-// domainGuidance is shared by routed and claim-only custom domains. Ingress
-// mode uses only the configured public A-record union; legacy steering still
-// offers a CNAME for subdomains. The public suffix list decides apexes, where
-// a CNAME cannot coexist with the zone's SOA and NS records.
+// domainGuidance is shared by routed and claim-only custom domains. Where the
+// deployment steers, a subdomain is offered the CNAME at the steering
+// hostname, configured ingress or not; ingress mode names only the configured
+// public union for A records. The public suffix list decides apexes, where a
+// CNAME cannot coexist with the zone's SOA and NS records.
func domainGuidance(host string, t DNSTargets) string {
target := "this deployment's edge IP"
if len(t.EdgeIPs) > 0 {
@@ -184,7 +186,7 @@ func domainGuidance(host string, t DNSTargets) string {
}
aRecord := "Point an A record for " + host + " at " + target + "."
switch {
- case t.ConfiguredIngress:
+ case t.ConfiguredIngress && (isApexDomain(host) || t.SteeringHost == ""):
if isApexDomain(host) {
return fmt.Sprintf("%s is an apex domain and cannot use a CNAME. Point its A record at the configured public ingress addresses: %s. Checks run every few minutes.", host, target)
}
@@ -198,6 +200,17 @@ func domainGuidance(host string, t DNSTargets) string {
return aRecord + " Checks run every few minutes."
}
+// cnameTarget is the name a host is told to CNAME at, or "" when the advice
+// is A records only: the steering hostname, for a subdomain. domainGuidance
+// and domainRecords both read it, so the sentence, the records and the
+// domains door's cname_target never name two different targets.
+func cnameTarget(host string, t DNSTargets) string {
+ if isApexDomain(host) {
+ return ""
+ }
+ return t.SteeringHost
+}
+
// isApexDomain reports whether host is the registrable domain itself — the
// one place a CNAME is illegal (RFC 1034: a CNAME cannot coexist with the
// SOA and NS records an apex must carry). golang.org/x/net/publicsuffix is
diff --git a/internal/domains/cname_steering_test.go b/internal/domains/cname_steering_test.go
new file mode 100644
index 000000000..33e439b6d
--- /dev/null
+++ b/internal/domains/cname_steering_test.go
@@ -0,0 +1,114 @@
+package domains
+
+import (
+ "context"
+ "net"
+ "strings"
+ "testing"
+ "time"
+
+ "golang.org/x/net/dns/dnsmessage"
+)
+
+// A custom domain CNAMEd at the steering hostname (the console's advice where
+// the deployment steers, configured ingress or not) reads "pointing" when that host
+// resolves into the edge set, configured public ingress included, and
+// "elsewhere" when it does not. dnsStatus is fed the production resolver
+// shape, so the CNAME is followed by LookupHost exactly as on a box.
+func TestDNSStatusFollowsACNAMEToTheSteeringHost(t *testing.T) {
+ const ingress = "192.0.2.90"
+ chain := []string{"shop.example.com", "edge.oncarlos.test"}
+ resolve := cnameDNS(t, chain, []string{ingress})
+ if got := dnsStatus(resolve, "shop.example.com", map[string]bool{"192.0.2.1": true, ingress: true}); got != "pointing" {
+ t.Errorf("CNAME to the steering host, answering with configured ingress: %q, want pointing", got)
+ }
+ if got := dnsStatus(resolve, "shop.example.com", map[string]bool{"192.0.2.1": true}); got != "elsewhere" {
+ t.Errorf("CNAME to an address outside the edge set: %q, want elsewhere", got)
+ }
+ if got := dnsStatus(resolve, "missing.example.com", map[string]bool{ingress: true}); got != "" {
+ t.Errorf("no record yet: %q, want empty", got)
+ }
+ // Two hops (a customer CNAME to their own name, then to the steering host).
+ two := cnameDNS(t, []string{"www.example.com", "shop.example.com", "edge.oncarlos.test"}, []string{ingress})
+ if got := dnsStatus(two, "www.example.com", map[string]bool{ingress: true}); got != "pointing" {
+ t.Errorf("two-hop CNAME: %q, want pointing", got)
+ }
+}
+
+// cnameDNS is a one-zone authoritative fake for the CNAME tests: it answers
+// every A query for a name in chain with the whole CNAME chain to the end
+// name plus that name's A records, the way a recursive resolver hands a
+// stub the answer. AAAA gets the chain alone. Anything else is NXDOMAIN.
+// It is reached through a real net.Resolver (PreferGo, dialing it), so
+// the lookup under test is the production LookupHost, CNAME-following and
+// all, with only the network swapped.
+func cnameDNS(t *testing.T, chain []string, ips []string) func(string) ([]string, error) {
+ t.Helper()
+ pc, err := net.ListenPacket("udp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { pc.Close() })
+ fq := func(n string) string { return strings.TrimSuffix(strings.ToLower(n), ".") + "." }
+ go func() {
+ buf := make([]byte, 1500)
+ for {
+ n, addr, err := pc.ReadFrom(buf)
+ if err != nil {
+ return
+ }
+ var p dnsmessage.Parser
+ h, err := p.Start(buf[:n])
+ if err != nil {
+ continue
+ }
+ q, err := p.Question()
+ if err != nil {
+ continue
+ }
+ b := dnsmessage.NewBuilder(nil, dnsmessage.Header{ID: h.ID, Response: true, Authoritative: true, RecursionAvailable: true})
+ b.EnableCompression()
+ _ = b.StartQuestions()
+ _ = b.Question(q)
+ _ = b.StartAnswers()
+ start := -1
+ for i, name := range chain {
+ if fq(name) == strings.ToLower(q.Name.String()) {
+ start = i
+ }
+ }
+ if start < 0 {
+ b = dnsmessage.NewBuilder(nil, dnsmessage.Header{ID: h.ID, Response: true, Authoritative: true, RCode: dnsmessage.RCodeNameError})
+ _ = b.StartQuestions()
+ _ = b.Question(q)
+ } else {
+ for i := start; i+1 < len(chain); i++ {
+ _ = b.CNAMEResource(dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(fq(chain[i])), Class: dnsmessage.ClassINET, TTL: 60},
+ dnsmessage.CNAMEResource{CNAME: dnsmessage.MustNewName(fq(chain[i+1]))})
+ }
+ if q.Type == dnsmessage.TypeA {
+ for _, ip := range ips {
+ var a [4]byte
+ copy(a[:], net.ParseIP(ip).To4())
+ _ = b.AResource(dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(fq(chain[len(chain)-1])), Class: dnsmessage.ClassINET, TTL: 60},
+ dnsmessage.AResource{A: a})
+ }
+ }
+ }
+ msg, err := b.Finish()
+ if err != nil {
+ continue
+ }
+ _, _ = pc.WriteTo(msg, addr)
+ }
+ }()
+ r := &net.Resolver{PreferGo: true, Dial: func(ctx context.Context, _, _ string) (net.Conn, error) {
+ var d net.Dialer
+ return d.DialContext(ctx, "udp", pc.LocalAddr().String())
+ }}
+ return func(host string) ([]string, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ defer cancel()
+ return r.LookupHost(ctx, host)
+ }
+}
diff --git a/internal/edge/cname_steering_test.go b/internal/edge/cname_steering_test.go
new file mode 100644
index 000000000..959b3adbe
--- /dev/null
+++ b/internal/edge/cname_steering_test.go
@@ -0,0 +1,104 @@
+package edge
+
+import (
+ "context"
+ "net"
+ "strings"
+ "testing"
+ "time"
+
+ "golang.org/x/net/dns/dnsmessage"
+)
+
+// The cert warm only orders for a host whose DNS lands wholly on this
+// deployment. A custom domain CNAMEd at the steering hostname passes when that
+// host resolves into the edge set (configured public ingress is part of it
+// through PLATFORM_EDGE_IPS), and fails when it does not.
+func TestCertWarmGateFollowsACNAMEToTheSteeringHost(t *testing.T) {
+ const ingress = "192.0.2.90"
+ resolve := cnameDNS(t, []string{"shop.example.com", "edge.oncarlos.test"}, []string{ingress})
+ if !dnsGate(resolve, func() []string { return []string{"192.0.2.1", ingress} })("shop.example.com") {
+ t.Error("CNAME to the steering host on configured ingress was refused a certificate")
+ }
+ if dnsGate(resolve, func() []string { return []string{"192.0.2.1"} })("shop.example.com") {
+ t.Error("CNAME to an address outside the edge set was offered a certificate")
+ }
+}
+
+// cnameDNS is a one-zone authoritative fake for the CNAME tests: it answers
+// every A query for a name in chain with the whole CNAME chain to the end
+// name plus that name's A records, the way a recursive resolver hands a
+// stub the answer. AAAA gets the chain alone. Anything else is NXDOMAIN.
+// It is reached through a real net.Resolver (PreferGo, dialing it), so
+// the lookup under test is the production LookupHost, CNAME-following and
+// all, with only the network swapped.
+func cnameDNS(t *testing.T, chain []string, ips []string) func(string) ([]string, error) {
+ t.Helper()
+ pc, err := net.ListenPacket("udp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { pc.Close() })
+ fq := func(n string) string { return strings.TrimSuffix(strings.ToLower(n), ".") + "." }
+ go func() {
+ buf := make([]byte, 1500)
+ for {
+ n, addr, err := pc.ReadFrom(buf)
+ if err != nil {
+ return
+ }
+ var p dnsmessage.Parser
+ h, err := p.Start(buf[:n])
+ if err != nil {
+ continue
+ }
+ q, err := p.Question()
+ if err != nil {
+ continue
+ }
+ b := dnsmessage.NewBuilder(nil, dnsmessage.Header{ID: h.ID, Response: true, Authoritative: true, RecursionAvailable: true})
+ b.EnableCompression()
+ _ = b.StartQuestions()
+ _ = b.Question(q)
+ _ = b.StartAnswers()
+ start := -1
+ for i, name := range chain {
+ if fq(name) == strings.ToLower(q.Name.String()) {
+ start = i
+ }
+ }
+ if start < 0 {
+ b = dnsmessage.NewBuilder(nil, dnsmessage.Header{ID: h.ID, Response: true, Authoritative: true, RCode: dnsmessage.RCodeNameError})
+ _ = b.StartQuestions()
+ _ = b.Question(q)
+ } else {
+ for i := start; i+1 < len(chain); i++ {
+ _ = b.CNAMEResource(dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(fq(chain[i])), Class: dnsmessage.ClassINET, TTL: 60},
+ dnsmessage.CNAMEResource{CNAME: dnsmessage.MustNewName(fq(chain[i+1]))})
+ }
+ if q.Type == dnsmessage.TypeA {
+ for _, ip := range ips {
+ var a [4]byte
+ copy(a[:], net.ParseIP(ip).To4())
+ _ = b.AResource(dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(fq(chain[len(chain)-1])), Class: dnsmessage.ClassINET, TTL: 60},
+ dnsmessage.AResource{A: a})
+ }
+ }
+ }
+ msg, err := b.Finish()
+ if err != nil {
+ continue
+ }
+ _, _ = pc.WriteTo(msg, addr)
+ }
+ }()
+ r := &net.Resolver{PreferGo: true, Dial: func(ctx context.Context, _, _ string) (net.Conn, error) {
+ var d net.Dialer
+ return d.DialContext(ctx, "udp", pc.LocalAddr().String())
+ }}
+ return func(host string) ([]string, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ defer cancel()
+ return r.LookupHost(ctx, host)
+ }
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 76eebb71b..f13dbbc05 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -722,7 +722,7 @@ var plan9B8CensusInventory = []censusEntry{
{"internal/console/claim_retire_helpers.go", "claimRetireRecordKey", "key-site", "key:RecordKey,key:SidecarRecordKey,key:claimRetireRecordKey", "4a84350fc30ad6866855f785e40bea690655daf6399acad853c4e61871ee82a5"},
{"internal/console/claim_store_effects.go", "claimEffectStore.Put", "record-transport", "def:Put,sel:Put", "679406564fa1f9816a4fe2fe9bd454ed6fdde1e16a3e7c5060c22fdb933e7b9e"},
{"internal/console/domainattach.go", "Server.attachDomainAs", "record-writer", "key:CreateRecord", "c99691f92daab087137bb607a89f3dc7ef4202e83431e61ebee56553756f7f4f"},
- {"internal/console/domaincatchall.go", "Server.catchallListItems", "key-site", "lit:instances", "365ead1d588dfbe9397a86510c386940545bf853f77294601575f1f39c48e989"},
+ {"internal/console/domaincatchall.go", "Server.catchallListItems", "key-site", "lit:instances", "305f95c61dbaafe261c876dd730e8af5682b444c16c470cd41b7760e4160a738"},
{"internal/console/economicspass.go", "Server.upsertBill", "nonrecord", "sel:Put", "2af1ed6992d6856f5273d5ce6305fa4b9d434f94b25c9843c5cd45a6c69362b1"},
{"internal/console/economicspass.go", "Server.putScenario", "nonrecord", "sel:Put", "80557ccbb43b60fe9e8a54a4aaf3be1e7982a92a9ba2d6e33be43ddf51329ab5"},
{"internal/console/economicspass.go", "Server.putActiveScenario", "nonrecord", "sel:Put", "0711f7092a78e391af67eca8c4a5b30224297bbddb8c7a92add8c375faef3bff"},