Merge 1edcd4b3ca1f294ab60e0e2cbabcebd0b1448f83 into 1b970516f5d3bc0fde96608989c97db26459371d

This commit is contained in:
Cytown 2024-10-07 15:06:30 +03:00 committed by GitHub
commit a8675ebf22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

27
ftp.go
View File

@ -161,11 +161,30 @@ func Dial(addr string, options ...DialOption) (*ServerConn, error) {
host: remoteAddr.IP.String(),
}
_, _, err = c.conn.ReadResponse(StatusReady)
if err != nil {
_ = c.Quit()
return nil, err
readyChan := make(chan error, 1)
go func(c *ServerConn) {
_, _, err = c.conn.ReadResponse(StatusReady)
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 err := c.authTLS(); err != nil {