Skip to content

Commit

Permalink
avoid returning stale ServFail response
Browse files Browse the repository at this point in the history
Close AdguardTeam#436.

Signed-off-by: Jay <[email protected]>
  • Loading branch information
BusyJay authored Feb 12, 2025
1 parent 1177916 commit 8fb6266
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proxy/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func (c *cache) unpackItem(data []byte, req *dns.Msg) (ci *cacheItem, expired bo
return nil, expired
}

// Don't return expired ServFail response from cache, otherwise it may stop
// future refresh.
if m.Rcode == dns.RcodeServerFailure && expired {
return nil, expired
}

res := (&dns.Msg{}).SetRcode(req, m.Rcode)
res.AuthenticatedData = m.AuthenticatedData
res.RecursionAvailable = m.RecursionAvailable
Expand Down

0 comments on commit 8fb6266

Please sign in to comment.