From a7675988d876ad45656dcd95c2e824dcc4c2986a Mon Sep 17 00:00:00 2001 From: Ekko Date: Tue, 24 Sep 2024 22:06:37 +0800 Subject: [PATCH] fix: compatible issue when DNS msg not be compressed (#646) Co-authored-by: mzz2017 <2017@duck.com> --- control/dns_control.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/control/dns_control.go b/control/dns_control.go index 8b41c30..b6cbaee 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -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) @@ -497,6 +498,7 @@ func (c *DnsController) sendReject_(dnsMessage *dnsmessage.Msg, req *udpRequest) dnsMessage.Response = true dnsMessage.RecursionAvailable = true dnsMessage.Truncated = false + dnsMessage.Compress = true if c.log.IsLevelEnabled(logrus.TraceLevel) { c.log.WithFields(logrus.Fields{ "question": dnsMessage.Question, @@ -756,6 +758,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