mirror of
https://github.com/coredns/coredns.git
synced 2026-08-20 23:08:28 -04:00
plugin/cache: preserve AD when storing cache entries (#8438)
This commit is contained in:
17
plugin/cache/cache.go
vendored
17
plugin/cache/cache.go
vendored
@@ -348,11 +348,14 @@ var prefetchAddr = &net.TCPAddr{}
|
||||
// short-circuits after caching when w.prefetch is true, and the nil-safe
|
||||
// overrides below make the remaining dns.ResponseWriter methods well-defined.
|
||||
func newPrefetchResponseWriter(server string, req *dns.Msg, do, cd bool, c *Cache) *ResponseWriter {
|
||||
req = req.Copy()
|
||||
req.AuthenticatedData = true
|
||||
cw := &ResponseWriter{
|
||||
Cache: c,
|
||||
server: server,
|
||||
do: do,
|
||||
cd: cd,
|
||||
ad: true,
|
||||
prefetch: true,
|
||||
remoteAddr: prefetchAddr,
|
||||
}
|
||||
@@ -435,13 +438,6 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
||||
res.Ns = filterRRSlice(res.Ns, ttl, false)
|
||||
res.Extra = filterRRSlice(res.Extra, ttl, false)
|
||||
|
||||
if !w.do && !w.ad {
|
||||
// unset AD bit if requester is not OK with DNSSEC
|
||||
// But retain AD bit if requester set the AD bit in the request, per RFC6840 5.7-5.8
|
||||
res.AuthenticatedData = false
|
||||
}
|
||||
w.lastResponse = res.Copy()
|
||||
|
||||
if hasKey && duration > 0 {
|
||||
if w.state.Match(res) {
|
||||
w.set(res, key, mt, duration)
|
||||
@@ -453,6 +449,13 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
||||
}
|
||||
}
|
||||
|
||||
if !w.do && !w.ad {
|
||||
// unset AD bit if requester is not OK with DNSSEC
|
||||
// But retain AD bit if requester set the AD bit in the request, per RFC6840 5.7-5.8
|
||||
res.AuthenticatedData = false
|
||||
}
|
||||
w.lastResponse = res.Copy()
|
||||
|
||||
if w.prefetch {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user