Add a bool property for forcing Passive mode.
This commit is contained in:
parent
fec71e62e4
commit
d86e41199e
4
ftp.go
4
ftp.go
@ -27,6 +27,7 @@ type ServerConn struct {
|
|||||||
conn *textproto.Conn
|
conn *textproto.Conn
|
||||||
host string
|
host string
|
||||||
features map[string]string
|
features map[string]string
|
||||||
|
Passive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry describes a file and is returned by List().
|
// Entry describes a file and is returned by List().
|
||||||
@ -58,6 +59,7 @@ func Connect(addr string) (*ServerConn, error) {
|
|||||||
conn: conn,
|
conn: conn,
|
||||||
host: a[0],
|
host: a[0],
|
||||||
features: make(map[string]string),
|
features: make(map[string]string),
|
||||||
|
Passive: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, err = c.conn.ReadResponse(StatusReady)
|
_, _, err = c.conn.ReadResponse(StatusReady)
|
||||||
@ -203,7 +205,7 @@ func (c *ServerConn) openDataConn() (net.Conn, error) {
|
|||||||
// else -> PASV
|
// else -> PASV
|
||||||
_, nat6Supported := c.features["nat6"]
|
_, nat6Supported := c.features["nat6"]
|
||||||
_, epsvSupported := c.features["EPSV"]
|
_, epsvSupported := c.features["EPSV"]
|
||||||
if nat6Supported || epsvSupported {
|
if !c.Passive && (nat6Supported || epsvSupported) {
|
||||||
port, err = c.epsv()
|
port, err = c.epsv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user