Shorten caching for empty success responses.

This commit is contained in:
Daniel 2020-11-30 15:08:25 +01:00
parent 454a234449
commit a60a53ed46
2 changed files with 6 additions and 4 deletions

View file

@ -479,10 +479,6 @@ func (mgr *tcpResolverConnMgr) handleQueryResponse(conn *dns.Conn, msg *dns.Msg)
// persist to database
rrCache := inFlight.MakeCacheRecord(msg)
if !rrCache.Cacheable() {
return
}
rrCache.Clean(minTTL)
err := rrCache.Save()
if err != nil {

View file

@ -85,6 +85,12 @@ func (rrCache *RRCache) Clean(minExpires uint32) {
lowestTTL = maxTTL
}
// Adjust return code if there are no answers
if rrCache.RCode == dns.RcodeSuccess &&
len(rrCache.Answer) == 0 {
rrCache.RCode = dns.RcodeNameError
}
// shorten caching
switch {
case rrCache.RCode != dns.RcodeSuccess: