From 812043a905ad9ec67b610e3e4ba7a7aabe076c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 6 Oct 2025 00:38:26 +0800 Subject: [PATCH] fix(dns): false-positive disable on deadline --- dns/dns.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dns/dns.go b/dns/dns.go index a078cd8..d76e854 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -132,7 +132,9 @@ func (ds *DNSList) lookupHostDoH(ctx context.Context, host string) (hosts []stri return nil } } - addr.disable(time.Hour) // no need to acquire write lock + if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) { + addr.disable(time.Hour) // no need to acquire write lock + } } return nil // not found, fallback to ds.b }) @@ -171,7 +173,7 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra defer cancel() } conn, err = dialer.DialContext(ctx, "tcp", addr.a) - if err != nil { + if err != nil && !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) { addr.disable(time.Hour) // no need to acquire write lock continue } @@ -181,7 +183,9 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra return nil } _ = tlsConn.Close() - addr.disable(time.Hour) // no need to acquire write lock + if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) { + addr.disable(time.Hour) // no need to acquire write lock + } } return nil })