Commit aa2302e3 authored by Chris O'Haver's avatar Chris O'Haver Committed by Miek Gieben

incl addtl rrs when computing cache ttl (#1549)

parent 96aff937
...@@ -96,12 +96,16 @@ func minMsgTTL(m *dns.Msg, mt response.Type) time.Duration { ...@@ -96,12 +96,16 @@ func minMsgTTL(m *dns.Msg, mt response.Type) time.Duration {
} }
// No data to examine, return a short ttl as a fail safe. // No data to examine, return a short ttl as a fail safe.
if len(m.Answer)+len(m.Ns) == 0 { if len(m.Answer)+len(m.Ns)+len(m.Extra) == 0 {
return failSafeTTL return failSafeTTL
} }
minTTL := maxTTL minTTL := maxTTL
for _, r := range append(m.Answer, m.Ns...) { for _, r := range append(append(m.Answer, m.Ns...), m.Extra...) {
if r.Header().Rrtype == dns.TypeOPT {
// OPT records use TTL field for extended rcode and flags
continue
}
switch mt { switch mt {
case response.NameError, response.NoData: case response.NameError, response.NoData:
if r.Header().Rrtype == dns.TypeSOA { if r.Header().Rrtype == dns.TypeSOA {
......
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