fix: incorrect OPT RR filter order (#2634)

This commit is contained in:
woaihsw authored and GitHub committed 2026-03-23 01:12:02 +08:00
1 parent 4f93c93954
commit d0f33125a9
1 file changed
+7 -7
+7 -7
View File
@@ -64,6 +64,13 @@ func putMsgToCache(c dnsCache, q D.Question, msg *D.Msg) {
return
}
msg = msg.Copy() // never modify the original msg
// OPT RRs MUST NOT be cached, forwarded, or stored in or loaded from master files.
msg.Extra = lo.Filter(msg.Extra, func(rr D.RR, index int) bool {
return rr.Header().Rrtype != D.TypeOPT
})
var ttl uint32
if msg.Rcode == D.RcodeServerFailure {
// [...] a resolver MAY cache a server failure response.
@@ -76,13 +83,6 @@ func putMsgToCache(c dnsCache, q D.Question, msg *D.Msg) {
return
}
msg = msg.Copy() // never modify the original msg
// OPT RRs MUST NOT be cached, forwarded, or stored in or loaded from master files.
msg.Extra = lo.Filter(msg.Extra, func(rr D.RR, index int) bool {
return rr.Header().Rrtype != D.TypeOPT
})
c.SetWithExpire(q.String(), msg, time.Now().Add(time.Duration(ttl)*time.Second))
}