From 24bfcd71718b1f317f46de53f26f9f0883fc7c39 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Tue, 23 Jul 2024 18:32:56 +0800 Subject: [PATCH] chore: optimize tls cert expire check Signed-off-by: Jim Ma --- client/daemon/proxy/proxy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/daemon/proxy/proxy.go b/client/daemon/proxy/proxy.go index 9fc03a34892..01341b8fd03 100644 --- a/client/daemon/proxy/proxy.go +++ b/client/daemon/proxy/proxy.go @@ -459,7 +459,7 @@ func (proxy *Proxy) handleHTTPS(w http.ResponseWriter, r *http.Request) { proxy.cacheRWMutex.RLock() cached, hit := proxy.certCache.Get(cacheKey) proxy.cacheRWMutex.RUnlock() - if hit && time.Now().Before(cached.(*tls.Certificate).Leaf.NotAfter) { // If cache hit and the cert is not expired + if hit && time.Now().Before(cached.(*tls.Certificate).Leaf.NotAfter.Add(-time.Hour)) { // If cache hit and the cert is not expired logger.Debugf("TLS cert cache hit, cacheKey = <%s>", cacheKey) return cached.(*tls.Certificate), nil } @@ -629,7 +629,7 @@ func (proxy *Proxy) shouldUseDragonfly(req *http.Request) bool { if strings.Contains(rule.Redirect, "/") { u, err := url.Parse(rule.Regx.ReplaceAllString(req.URL.String(), rule.Redirect)) if err != nil { - logger.Errorf("failed to rewrite url", err) + logger.Errorf("failed to rewrite url: %s", err) return false } req.URL = u