From c959af8edb48670c15b04cdad7eba36456eceddd Mon Sep 17 00:00:00 2001 From: eball Date: Wed, 22 Oct 2025 12:22:55 +0800 Subject: [PATCH] Enhance connection handling in proxyRaw function Refactor proxyRaw function to prioritize DialTLSContext and DialContext for establishing connections. --- middleware/proxy.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/middleware/proxy.go b/middleware/proxy.go index 2744bc4a8..6afeb5104 100644 --- a/middleware/proxy.go +++ b/middleware/proxy.go @@ -134,12 +134,18 @@ var DefaultProxyConfig = ProxyConfig{ func proxyRaw(t *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler { var dialFunc func(ctx context.Context, network, addr string) (net.Conn, error) if transport, ok := config.Transport.(*http.Transport); ok { - if transport.TLSClientConfig != nil { + switch { + case transport.DialTLSContext != nil: + dialFunc = transport.DialTLSContext + case transport.DialContext != nil: + dialFunc = transport.DialContext + case transport.TLSClientConfig != nil: d := tls.Dialer{ Config: transport.TLSClientConfig, } dialFunc = d.DialContext } + } if dialFunc == nil { var d net.Dialer