From 15e8eb57d6084c1f20ab66f7ccef1421ef2a223a Mon Sep 17 00:00:00 2001 From: Viktor Sidorenko Date: Fri, 24 Jun 2022 17:37:27 +0300 Subject: [PATCH] fix http_proxy param Hello. In latest build of statping (v0.90.80) not worked http requests via http_proxy. This commit can fix this. --- utils/utils.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 794638f4..5bd9d564 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -9,7 +9,6 @@ import ( "io/ioutil" "net" "net/http" - "net/url" "os" "os/exec" "strconv" @@ -215,17 +214,9 @@ func HttpRequest(endpoint, method string, contentType interface{}, headers []str Proxy: http.ProxyFromEnvironment, DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { // redirect all connections to host specified in url - addr = strings.Split(req.URL.Host, ":")[0] + addr[strings.LastIndex(addr, ":"):] return dialer.DialContext(ctx, network, addr) }, } - if Params.GetString("HTTP_PROXY") != "" { - proxyUrl, err := url.Parse(Params.GetString("HTTP_PROXY")) - if err != nil { - return nil, nil, err - } - transport.Proxy = http.ProxyURL(proxyUrl) - } if customTLS != nil { transport.TLSClientConfig.RootCAs = customTLS.RootCAs transport.TLSClientConfig.Certificates = customTLS.Certificates