From fa83b53d0e35def1ee9ca32470d08736bbc57094 Mon Sep 17 00:00:00 2001 From: Julien Laffaye Date: Wed, 17 Aug 2022 19:35:55 -0400 Subject: [PATCH] Use tls.Dialer to be able to use DialContext --- ftp.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ftp.go b/ftp.go index 6e994ab..7ad3ca1 100644 --- a/ftp.go +++ b/ftp.go @@ -110,16 +110,20 @@ func Dial(addr string, options ...DialOption) (*ServerConn, error) { dialFunc := do.dialFunc if dialFunc == nil { + ctx := do.context + + if ctx == nil { + ctx = context.Background() + } if do.tlsConfig != nil && !do.explicitTLS { dialFunc = func(network, address string) (net.Conn, error) { - return tls.DialWithDialer(&do.dialer, network, addr, do.tlsConfig) + tlsDialer := &tls.Dialer{ + NetDialer: &do.dialer, + Config: do.tlsConfig, + } + return tlsDialer.DialContext(ctx, network, addr) } } else { - ctx := do.context - - if ctx == nil { - ctx = context.Background() - } dialFunc = func(network, address string) (net.Conn, error) { return do.dialer.DialContext(ctx, network, addr)