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.
pull/1101/head
Viktor Sidorenko 2022-06-24 17:37:27 +03:00 committed by GitHub
parent b7ecf0c31b
commit 15e8eb57d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 9 deletions

View File

@ -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