From 717d86db2e0a0c2cda51dcd06c07960089c62189 Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Sun, 14 May 2023 20:41:47 +0800 Subject: [PATCH 1/3] fix: cache would never expire caused by #63 by accident --- control/dns_control.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/dns_control.go b/control/dns_control.go index 96515b1d33..d44b3767f5 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -136,7 +136,7 @@ func (c *DnsController) LookupDnsRespCache(qname string, qtype dnsmessage.Type) c.dnsCacheMu.Unlock() // We should make sure the remaining TTL is greater than 120s (minFirefoxCacheTimeout), 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 From 18f83d1c9ab9c2e332c416ca9b86f94d53c12769 Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Sun, 14 May 2023 21:24:27 +0800 Subject: [PATCH 2/3] fix notation --- control/dns_control.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/dns_control.go b/control/dns_control.go index d44b3767f5..2a1641401f 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -134,7 +134,7 @@ 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 does not expire, or // return nil and request a new lookup to refresh the cache. if ok && cache.Deadline.After(time.Now()) { return cache From ff4f39ed09c521679b4b3f290ad362bee0c56301 Mon Sep 17 00:00:00 2001 From: mzz <2017@duck.com> Date: Sun, 14 May 2023 22:08:37 +0800 Subject: [PATCH 3/3] Update control/dns_control.go --- control/dns_control.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/dns_control.go b/control/dns_control.go index 2a1641401f..4251e9996d 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -134,7 +134,7 @@ 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 cache does not expire, or + // We should make sure the cache did not expire, or // return nil and request a new lookup to refresh the cache. if ok && cache.Deadline.After(time.Now()) { return cache