code: func newNetAddress(addr net.Addr, services wire.ServiceFlag) (*wire.NetAddress, error) {
  	// addr will be a net.TCPAddr when not using a proxy.
  	if tcpAddr, ok := addr.(*net.TCPAddr); ok {
  		ip := tcpAddr.IP
  		port := uint16(tcpAddr.Port)
  		na := wire.NewNetAddressIPPort(ip, port, services)
  		return na, nil
  	}
  
  	// addr will be a socks.ProxiedAddr when using a proxy.
  	if proxiedAddr, ok := addr.(*socks.ProxiedAddr); ok {
  		ip := net.ParseIP(proxiedAddr.Host)
  		if ip == nil {
  			ip = net.ParseIP("0.0.0.0")
  		}
  		port := uint16(proxiedAddr.Port)
  		na := wire.NewNetAddressIPPort(ip, port, services)
  		return na, nil
  	}
  
  	// For the most part, addr should be one of the two above cases, but
  	// to be safe, fall back to trying to parse the information from the
  	// address string as a last resort.
  	host, portStr, err := net.SplitHostPort(addr.String())
  	if err != nil {
  		return nil, err
  	}
  	ip := net.ParseIP(host)
  	port, err := strconv.ParseUint(portStr, 10, 16)
  	if err != nil {
  		return nil, err
  	}
  	na := wire.NewNetAddressIPPort(ip, uint16(port), services)
  	return na, nil
  }
docs: // newNetAddress attempts to extract the IP address and port from the passed
  // net.Addr interface and create a bitcoin NetAddress structure using that
  // information.