Add a bool property for forcing Passive mode.

This commit is contained in:
Stephen Blankenship 2014-03-26 14:08:40 -05:00
parent fec71e62e4
commit d86e41199e

4
ftp.go
View File

@ -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