Skip to content

Commit

Permalink
Merge pull request #101 from digineo/tcpaddr
Browse files Browse the repository at this point in the history
Use net.TCPAddr to extract remote IP address
  • Loading branch information
jlaffaye committed Dec 29, 2017
2 parents 299b7ff + f5cdbb9 commit c2fc7f0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,13 @@ func DialTimeout(addr string, timeout time.Duration) (*ServerConn, error) {

// Use the resolved IP address in case addr contains a domain name
// If we use the domain name, we might not resolve to the same IP.
remoteAddr := tconn.RemoteAddr().String()
host, _, err := net.SplitHostPort(remoteAddr)
if err != nil {
return nil, err
}
remoteAddr := tconn.RemoteAddr().(*net.TCPAddr)

conn := textproto.NewConn(tconn)

c := &ServerConn{
conn: conn,
host: host,
host: remoteAddr.IP.String(),
timeout: timeout,
features: make(map[string]string),
}
Expand Down

0 comments on commit c2fc7f0

Please sign in to comment.