From d3562ce3946ad9a38f652513dfc22fad4b42ebd4 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sat, 19 Nov 2022 22:48:04 +0800 Subject: [PATCH] fix: DoH recreate the connection multiple times --- dns/doh.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dns/doh.go b/dns/doh.go index 84135b72..6e3e8d88 100644 --- a/dns/doh.go +++ b/dns/doh.go @@ -12,6 +12,7 @@ import ( "net/url" "runtime" "strconv" + "strings" "sync" "time" @@ -140,7 +141,7 @@ func (doh *dnsOverHTTPS) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D. msg, err = doh.exchangeHTTPS(ctx, client, m) } - if err != nil { + if err != nil && !strings.Contains(err.Error(), "context canceled") { // If the request failed anyway, make sure we don't use this client. _, resErr := doh.resetClient(ctx, err)