Improve handling of expired or failed queries

This commit is contained in:
Daniel
2020-09-24 10:42:48 +02:00
parent af056780fc
commit c856b7372a
3 changed files with 51 additions and 26 deletions

View File

@@ -50,6 +50,11 @@ func (rrCache *RRCache) Expired() bool {
return rrCache.TTL <= time.Now().Unix()
}
// Expired returns whether the record will expire soon and should already be refreshed.
func (rrCache *RRCache) ExpiresSoon() bool {
return rrCache.TTL <= time.Now().Unix()+refreshTTL
}
// MixAnswers randomizes the answer records to allow dumb clients (who only look at the first record) to reliably connect.
func (rrCache *RRCache) MixAnswers() {
rrCache.Lock()