Skip to content

Commit

Permalink
chore: optimize tls cert expire check
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma committed Jul 23, 2024
1 parent 29ab308 commit 24bfcd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/daemon/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 24bfcd7

Please sign in to comment.