Merge pull request #101 from digineo/tcpaddr
Use net.TCPAddr to extract remote IP address
This commit is contained in:
		
						commit
						c2fc7f0a5a
					
				
							
								
								
									
										8
									
								
								ftp.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								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
 | 
						// 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.
 | 
						// If we use the domain name, we might not resolve to the same IP.
 | 
				
			||||||
	remoteAddr := tconn.RemoteAddr().String()
 | 
						remoteAddr := tconn.RemoteAddr().(*net.TCPAddr)
 | 
				
			||||||
	host, _, err := net.SplitHostPort(remoteAddr)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conn := textproto.NewConn(tconn)
 | 
						conn := textproto.NewConn(tconn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := &ServerConn{
 | 
						c := &ServerConn{
 | 
				
			||||||
		conn:     conn,
 | 
							conn:     conn,
 | 
				
			||||||
		host:     host,
 | 
							host:     remoteAddr.IP.String(),
 | 
				
			||||||
		timeout:  timeout,
 | 
							timeout:  timeout,
 | 
				
			||||||
		features: make(map[string]string),
 | 
							features: make(map[string]string),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user