From 560aa24383868c4d73995a4938775549801f5fc9 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 19 Dec 2019 14:20:08 +0800 Subject: [PATCH] mcclient: proxy setting aware by using httputils' transport --- pkg/mcclient/mcclient.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/mcclient/mcclient.go b/pkg/mcclient/mcclient.go index e088791128..259177da5e 100644 --- a/pkg/mcclient/mcclient.go +++ b/pkg/mcclient/mcclient.go @@ -19,7 +19,6 @@ import ( "crypto/tls" "fmt" "io" - "net" "net/http" "strings" "time" @@ -58,14 +57,10 @@ func NewClient(authUrl string, timeout int, debug bool, insecure bool, certFile, } tlsConf.InsecureSkipVerify = insecure - tr := &http.Transport{ - TLSClientConfig: tlsConf, - DialContext: (&net.Dialer{ - Timeout: 5 * time.Second, - }).DialContext, - IdleConnTimeout: 5 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - } + tr := httputils.GetTransport(insecure, 5*time.Second) + tr.TLSClientConfig = tlsConf + tr.IdleConnTimeout = 5 * time.Second + tr.TLSHandshakeTimeout = 10 * time.Second client := Client{authUrl: authUrl, timeout: timeout,