Use tls.Dialer to be able to use DialContext
This commit is contained in:
parent
45482d097e
commit
fa83b53d0e
16
ftp.go
16
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)
|
||||
|
Loading…
Reference in New Issue
Block a user