Merge pull request #798 from josh-tepper/tls-respects-dial-timeout

Establishing TLS connections respect DialTimeout
This commit is contained in:
Vladimir Mihailenco 2018-06-29 09:21:45 +03:00 committed by GitHub
commit d409b91714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -85,12 +85,12 @@ func (opt *Options) init() {
}
if opt.Dialer == nil {
opt.Dialer = func() (net.Conn, error) {
conn, err := net.DialTimeout(opt.Network, opt.Addr, opt.DialTimeout)
if opt.TLSConfig == nil || err != nil {
return conn, err
netDialer := &net.Dialer{Timeout: opt.DialTimeout}
if opt.TLSConfig == nil {
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 {