From e0d3cb0ecd4b10230d60290fe67b4e93602b0b94 Mon Sep 17 00:00:00 2001 From: mzz <2017@duck.com> Date: Sun, 14 May 2023 22:09:55 +0800 Subject: [PATCH] fix(dns): cache would never expire caused by #63 by accident (#87) --- control/dns_control.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control/dns_control.go b/control/dns_control.go index 96515b1..4251e99 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -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