diff options
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r-- | plugin/cache/cache.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index d1989f35b..bfd8c1576 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -43,6 +43,10 @@ type Cache struct { staleUpTo time.Duration verifyStale bool + // Positive/negative zone exceptions + pexcept []string + nexcept []string + // Testing. now func() time.Time } @@ -117,6 +121,8 @@ type ResponseWriter struct { wildcardFunc func() string // function to retrieve wildcard name that synthesized the result. + pexcept []string // positive zone exceptions + nexcept []string // negative zone exceptions } // newPrefetchResponseWriter returns a Cache ResponseWriter to be used in @@ -204,6 +210,10 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration // and key is valid switch mt { case response.NoError, response.Delegation: + if plugin.Zones(w.pexcept).Matches(m.Question[0].Name) != "" { + // zone is in exception list, do not cache + return + } i := newItem(m, w.now(), duration) if w.wildcardFunc != nil { i.wildcard = w.wildcardFunc() @@ -217,6 +227,10 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration } case response.NameError, response.NoData, response.ServerError: + if plugin.Zones(w.nexcept).Matches(m.Question[0].Name) != "" { + // zone is in exception list, do not cache + return + } i := newItem(m, w.now(), duration) if w.wildcardFunc != nil { i.wildcard = w.wildcardFunc() |