diff options
author | 2022-07-07 17:07:04 -0400 | |
---|---|---|
committer | 2022-07-07 17:07:04 -0400 | |
commit | 83adb8fa229f88cfccd56dc89faee55ee4dcd500 (patch) | |
tree | 87ae288a1eb04968827339aeb8af8fd08567ae88 /plugin/cache/cache.go | |
parent | e80d696502863f2e35099e6e366bb00418c28d80 (diff) | |
download | coredns-83adb8fa229f88cfccd56dc89faee55ee4dcd500.tar.gz coredns-83adb8fa229f88cfccd56dc89faee55ee4dcd500.tar.zst coredns-83adb8fa229f88cfccd56dc89faee55ee4dcd500.zip |
plugin/file/cache: Add metadata for wildcard record responses (#5308)
For responses synthesized by known wildcard records, publish metadata containing the wildcard record name
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r-- | plugin/cache/cache.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index fc42866ac..d1989f35b 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -114,6 +114,9 @@ type ResponseWriter struct { ad bool // When true the original request had the AD bit set. prefetch bool // When true write nothing back to the client. remoteAddr net.Addr + + wildcardFunc func() string // function to retrieve wildcard name that synthesized the result. + } // newPrefetchResponseWriter returns a Cache ResponseWriter to be used in @@ -202,6 +205,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration switch mt { case response.NoError, response.Delegation: i := newItem(m, w.now(), duration) + if w.wildcardFunc != nil { + i.wildcard = w.wildcardFunc() + } if w.pcache.Add(key, i) { evictions.WithLabelValues(w.server, Success, w.zonesMetricLabel).Inc() } @@ -212,6 +218,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration case response.NameError, response.NoData, response.ServerError: i := newItem(m, w.now(), duration) + if w.wildcardFunc != nil { + i.wildcard = w.wildcardFunc() + } if w.ncache.Add(key, i) { evictions.WithLabelValues(w.server, Denial, w.zonesMetricLabel).Inc() } |