fix dial stuck when connect to tls ftp without tls configuration
Signed-off-by: Cytown <cytown@gmail.com>
This commit is contained in:
parent
4edb16bfcd
commit
1edcd4b3ca
27
ftp.go
27
ftp.go
@ -161,11 +161,30 @@ func Dial(addr string, options ...DialOption) (*ServerConn, error) {
|
|||||||
host: remoteAddr.IP.String(),
|
host: remoteAddr.IP.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, err = c.conn.ReadResponse(StatusReady)
|
readyChan := make(chan error, 1)
|
||||||
if err != nil {
|
go func(c *ServerConn) {
|
||||||
_ = c.Quit()
|
_, _, err = c.conn.ReadResponse(StatusReady)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
_ = c.Quit()
|
||||||
|
readyChan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
readyChan <- nil
|
||||||
|
}(c)
|
||||||
|
|
||||||
|
readyTimeer := time.NewTimer(do.dialer.Timeout)
|
||||||
|
select {
|
||||||
|
case err = <-readyChan:{
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case <-readyTimeer.C:{
|
||||||
|
return nil, errors.New("Timeout waiting for server to be ready, maybe need TLS?")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close(readyChan)
|
||||||
|
|
||||||
if do.explicitTLS {
|
if do.explicitTLS {
|
||||||
if err := c.authTLS(); err != nil {
|
if err := c.authTLS(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user