aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-05-22 19:43:58 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2016-05-22 19:43:58 +0100
commitd35394a8df3aa9d2b2bcf59101c093c03f4bd227 (patch)
tree598ad0bf7d1a5177a1be2291a2f93cf34cb49c26
parent069b61ff15a3e6ae416c4c9b09273f7fbcb15cd8 (diff)
downloadcoredns-d35394a8df3aa9d2b2bcf59101c093c03f4bd227.tar.gz
coredns-d35394a8df3aa9d2b2bcf59101c093c03f4bd227.tar.zst
coredns-d35394a8df3aa9d2b2bcf59101c093c03f4bd227.zip
middleware/caching: don't set TTL on OPT
When setting the TTL on all RR in the message we would also do this for the OPT RR. This is wrong as the OPT RR does *not* have a TTL.
-rw-r--r--middleware/cache/cache.go6
-rw-r--r--middleware/cache/item.go3
2 files changed, 8 insertions, 1 deletions
diff --git a/middleware/cache/cache.go b/middleware/cache/cache.go
index 6249b8faa..fd804d445 100644
--- a/middleware/cache/cache.go
+++ b/middleware/cache/cache.go
@@ -74,7 +74,7 @@ func (c *CachingResponseWriter) WriteMsg(res *dns.Msg) error {
func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgType) {
if key == "" {
- // logger the log? TODO(miek)
+ log.Printf("[ERROR] Caching called with empty cache key")
return
}
@@ -94,6 +94,10 @@ func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgTyp
i := newItem(m, duration)
c.cache.Set(key, i, duration)
+ case middleware.OtherError:
+ // don't cache these
+ default:
+ log.Printf("[WARNING] Caching called with unknown middleware MsgType: %d", mt)
}
}
diff --git a/middleware/cache/item.go b/middleware/cache/item.go
index 6f0190c52..544de3c9a 100644
--- a/middleware/cache/item.go
+++ b/middleware/cache/item.go
@@ -74,6 +74,9 @@ func setCap(m *dns.Msg, ttl uint32) {
r.Header().Ttl = uint32(ttl)
}
for _, r := range m.Extra {
+ if r.Header().Rrtype == dns.TypeOPT {
+ continue
+ }
r.Header().Ttl = uint32(ttl)
}
}