我需要创建一个返回自签名代理http.Client的函数,但是我找不到任何可行的解决方案。
我附加了我当前的代码,但似乎不起作用。
func CreateProxyClient(server string,serverProxy string, sid string, portProxy int) (*Client, error) {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
proxyURL, _ := url.Parse("http://" + serverProxy+":"+strconv.Itoa(portProxy) )
http.DefaultTransport = &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
var netClient = &http.Client{
Timeout: time.Second * 1,
}
resp, _ := http.Get("http://"+server+":443")
fmt.Printf("%d",resp.StatusCode)
return &Client{netClient, server, sid, "", ""}, nil
}我
发布于 2019-05-08 00:47:45
将此代码添加到http.Transport:
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),https://stackoverflow.com/questions/56021457
复制相似问题