ServerConn::openDataConn() recursively tries to use EPSV and PASV.
This commit is contained in:
parent
f780314026
commit
e252713eb1
24
ftp.go
24
ftp.go
@ -217,28 +217,18 @@ func (c *ServerConn) pasv() (port int, err error) {
|
|||||||
|
|
||||||
// openDataConn creates a new FTP data connection.
|
// openDataConn creates a new FTP data connection.
|
||||||
func (c *ServerConn) openDataConn() (net.Conn, error) {
|
func (c *ServerConn) openDataConn() (net.Conn, error) {
|
||||||
var port int
|
var (
|
||||||
var err error
|
port int
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
// If features contains nat6 or EPSV => EPSV
|
if port, err = c.epsv(); err != nil {
|
||||||
// else -> PASV
|
if port, err = c.pasv(); err != nil {
|
||||||
_, nat6Supported := c.features["nat6"]
|
|
||||||
_, epsvSupported := c.features["EPSV"]
|
|
||||||
|
|
||||||
if !nat6Supported && !epsvSupported {
|
|
||||||
port, _ = c.pasv()
|
|
||||||
}
|
|
||||||
if port == 0 {
|
|
||||||
port, err = c.epsv()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the new net address string
|
return net.DialTimeout("tcp", net.JoinHostPort(c.host, strconv.Itoa(port)), c.timeout)
|
||||||
addr := net.JoinHostPort(c.host, strconv.Itoa(port))
|
|
||||||
|
|
||||||
return net.DialTimeout("tcp", addr, c.timeout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cmd is a helper function to execute a command and check for the expected FTP
|
// cmd is a helper function to execute a command and check for the expected FTP
|
||||||
|
Loading…
Reference in New Issue
Block a user