Set timeouts for docker dialer
@@ -4,10 +4,15 @@ import (
"fmt"
"net"
"net/http"
+ "time"
"golang.org/x/crypto/ssh"
)
+const (
+ DockerDialerTimeout = 30
+)
+
type DialerFactory func(h *Host) (func(network, address string) (net.Conn, error), error)
type dialer struct {
@@ -105,9 +110,13 @@ func (h *Host) newHTTPClient(dialerFactory DialerFactory) (*http.Client, error)
if err != nil {
return nil, err
}
+ dockerDialerTimeout := time.Second * DockerDialerTimeout
return &http.Client{
Transport: &http.Transport{
Dial: dialer,
+ TLSHandshakeTimeout: dockerDialerTimeout,
+ IdleConnTimeout: dockerDialerTimeout,
+ ResponseHeaderTimeout: dockerDialerTimeout,
},
}, nil
}
