From 057a0e1076068ebb20c987f2e9aebe96a8e550ec Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Tue, 9 May 2023 23:17:26 +0330 Subject: using the simpler proxyfromenv function from the stdlib --- arbiter/arbiter.go | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'arbiter/arbiter.go') diff --git a/arbiter/arbiter.go b/arbiter/arbiter.go index a9ce43d..8e2c999 100644 --- a/arbiter/arbiter.go +++ b/arbiter/arbiter.go @@ -6,9 +6,7 @@ import ( "encoding/json" "errors" "flag" - "fmt" "io" - "net" "net/http" "net/url" "os" @@ -21,7 +19,6 @@ import ( "github.com/gorilla/mux" "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "golang.org/x/net/proxy" ) var ( @@ -87,28 +84,9 @@ type errorChanStruct struct { } func GetProxiedClient() (*http.Client, error) { - proxyURL := os.Getenv("ALL_PROXY") - if proxyURL == "" { - proxyURL = os.Getenv("HTTPS_PROXY") - } - - dialer, err := proxy.SOCKS5("tcp", proxyURL, nil, proxy.Direct) - if err != nil { - return nil, fmt.Errorf("[GetProxiedClient] : %w", err) - } - - dialContext := func(ctx context.Context, network, address string) (net.Conn, error) { - netConn, err := dialer.Dial(network, address) - if err == nil { - return netConn, nil - } - - return netConn, fmt.Errorf("[dialContext] : %w", err) - } - transport := &http.Transport{ - DialContext: dialContext, DisableKeepAlives: true, + Proxy: http.ProxyFromEnvironment, } client := &http.Client{ Transport: transport, -- cgit v1.2.3