refactor(dns): eagerly decode CNAME target into r.data, drop target field

Address review feedback on #189:

- Remove Resource.target: Resource.Decode expands CNAME RDATA in place
  into r.data (uncompressed wire format) while the full message is still
  available and updates header.Length, storing the name bytes exactly once.
- Add Resource.CNAMEView returning a length-bounded view of the expanded
  target; Message.WriteAnswers uses it.
- Rename matchesHost to ResourceHeader.pertainsTo.
- Make ResolveConfig.MaxCNAMEs explicit: drop the silent default in
  Client.StartResolve and let callers opt in (x/xnet).
- Reduce test suite to regression coverage only.

refs #189
This commit is contained in:
Yoshio HANAWA
2026-08-27 09:46:00 +09:00
parent a33e9c5fab
commit 8c49548440
4 changed files with 81 additions and 71 deletions
+1 -5
View File
@@ -43,11 +43,7 @@ func (c *Client) StartResolve(localPort, txid uint16, cfg ResolveConfig) error {
if maxIPs == 0 {
maxIPs = uint16(nd)
}
maxCNAMEs := cfg.MaxCNAMEs
if maxCNAMEs == 0 {
maxCNAMEs = 16
}
maxAns := maxIPs + maxCNAMEs
maxAns := maxIPs + cfg.MaxCNAMEs
c.reset(localPort, txid, CQueryPending, cfg.EnableRecursion)
c.msg.LimitResourceDecoding(uint16(nd), maxAns, 0, 0)
c.msg.AddQuestions(cfg.Questions)