Force EPSV for IPv6 hosts and fix split of IPv6:port
This commit is contained in:
parent
460814bcb1
commit
691fac98af
@ -130,3 +130,23 @@ func TestConn2(t *testing.T) {
|
|||||||
|
|
||||||
c.Quit()
|
c.Quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// antioche.antioche.eu.org with IPv6
|
||||||
|
func TestConnIPv6(t *testing.T) {
|
||||||
|
c, err := Connect("[2001:660:3302:282a:204:75ff:fe9f:9e11]:21")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.Login("anonymous", "anonymous")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.List(".")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Quit()
|
||||||
|
}
|
||||||
|
8
ftp.go
8
ftp.go
@ -53,10 +53,10 @@ func Connect(addr string) (*ServerConn, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
a := strings.SplitN(addr, ":", 2)
|
a := addr[:strings.LastIndex(addr, ":")]
|
||||||
c := &ServerConn{
|
c := &ServerConn{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
host: a[0],
|
host: a,
|
||||||
features: make(map[string]string),
|
features: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +197,10 @@ 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 host is IPv6 => EPSV
|
||||||
|
if c.host[0] == '[' {
|
||||||
|
epsvSupported = true
|
||||||
|
}
|
||||||
if nat6Supported || epsvSupported {
|
if nat6Supported || epsvSupported {
|
||||||
port, err = c.epsv()
|
port, err = c.epsv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user