mirror of
https://github.com/coredns/coredns.git
synced 2026-06-15 13:40:11 -04:00
plugin/cache: allow cache TTLs above default 3600s (#8134)
* plugin/cache: allow cache TTLs above default 3600s This change allows the cache plugin to honor configured maximum TTL values above the default 3600s limit. Default behavior remains unchanged This PR fixes 7846 Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Keep MinimalTTL Signed-off-by: Yong Tang <yong.tang.github@outlook.com> --------- Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -10,6 +10,12 @@ import (
|
||||
|
||||
// MinimalTTL scans the message returns the lowest TTL found taking into the response.Type of the message.
|
||||
func MinimalTTL(m *dns.Msg, mt response.Type) time.Duration {
|
||||
return MinimalTTLWithMaximum(m, mt, MaximumDefaultTTL)
|
||||
}
|
||||
|
||||
// MinimalTTLWithMaximum scans the DNS message and returns the lowest TTL found,
|
||||
// constrained by maximumTTL and the response type.
|
||||
func MinimalTTLWithMaximum(m *dns.Msg, mt response.Type, maximumTTL time.Duration) time.Duration {
|
||||
if mt != response.NoError && mt != response.NameError && mt != response.NoData {
|
||||
return MinimalDefaultTTL
|
||||
}
|
||||
@@ -20,7 +26,7 @@ func MinimalTTL(m *dns.Msg, mt response.Type) time.Duration {
|
||||
return MinimalDefaultTTL
|
||||
}
|
||||
|
||||
minTTL := MaximumDefaulTTL
|
||||
minTTL := maximumTTL
|
||||
for _, r := range m.Answer {
|
||||
if r.Header().Ttl < uint32(minTTL.Seconds()) {
|
||||
minTTL = time.Duration(r.Header().Ttl) * time.Second
|
||||
|
||||
Reference in New Issue
Block a user