// RemoteAddr implements the RemoteAddr interface of the connection.
// This is the main change where we actually use the FD of the unix
// socket to find the remote UID.
549446
func (c UIDConnection) RemoteAddr() net.Addr {

	uidAddr := &UIDAddr{
		NetworkAddress: c.nc.RemoteAddr().Network(),
	}

	f, err := c.nc.File()
	if err != nil {
		uidAddr.Address = "NotAvailable"
	}
	defer f.Close() // nolint

	cred, err := syscall.GetsockoptUcred(int(f.Fd()), syscall.SOL_SOCKET, syscall.SO_PEERCRED)
	if err != nil {
		uidAddr.Address = "NotAvailable"
	}

	uidAddr.Address = strconv.Itoa(int(cred.Uid)) + ":" + strconv.Itoa(int(cred.Gid)) + ":" + strconv.Itoa(int(cred.Pid))

	return uidAddr

}
968243
func (s *Stream) RemoteAddr() net.Addr {
	if ts, ok := s.sess.conn.(interface {
		RemoteAddr() net.Addr
	}); ok {
		return ts.RemoteAddr()
	}
	return nil
}
1207487
func (ra *RemoteAddr) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
	ra.handleActualRequest(w, r)
	next(w, r)
}
81390
func encodeRemoteAddr(remoteAddr net.Addr) []byte {
	if udpAddr, ok := remoteAddr.(*net.UDPAddr); ok {
		return append([]byte{cookiePrefixIP}, udpAddr.IP...)
	}
	return append([]byte{cookiePrefixString}, []byte(remoteAddr.String())...)
}
399960
func (c *connector) RemoteAddr() string {
	if nil != c.conn {
		return c.conn.RemoteAddr().String()
	}

	return ""
}
1064786
func UnixAddrToSockaddr(addr *net.UnixAddr) (Sockaddr, int) {
	t := 0
	switch addr.Net {
	case "unix":
		t = SOCK_STREAM
	case "unixgram":
		t = SOCK_DGRAM
	case "unixpacket":
		t = SOCK_SEQPACKET
	default:
		return nil, 0
	}
	return &SockaddrUnix{Name: addr.Name}, t
}
1116152
func (a *Array) IPAddr(ip net.IP) *Array {
	a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip)
	return a
}
459856
func (c *Conn) LocalAddr() net.Addr {
	a, err := c.ep.GetLocalAddress()
	if err != nil {
		return nil
	}
	return fullToTCPAddr(a)
}
1248052
func canonicalAddr(url *url.URL) string {
	addr := url.Host
	if !hasPort(addr) {
		if strings.HasPrefix(addr, "[") && strings.HasSuffix(addr, "]") {
			addr = addr[1 : len(addr)-1]
		}
		return net.JoinHostPort(addr, portMap[url.Scheme])
	}
	return addr
}
607097
func (c *client) RemoteAddress() net.Addr {
	c.mu.Lock()
	defer c.mu.Unlock()

	if c.nc == nil {
		return nil
	}

	return c.nc.RemoteAddr()
}
66265
func (c *Conn) RemoteAddr() ble.Addr {
	a := c.param.PeerAddress()
	return net.HardwareAddr([]byte{a[5], a[4], a[3], a[2], a[1], a[0]})
}
1199427
func (c *managedConnImpl) LocalAddr() net.Addr {
	conn, _ := c.rawConn()
	return conn.LocalAddr()
}
583152
func guiAddr(conn api.Connection) string {
	if dnsName := conn.PublicDNSName(); dnsName != "" {
		return dnsName
	}
	return conn.Addr()
}
286334
func (mgr *AddrSubManager) BroadcastAddr(p peer.ID, addr ma.Multiaddr) {
	mgr.mu.RLock()
	defer mgr.mu.RUnlock()

	if subs, ok := mgr.subs[p]; ok {
		for _, sub := range subs {
			sub.pubAddr(addr)
		}
	}
}
951530
func (sl *ServerLookup) ServerAddr(id raft.ServerID) (raft.ServerAddress, error) {
	sl.lock.RLock()
	defer sl.lock.RUnlock()
	svr, ok := sl.idToServer[id]
	if !ok {
		return "", fmt.Errorf("Could not find address for server id %v", id)
	}
	return raft.ServerAddress(svr.Addr.String()), nil
}
66405
func (c *Connection) LocalAddr() net.Addr {
	if conn, ok := c.conn.(interface {
		LocalAddr() net.Addr
	}); ok {
		return conn.LocalAddr()
	}
	return &net.TCPAddr{}
}
1199375
func WithRemoteAddr(addr string) DaemonOpt {
	return func(r *remote) error {
		r.GRPC.Address = addr
		return nil
	}
}