mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-16 20:11:09 +00:00
Add timeouts to the probe http client
This commit is contained in:
@@ -82,7 +82,8 @@ func NewAppClient(pc ProbeConfig, hostname string, target url.URL, control xfer.
|
||||
Timeout: httpClientTimeout,
|
||||
},
|
||||
wsDialer: websocket.Dialer{
|
||||
TLSClientConfig: httpTransport.TLSClientConfig,
|
||||
TLSClientConfig: httpTransport.TLSClientConfig,
|
||||
HandshakeTimeout: httpClientTimeout,
|
||||
},
|
||||
conns: map[string]xfer.Websocket{},
|
||||
readers: make(chan io.Reader, 2),
|
||||
|
||||
@@ -44,16 +44,24 @@ func (pc ProbeConfig) authorizedRequest(method string, urlStr string, body io.Re
|
||||
}
|
||||
|
||||
func (pc ProbeConfig) getHTTPTransport(hostname string) (*http.Transport, error) {
|
||||
var tlsConfig *tls.Config
|
||||
if pc.Insecure {
|
||||
return &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
tlsConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
} else {
|
||||
tlsConfig = &tls.Config{
|
||||
RootCAs: certPool,
|
||||
ServerName: hostname,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return &http.Transport{
|
||||
TLSClientConfig: tlsConfig,
|
||||
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext,
|
||||
IdleConnTimeout: http.DefaultTransport.IdleConnTimeout,
|
||||
TLSHandshakeTimeout: http.DefaultTransport.TLSHandshakeTimeout,
|
||||
ExpectContinueTimeout: http.DefaultTransport.ExpectContinueTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user