gofmt ftp.go
This commit is contained in:
parent
816272713b
commit
1b161dcaad
12
ftp.go
12
ftp.go
@ -153,7 +153,7 @@ func (c *ServerConn) epsv() (port int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// pasv issues an "PASV" command to get a port number for a data connection.
|
// pasv issues a "PASV" command to get a port number for a data connection.
|
||||||
func (c *ServerConn) pasv() (port int, err error) {
|
func (c *ServerConn) pasv() (port int, err error) {
|
||||||
_, line, err := c.cmd(StatusPassiveMode, "PASV")
|
_, line, err := c.cmd(StatusPassiveMode, "PASV")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -169,7 +169,7 @@ func (c *ServerConn) pasv() (port int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We have to split the response string
|
// We have to split the response string
|
||||||
pasvData := strings.Split(line[start+1 : end], ",")
|
pasvData := strings.Split(line[start+1:end], ",")
|
||||||
// Let's compute the port number
|
// Let's compute the port number
|
||||||
portPart1, err1 := strconv.Atoi(pasvData[4])
|
portPart1, err1 := strconv.Atoi(pasvData[4])
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
@ -184,7 +184,7 @@ func (c *ServerConn) pasv() (port int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recompose port
|
// Recompose port
|
||||||
port = portPart1 * 256 + portPart2
|
port = portPart1*256 + portPart2
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,8 +198,8 @@ func (c *ServerConn) openDataConn() (net.Conn, error) {
|
|||||||
|
|
||||||
// If features contains nat6 or EPSV => EPSV
|
// If features contains nat6 or EPSV => EPSV
|
||||||
// else -> PASV
|
// else -> PASV
|
||||||
_,nat6Supported := c.features["nat6"];
|
_, nat6Supported := c.features["nat6"]
|
||||||
_,epsvSupported := c.features["EPSV"];
|
_, epsvSupported := c.features["EPSV"]
|
||||||
if nat6Supported || epsvSupported {
|
if nat6Supported || epsvSupported {
|
||||||
port, err = c.epsv()
|
port, err = c.epsv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -212,7 +212,6 @@ func (c *ServerConn) openDataConn() (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Build the new net address string
|
// Build the new net address string
|
||||||
addr := fmt.Sprintf("%s:%d", c.host, port)
|
addr := fmt.Sprintf("%s:%d", c.host, port)
|
||||||
|
|
||||||
@ -467,4 +466,3 @@ func (r *response) Close() error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user