From 98b30605584cb054924b4769b08d8c73d5c00d4c Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sun, 25 Jan 2026 22:40:48 +0800 Subject: [PATCH] chore: optimize timeout control in DoH TLS probe --- dns/doh.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dns/doh.go b/dns/doh.go index df0697ec..77534d52 100644 --- a/dns/doh.go +++ b/dns/doh.go @@ -725,14 +725,10 @@ func (doh *dnsOverHTTPS) tlsDial(ctx context.Context, network string, config *tl // TLS handshake dialTimeout will be used as connection deadLine. conn := tls.Client(rawConn, config) - err = conn.SetDeadline(time.Now().Add(dialTimeout)) - if err != nil { - // Must not happen in normal circumstances. - log.Errorln("cannot set deadline: %v", err) - return nil, err - } + ctx, cancel := context.WithTimeout(ctx, dialTimeout) + defer cancel() - err = conn.Handshake() + err = conn.HandshakeContext(ctx) if err != nil { defer conn.Close() return nil, err