// SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr
// Returns nil if conversion fails.
978058
func SockaddrToUDPAddr(sa Sockaddr) *net.UDPAddr {
	ip, zone := SockaddrToIPAndZone(sa)
	switch sa := sa.(type) {
	case *SockaddrInet4:
		return &net.UDPAddr{IP: ip, Port: sa.Port}
	case *SockaddrInet6:
		return &net.UDPAddr{IP: ip, Port: sa.Port, Zone: zone}
	}
	return nil
}
586284
func (t *Transport) PeerAddr(id uint64) (string, error) {
	t.mu.Lock()
	defer t.mu.Unlock()
	p, ok := t.peers[id]
	if !ok {
		return "", ErrIsNotFound
	}
	return p.address(), nil
}
209111
func ifaceAddIPv4Addr(iface *net.Interface, ip net.IP, mask net.IPMask) error {
	if ip.To4() == nil {
		return fmt.Errorf("IP %v is not a valid IPv4 address", ip)
	}
	brd := make(net.IP, net.IPv4len)
	copy(brd, ip.To4())
	for i := 0; i < net.IPv4len; i++ {
		brd[i] |= ^mask[i]
	}
	prefixLen, _ := mask.Size()
	return ipRunIface(iface, "addr add %s/%d brd %s dev %s", ip, prefixLen, brd, iface.Name)
}
930072
func (c *Conn) RemoteAddr() net.Addr {
	if c.proxyLine != nil {
		return &c.proxyLine.Source
	}
	return c.Conn.RemoteAddr()
}
1036720
func getAddr(addr string) (string, error) {
	if strings.Compare(addr, "0.0.0.0") == 0 {
		addrs, err := net.InterfaceAddrs()
		if err != nil {
			return "", err
		}
		for _, address := range addrs {
			// check the address type and if it is not a loopback the display it
			if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
				if ipnet.IP.To4() != nil {
					return ipnet.IP.String(), nil
				}
			}
		}
	}
	return addr, nil
}
678687
func SockaddrToAny(sa sockaddrnet.Sockaddr) (*sockaddrnet.RawSockaddrAny, Socklen, error) {
	return sockaddrToAny(sa)
}
935888
func (cl *Client) publicAddr(peer net.IP) IpPort {
	return IpPort{cl.publicIp(peer), uint16(cl.incomingPeerPort())}
}
303208
func (nc *Conn) ConnectedAddr() string {
	if nc == nil {
		return _EMPTY_
	}

	nc.mu.RLock()
	defer nc.mu.RUnlock()

	if nc.status != CONNECTED {
		return _EMPTY_
	}
	return nc.conn.RemoteAddr().String()
}
288818
func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
	return e.AppendString(dst, ip.String())
}
110508
func (p *Peer) LocalAddr() net.Addr {
	var localAddr net.Addr
	if atomic.LoadInt32(&p.connected) != 0 {
		localAddr = p.conn.LocalAddr()
	}
	return localAddr
}
583152
func guiAddr(conn api.Connection) string {
	if dnsName := conn.PublicDNSName(); dnsName != "" {
		return dnsName
	}
	return conn.Addr()
}
427150
func lookupAddr(ctx context.Context, resolver *net.Resolver, host string) (string, error) {
	// Resolve the IP address or hostname to an IP address.
	addrs, err := resolver.LookupIPAddr(ctx, host)
	if err != nil {
		return "", errors.Wrap(err, "looking up IP addresses")
	}
	if len(addrs) == 0 {
		return "", fmt.Errorf("cannot resolve %q to an address", host)
	}

	// LookupIPAddr() can return a mix of IPv6 and IPv4
	// addresses. Return the first IPv4 address if possible.
	for _, addr := range addrs {
		if ip := addr.IP.To4(); ip != nil {
			return ip.String(), nil
		}
	}

	// No IPv4 address, return the first resolved address instead.
	return addrs[0].String(), nil
}
715832
func (s *ResourceState) ProviderAddr() (addrs.AbsProviderConfig, error) {
	var diags tfdiags.Diagnostics

	str := s.Provider
	traversal, travDiags := hclsyntax.ParseTraversalAbs([]byte(str), "", hcl.Pos{Line: 1, Column: 1})
	diags = diags.Append(travDiags)
	if travDiags.HasErrors() {
		return addrs.AbsProviderConfig{}, diags.Err()
	}

	addr, addrDiags := addrs.ParseAbsProviderConfig(traversal)
	diags = diags.Append(addrDiags)
	return addr, diags.Err()
}
399960
func (c *connector) RemoteAddr() string {
	if nil != c.conn {
		return c.conn.RemoteAddr().String()
	}

	return ""
}
115070
func ResolveIPv4Addrs(addr string) ([]string, error) {
	host, port, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, err
	}
	ipAddrs, err := net.LookupIP(host)
	if err != nil {
		return nil, err
	}
	result := make([]string, 0, len(ipAddrs))
	for _, ipAddr := range ipAddrs {
		ipv4 := ipAddr.To4()
		if ipv4 != nil {
			result = append(result, net.JoinHostPort(ipv4.String(), port))
		}
	}
	if len(result) == 0 {
		return nil, fmt.Errorf("no IPv4addr for name %v", host)
	}
	return result, nil
}
1355218
func (p *Pinger) SetIPAddr(ipaddr *net.IPAddr) {
	var ipv4 bool
	if isIPv4(ipaddr.IP) {
		ipv4 = true
	} else if isIPv6(ipaddr.IP) {
		ipv4 = false
	}

	p.ipaddr = ipaddr
	p.addr = ipaddr.String()
	p.ipv4 = ipv4
}
1044614
func hostAddr(addr string) string {
	_, port := splitHostPort(addr)
	if port == "" {
		return addr + ":443"
	}
	return addr
}