From d86e41199e0a24d404826eceebb851e8b28df04b Mon Sep 17 00:00:00 2001 From: Stephen Blankenship Date: Wed, 26 Mar 2014 14:08:40 -0500 Subject: [PATCH] Add a bool property for forcing Passive mode. --- ftp.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ftp.go b/ftp.go index 24e0450..18b4034 100644 --- a/ftp.go +++ b/ftp.go @@ -27,6 +27,7 @@ type ServerConn struct { conn *textproto.Conn host string features map[string]string + Passive bool } // Entry describes a file and is returned by List(). @@ -58,6 +59,7 @@ func Connect(addr string) (*ServerConn, error) { conn: conn, host: a[0], features: make(map[string]string), + Passive: false, } _, _, err = c.conn.ReadResponse(StatusReady) @@ -203,7 +205,7 @@ func (c *ServerConn) openDataConn() (net.Conn, error) { // else -> PASV _, nat6Supported := c.features["nat6"] _, epsvSupported := c.features["EPSV"] - if nat6Supported || epsvSupported { + if !c.Passive && (nat6Supported || epsvSupported) { port, err = c.epsv() if err != nil { return nil, err