Skip to content

Commit

Permalink
fix: compatible issue when msg not be compressed
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed Sep 21, 2024
1 parent cec5e71 commit 945b32e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions control/dns_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (c *DnsController) LookupDnsRespCache_(msg *dnsmessage.Msg, cacheKey string
cache := c.LookupDnsRespCache(cacheKey, ignoreFixedTtl)
if cache != nil {
cache.FillInto(msg)
msg.Compress = true
b, err := msg.Pack()
if err != nil {
c.log.Warnf("failed to pack: %v", err)
Expand Down Expand Up @@ -483,6 +484,7 @@ func (c *DnsController) handle_(
}

// Re-pack DNS packet.
dnsMessage.Compress = true
data, err := dnsMessage.Pack()
if err != nil {
return fmt.Errorf("pack DNS packet: %w", err)
Expand All @@ -502,6 +504,7 @@ func (c *DnsController) sendReject_(dnsMessage *dnsmessage.Msg, req *udpRequest)
"question": dnsMessage.Question,
}).Traceln("Reject")
}
dnsMessage.Compress = true
data, err := dnsMessage.Pack()
if err != nil {
return fmt.Errorf("pack DNS packet: %w", err)
Expand Down Expand Up @@ -756,6 +759,7 @@ func (c *DnsController) dialSend(invokingDepth int, req *udpRequest, data []byte
if needResp {
// Keep the id the same with request.
respMsg.Id = id
respMsg.Compress = true
data, err = respMsg.Pack()
if err != nil {
return err
Expand Down

0 comments on commit 945b32e

Please sign in to comment.