CopyFrom pattern for DNS and use it for Cookie

This commit is contained in:
soypat
2025-06-25 09:32:35 -03:00
parent 1fcde05284
commit 23212d8dc6
6 changed files with 81 additions and 12 deletions
+12
View File
@@ -91,6 +91,18 @@ func (c *Client) isClosed() bool {
return c.state == dnsClosed || c.state == dnsAborted
}
func (c *Client) MessageCopyTo(dst *Message) (done bool, err error) {
if !c.respFlags.IsResponse() {
return false, nil
}
dst.CopyFrom(c.msg)
rcode := c.respFlags.ResponseCode()
if rcode != 0 {
return true, rcode
}
return true, nil
}
func (c *Client) Answers() []Resource {
if c.state != dnsDone {
return nil