diff options
author | 2022-06-17 15:48:57 -0400 | |
---|---|---|
committer | 2022-06-17 15:48:57 -0400 | |
commit | dded10420b8a477ebd86cd2ceed9207a42c226cc (patch) | |
tree | 6b0679260b212428c74a3fbdc6ee3013d6460e0b /plugin/cache/setup.go | |
parent | d60ce0c8d4fd647e880a118f469e8239d6effc7d (diff) | |
download | coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.gz coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.zst coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.zip |
plugin/cache: Add option to adjust SERVFAIL response cache TTL (#5320)
* add servfail cache opt
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/setup.go')
-rw-r--r-- | plugin/cache/setup.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugin/cache/setup.go b/plugin/cache/setup.go index e5258dc06..aa487105c 100644 --- a/plugin/cache/setup.go +++ b/plugin/cache/setup.go @@ -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() } |