From 908ca20afafbb3dbb069805f23adf5c128115388 Mon Sep 17 00:00:00 2001 From: fishg <1423545+fishg@users.noreply.github.com> Date: Sat, 2 Apr 2022 16:03:53 +0800 Subject: [PATCH] fix: dns over proxy may due to cancel request, but proxy live status is fine --- adapter/adapter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index 9b1a4fb3..dbb31bf0 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "net/url" + "strings" "time" "github.com/Dreamacro/clash/common/queue" @@ -39,7 +40,11 @@ func (p *Proxy) Dial(metadata *C.Metadata) (C.Conn, error) { // DialContext implements C.ProxyAdapter func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.Conn, error) { conn, err := p.ProxyAdapter.DialContext(ctx, metadata, opts...) - p.alive.Store(err == nil) + wasCancel := false + if err != nil { + wasCancel = strings.Contains(err.Error(), "operation was canceled") + } + p.alive.Store(err == nil || wasCancel) return conn, err }