Commit d35394a8 authored by Miek Gieben's avatar Miek Gieben

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.
parent 069b61ff
...@@ -74,7 +74,7 @@ func (c *CachingResponseWriter) WriteMsg(res *dns.Msg) error { ...@@ -74,7 +74,7 @@ func (c *CachingResponseWriter) WriteMsg(res *dns.Msg) error {
func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgType) { func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgType) {
if key == "" { if key == "" {
// logger the log? TODO(miek) log.Printf("[ERROR] Caching called with empty cache key")
return return
} }
...@@ -94,6 +94,10 @@ func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgTyp ...@@ -94,6 +94,10 @@ func (c *CachingResponseWriter) set(m *dns.Msg, key string, mt middleware.MsgTyp
i := newItem(m, duration) i := newItem(m, duration)
c.cache.Set(key, i, 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)
} }
} }
......
...@@ -74,6 +74,9 @@ func setCap(m *dns.Msg, ttl uint32) { ...@@ -74,6 +74,9 @@ func setCap(m *dns.Msg, ttl uint32) {
r.Header().Ttl = uint32(ttl) r.Header().Ttl = uint32(ttl)
} }
for _, r := range m.Extra { for _, r := range m.Extra {
if r.Header().Rrtype == dns.TypeOPT {
continue
}
r.Header().Ttl = uint32(ttl) r.Header().Ttl = uint32(ttl)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment