Fix and improve TTL handling

This commit is contained in:
Daniel
2020-07-20 16:40:47 +02:00
parent 813346e829
commit 8dea8e6c46
4 changed files with 15 additions and 6 deletions

View File

@@ -45,6 +45,12 @@ var (
ErrNoCompliance = fmt.Errorf("%w: no compliant resolvers for this query", ErrBlocked)
)
const (
minTTL = 60 // 1 Minute
minMDnsTTL = 60 // 1 Minute
maxTTL = 24 * 60 * 60 // 24 hours
)
// BlockedUpstreamError is returned when a DNS request
// has been blocked by the upstream server.
type BlockedUpstreamError struct {
@@ -326,7 +332,7 @@ resolveLoop:
// cache if enabled
if !q.NoCaching {
// persist to database
rrCache.Clean(600)
rrCache.Clean(minTTL)
err = rrCache.Save()
if err != nil {
log.Warningf("resolver: failed to cache RR for %s%s: %s", q.FQDN, q.QType.String(), err)