diff options
Diffstat (limited to 'plugin/cache')
-rw-r--r-- | plugin/cache/cache.go | 13 | ||||
-rw-r--r-- | plugin/cache/handler.go | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index b37e527cf..5d9bd746b 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -117,6 +117,19 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error { return nil } + // Apply capped TTL to this reply to avoid jarring TTL experience 1799 -> 8 (e.g.) + ttl := uint32(duration.Seconds()) + for i := range res.Answer { + res.Answer[i].Header().Ttl = ttl + } + for i := range res.Ns { + res.Ns[i].Header().Ttl = ttl + } + for i := range res.Extra { + if res.Extra[i].Header().Rrtype != dns.TypeOPT { + res.Extra[i].Header().Ttl = ttl + } + } return w.ResponseWriter.WriteMsg(res) } diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go index ebd87d659..f3f2e675b 100644 --- a/plugin/cache/handler.go +++ b/plugin/cache/handler.go @@ -19,7 +19,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) qtype := state.QType() zone := plugin.Zones(c.Zones).Matches(qname) if zone == "" { - return c.Next.ServeDNS(ctx, w, r) + return plugin.NextOrFailure(c.Name(), c.Next, ctx, w, r) } do := state.Do() // TODO(): might need more from OPT record? Like the actual bufsize? |