plugin/file: expand SVCB/HTTPS record support (#7950)

* plugin/file: expand SVCB/HTTPS record support

Add proper SVCB (type 64) and HTTPS (type 65) handling:

- Additional section processing: include A/AAAA glue for in-bailiwick
  SVCB/HTTPS targets, matching existing SRV/MX behavior
- Target name normalization: lowercase SVCB/HTTPS Target on zone insert,
  consistent with CNAME/MX handling
- Metrics: add TypeSVCB to monitored query types (TypeHTTPS was already
  present)
- Test helpers: add SVCB()/HTTPS() constructors and Section comparison
  cases
- Tests: basic queries with glue, AliasMode, wildcards, NoData, NXDOMAIN,
  target normalization, and DNS-AID private-use key (65400-65408)
  round-trip

Signed-off-by: Ingmar <ivanglabbeek@infoblox.com>

* plugin/file: simplify HTTPS target access via field promotion

dns.HTTPS embeds dns.SVCB, so .Target is directly accessible
without the redundant .SVCB. qualifier. Fixes gosimple S1027.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ingmar <ivanglabbeek@infoblox.com>

---------

Signed-off-by: Ingmar <ivanglabbeek@infoblox.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ingmar Van Glabbeek
2026-03-28 02:46:41 -07:00
committed by GitHub
parent a8caf4c375
commit 12d9457e71
5 changed files with 261 additions and 0 deletions

View File

@@ -111,6 +111,12 @@ func DS(rr string) *dns.DS { r, _ := dns.NewRR(rr); return r.(*dns.DS) }
// NAPTR returns a NAPTR record from rr. It panics on errors.
func NAPTR(rr string) *dns.NAPTR { r, _ := dns.NewRR(rr); return r.(*dns.NAPTR) }
// SVCB returns a SVCB record from rr. It panics on errors.
func SVCB(rr string) *dns.SVCB { r, _ := dns.NewRR(rr); return r.(*dns.SVCB) }
// HTTPS returns an HTTPS record from rr. It panics on errors.
func HTTPS(rr string) *dns.HTTPS { r, _ := dns.NewRR(rr); return r.(*dns.HTTPS) }
// OPT returns an OPT record with UDP buffer size set to bufsize and the DO bit set to do.
func OPT(bufsize int, do bool) *dns.OPT {
o := new(dns.OPT)
@@ -256,6 +262,28 @@ func Section(tc Case, sec sect, rr []dns.RR) error {
if x.Do() != tt.Do() {
return fmt.Errorf("OPT DO should be %t, but is %t", tt.Do(), x.Do())
}
case *dns.SVCB:
tt := section[i].(*dns.SVCB)
if x.Priority != tt.Priority {
return fmt.Errorf("RR %d should have a Priority of %d, but has %d", i, tt.Priority, x.Priority)
}
if x.Target != tt.Target {
return fmt.Errorf("RR %d should have a Target of %q, but has %q", i, tt.Target, x.Target)
}
if x.String() != tt.String() {
return fmt.Errorf("RR %d should have value %q, but has %q", i, tt.String(), x.String())
}
case *dns.HTTPS:
tt := section[i].(*dns.HTTPS)
if x.Priority != tt.Priority {
return fmt.Errorf("RR %d should have a Priority of %d, but has %d", i, tt.Priority, x.Priority)
}
if x.Target != tt.Target {
return fmt.Errorf("RR %d should have a Target of %q, but has %q", i, tt.Target, x.Target)
}
if x.String() != tt.String() {
return fmt.Errorf("RR %d should have value %q, but has %q", i, tt.String(), x.String())
}
}
}
return nil