From f5cdbb9f1e2ccfe491bd7a97cc90bf640819fbe5 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Sat, 12 Aug 2017 01:24:47 +0200 Subject: [PATCH] Use net.TCPAddr to extract remote IP address --- ftp.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ftp.go b/ftp.go index 1803423..d4ed100 100644 --- a/ftp.go +++ b/ftp.go @@ -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), }