fix(dns): cache would never expire caused by #63 by accident (#87)

This commit is contained in:
mzz 2023-05-14 22:09:55 +08:00 committed by GitHub
parent 11d792e6a9
commit e0d3cb0ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,9 +134,9 @@ func (c *DnsController) LookupDnsRespCache(qname string, qtype dnsmessage.Type)
c.dnsCacheMu.Lock()
cache, ok := c.dnsCache[c.cacheKey(qname, qtype)]
c.dnsCacheMu.Unlock()
// We should make sure the remaining TTL is greater than 120s (minFirefoxCacheTimeout), or
// We should make sure the cache did not expire, or
// return nil and request a new lookup to refresh the cache.
if ok {
if ok && cache.Deadline.After(time.Now()) {
return cache
}
return nil