Fix incorrect empty answer handling per RFC4074

This commit is contained in:
Daniel
2021-04-16 17:47:13 +02:00
parent 4c5461a788
commit ccefcd6b3b
2 changed files with 15 additions and 12 deletions

View File

@@ -82,12 +82,6 @@ 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:
@@ -96,6 +90,9 @@ func (rrCache *RRCache) Clean(minExpires uint32) {
case netenv.IsConnectivityDomain(rrCache.Domain):
// Responses from these domains might change very quickly depending on the environment.
lowestTTL = 3
case len(rrCache.Answer) == 0:
// Empty answer section: Domain exists, but not the queried RR.
lowestTTL = 60
case !netenv.Online():
// Not being fully online could mean that we get funny responses.
lowestTTL = 60