plugin/cache: add a new keepttl option (#5879)
adds a new option `keepttl` to the cache plugin Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
This commit is contained in:
parent
d3e4fc78c3
commit
bf7c2cf37b
6 changed files with 87 additions and 1 deletions
5
plugin/cache/handler.go
vendored
5
plugin/cache/handler.go
vendored
|
@ -71,6 +71,11 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||
})
|
||||
}
|
||||
|
||||
if c.keepttl {
|
||||
// If keepttl is enabled we fake the current time to the stored
|
||||
// one so that we always get the original TTL
|
||||
now = i.stored
|
||||
}
|
||||
resp := i.toMsg(r, now, do, ad)
|
||||
w.WriteMsg(resp)
|
||||
return dns.RcodeSuccess, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue