mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/cache: Add option to adjust SERVFAIL response cache TTL (#5320)
* add servfail cache opt Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
17
plugin/cache/setup.go
vendored
17
plugin/cache/setup.go
vendored
@@ -188,6 +188,23 @@ func cacheParse(c *caddy.Controller) (*Cache, error) {
|
||||
}
|
||||
ca.verifyStale = mode == "verify"
|
||||
}
|
||||
case "servfail":
|
||||
args := c.RemainingArgs()
|
||||
if len(args) != 1 {
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
d, err := time.ParseDuration(args[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if d < 0 {
|
||||
return nil, errors.New("invalid negative ttl for servfail")
|
||||
}
|
||||
if d > 5*time.Minute {
|
||||
// RFC 2308 prohibits caching SERVFAIL longer than 5 minutes
|
||||
return nil, errors.New("caching SERVFAIL responses over 5 minutes is not permitted")
|
||||
}
|
||||
ca.failttl = d
|
||||
default:
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user