Estab TLS connections + Handshake should respect DialTimeout

This commit is contained in:
josh-tepper 2018-06-27 19:34:47 -04:00
parent 8a90ef696e
commit 8c513f1b88
1 changed files with 5 additions and 5 deletions

View File

@ -85,12 +85,12 @@ func (opt *Options) init() {
} }
if opt.Dialer == nil { if opt.Dialer == nil {
opt.Dialer = func() (net.Conn, error) { opt.Dialer = func() (net.Conn, error) {
conn, err := net.DialTimeout(opt.Network, opt.Addr, opt.DialTimeout) netDialer := &net.Dialer{Timeout: opt.DialTimeout}
if opt.TLSConfig == nil || err != nil { if opt.TLSConfig == nil {
return conn, err return netDialer.Dial(opt.Network, opt.Addr)
} else {
return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig)
} }
t := tls.Client(conn, opt.TLSConfig)
return t, t.Handshake()
} }
} }
if opt.PoolSize == 0 { if opt.PoolSize == 0 {