From 8c513f1b884e3175ff396a819a0e1389df080b0b Mon Sep 17 00:00:00 2001 From: josh-tepper Date: Wed, 27 Jun 2018 19:34:47 -0400 Subject: [PATCH] Estab TLS connections + Handshake should respect DialTimeout --- options.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/options.go b/options.go index fd17cbb2..ebd0adb3 100644 --- a/options.go +++ b/options.go @@ -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 {