From 6bad3e176cc15f1846f122b65d487720055dc82f Mon Sep 17 00:00:00 2001 From: Arnaud Ysmal Date: Thu, 5 Dec 2013 19:29:22 +0100 Subject: [PATCH] Try EPSV when PASV fails --- ftp.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ftp.go b/ftp.go index 949a7b6..02f3c4c 100644 --- a/ftp.go +++ b/ftp.go @@ -200,20 +200,15 @@ func (c *ServerConn) openDataConn() (net.Conn, error) { // else -> PASV _, nat6Supported := c.features["nat6"] _, epsvSupported := c.features["EPSV"] - // If host is IPv6 => EPSV - if strings.ContainsAny(c.host, ":%") { - epsvSupported = true + + if !nat6Supported && !epsvSupported { + port, _ = c.pasv() } - if nat6Supported || epsvSupported { + if port == 0 { port, err = c.epsv() if err != nil { return nil, err } - } else { - port, err = c.pasv() - if err != nil { - return nil, err - } } // Build the new net address string