Add dns cache clearing mechanisms
This commit is contained in:
@@ -34,6 +34,11 @@ type RRCache struct {
|
||||
updated int64 // mutable
|
||||
}
|
||||
|
||||
// ID returns the ID of the RRCache consisting of the domain and question type.
|
||||
func (rrCache *RRCache) ID() string {
|
||||
return rrCache.Domain + rrCache.Question.String()
|
||||
}
|
||||
|
||||
// Expired returns whether the record has expired.
|
||||
func (rrCache *RRCache) Expired() bool {
|
||||
return rrCache.TTL <= time.Now().Unix()
|
||||
@@ -70,6 +75,11 @@ func (rrCache *RRCache) Clean(minExpires uint32) {
|
||||
lowestTTL = minExpires
|
||||
}
|
||||
|
||||
// shorten NXDomain caching
|
||||
if len(rrCache.Answer) == 0 {
|
||||
lowestTTL = 10
|
||||
}
|
||||
|
||||
// log.Tracef("lowest TTL is %d", lowestTTL)
|
||||
rrCache.TTL = time.Now().Unix() + int64(lowestTTL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user