diff --git a/api/client.go b/api/client.go index c141f00..6f55b3a 100644 --- a/api/client.go +++ b/api/client.go @@ -25,12 +25,13 @@ type Client struct { } type ClientConfig struct { - Email string - Token string - Timeout time.Duration - Retries int - API *url.URL - Proxy *url.URL + Email string + Token string + Timeout time.Duration + TLSHandshakeTimeout time.Duration + Retries int + API *url.URL + Proxy *url.URL Logger interface{} } @@ -62,6 +63,10 @@ func NewClient(config ClientConfig) *Client { DisableCompression: false, } + if config.TLSHandshakeTimeout.Seconds() > 0 { + transport.TLSHandshakeTimeout = config.TLSHandshakeTimeout + } + retryClient := retryablehttp.NewClient() retryClient.HTTPClient.Transport = transport retryClient.RetryWaitMin = config.Timeout diff --git a/config.go b/config.go index 3329662..470b5a3 100644 --- a/config.go +++ b/config.go @@ -18,21 +18,22 @@ import ( // Config describes the libkflow configuration. type Config struct { - email string - token string - capture Capture - proxy *url.URL - api *url.URL - flow *url.URL - metrics *url.URL - sample int - timeout time.Duration - retries int - logger interface{} - program string - version string - registry go_metrics.Registry - useInternalErrors bool + email string + token string + capture Capture + proxy *url.URL + api *url.URL + flow *url.URL + metrics *url.URL + sample int + timeout time.Duration + tlsHandshakeTimeout time.Duration + retries int + logger interface{} + program string + version string + registry go_metrics.Registry + useInternalErrors bool metricsPrefix string metricsInterval time.Duration @@ -93,6 +94,11 @@ func (c *Config) SetTimeout(timeout time.Duration) { c.timeout = timeout } +// SetTLSHandshakeTimeout sets the TLSHandshakeTimeout on the http client's Transport +func (c *Config) SetTLSHandshakeTimeout(timeout time.Duration) { + c.tlsHandshakeTimeout = timeout +} + // SetRetries sets the number of times to try HTTP requests. func (c *Config) SetRetries(retries int) { c.retries = retries