From c576db03ace36d86658a51f72063b5ef5ef866e0 Mon Sep 17 00:00:00 2001 From: geekeryy Date: Fri, 23 May 2025 14:34:34 +0800 Subject: [PATCH] Optimize TCP connection logic, use proxy settings in the environment instead of the original all_proxy environment variable check Signed-off-by: geekeryy --- netconn.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/netconn.go b/netconn.go index f5429e28..e6f64e56 100644 --- a/netconn.go +++ b/netconn.go @@ -50,16 +50,7 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade conn, err := NewWebsocket(dialURI.String(), tlsc, timeout, headers, websocketOptions) return conn, err case "mqtt", "tcp": - allProxy := os.Getenv("all_proxy") - if len(allProxy) == 0 { - conn, err := dialer.Dial("tcp", uri.Host) - if err != nil { - return nil, err - } - return conn, nil - } - proxyDialer := proxy.FromEnvironment() - + proxyDialer := proxy.FromEnvironmentUsing(dialer) conn, err := proxyDialer.Dial("tcp", uri.Host) if err != nil { return nil, err