Get preferred IP for given endpoint if it is known. Otherwise this returns given endpoint itself.

@param ep endpoint address to check
@return Preferred IP for given endpoint if present, otherwise returns given ep
486465
public static InetAddress getPreferredIP(InetAddress ep)
    {
        String req = "SELECT preferred_ip FROM system.%s WHERE peer=?";
        UntypedResultSet result = executeInternal(String.format(req, PEERS_CF), ep);
        if (!result.isEmpty() && result.one().has("preferred_ip"))
            return result.one().getInetAddress("preferred_ip");
        return ep;
    }
176872
public InetAddress getInetAddress() throws UnknownHostException{
     if(ip!=null) return ip;

     return (ip=InetAddress.getByName(host));
   }
564550
public static String getAddressForUrl(String address, boolean resolveForIp) {
        if (address == null) {
            return null;
        }

        // drop schema
        int pos = address.indexOf("://");
        if (pos > 0) {
            address = address.substring(pos + 3);
        }

        // drop user authentication information
        pos = address.indexOf('@');
        if (pos > 0) {
            address = address.substring(pos + 1);
        }

        // drop trailing parts: port number, query parameters, path, fragment
        for (int i = 0; i < address.length(); ++i) {
            char c = address.charAt(i);
            if ((c == ':') || (c == '?') || (c == '/') || (c == '#')) {
                return address.substring(0, i);
            }
        }
        return address;
    }
1249199
private InetAddress minEndpoint()
    {
        return FBUtilities.compareUnsigned(r1.endpoint.getAddress(), r2.endpoint.getAddress()) < 0
             ? r1.endpoint
             : r2.endpoint;
    }
657948
public IPRangeNode get(InetAddress addr) {

	if (version == 0) // no data was added
	    return null;

	IPRangeNode node = isV4(addr) ? ipv4 : ipv6;

	if (!this.isSorted) this.optimize();

	return node.findFast(addr);
    }
599110
def get_client_ip(request):
    
    # set the default value of the ip to be the REMOTE_ADDR if available
    # else None
    ip = request.META.get('REMOTE_ADDR')
    # try to get the first non-proxy ip (not a private ip) from the
    # HTTP_X_FORWARDED_FOR
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        proxies = x_forwarded_for.split(',')
        # remove the private ips from the beginning
        proxies = [proxy for proxy in proxies
                   if not proxy.startswith(settings.PRIVATE_IPS_PREFIX)]
        # take the first ip which is not a private one (of a proxy)
        if len(proxies) > 0:
            ip = proxies[0]

    return ip
1293011
def get_local_ep(*args, **kwargs):
    
    if kwargs.get("warn", True):
        raise DeprecationWarning("'get_local_ep()' has been deprecated in favor of "
                                 "'globus_sdk.LocalGlobusConnectPersonal().endpoint_id'. "
                                 "To override, pass in 'warn=False'.")
    else:
        import warnings
        warnings.warn("'get_local_ep()' has been deprecated in favor of "
                      "'globus_sdk.LocalGlobusConnectPersonal().endpoint_id'.")
    return globus_sdk.LocalGlobusConnectPersonal().endpoint_id
509558
public com.google.protobuf.ByteString
      getServerIpBytes() {
    java.lang.Object ref = serverIp_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      serverIp_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
158854
public static String getClientIpAddr(HttpServletRequest request) {
        for (String header : HEADERS_ABOUT_CLIENT_IP) {
            String ip = request.getHeader(header);
            if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
                return ip;
            }
        }
        return request.getRemoteAddr();
    }
587518
function selectEndPoint (local) {
  var endPoint;
  // Use an existing datagram socket if one exists.
  if (local.port == 0) {
    endPoint = createEndPoint(local);
  } else if (!(endPoint = lookupEndPoint(local))) {
    endPoint = createEndPoint(local);
  }
  return endPoint;
}
843630
public List<String> getVhost(String address, String port) {
        if (null == address || null == port) {
            return null;
        }
        int portnum = Integer.parseInt(port);
        List<EndPointInfo> eps = EndPointMgrImpl.getRef().getEndPoints(address, portnum);
        List<String> rc = new ArrayList<String>(eps.size());
        for (EndPointInfo ep : eps) {
            rc.add(ep.getName());
        }
        return rc;
    }
814852
public InetAddress getRemoteAddress() {
        final Channel channel;
        try {
            channel = strategy.getChannel();
        } catch (IOException e) {
            return null;
        }
        final Connection connection = channel.getConnection();
        final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
        return peerAddress == null ? null : peerAddress.getAddress();
    }
936137
public static String getIP(final InetAddress inetAddress)
	{
		String ip = "";
		ip = inetAddress.getHostAddress();
		if (ip.equals(""))
		{
			final byte[] ipAddressInBytes = inetAddress.getAddress();
			for (int i = 0; i < ipAddressInBytes.length; i++)
			{
				if (i > 0)
				{
					ip += ".";
				}
				ip += ipAddressInBytes[i] & 0xFF;
			}
		}
		return ip;
	}
428915
def _get_service_endpoint(context, svc, region=None, public=True):
    
    region = _safe_region(region)
    # If a specific context is passed, use that. Otherwise, use the global
    # identity reference.
    context = context or identity
    url_type = {True: "public", False: "private"}[public]
    svc_obj = context.services.get(svc)
    if not svc_obj:
        return None
    ep = svc_obj.endpoints.get(region, {}).get(url_type)
    if not ep:
        # Try the "ALL" region, and substitute the actual region
        ep = svc_obj.endpoints.get("ALL", {}).get(url_type)
    return ep
281628
@Override
    public E lower(E e)
    {
        int idx = indexOf(e);
        if (idx >= 1)
        {
            return list.get(idx-1);
        }
        else
        {
            int ip = insertPoint(idx);
            if (ip >= 1)
            {
                return list.get(ip-1);
            }
            else
            {
                return null;
            }
        }
    }
1109034
def get_trusted_ip(request, right_most_proxy=False, trusted_proxies=TRUSTED_PROXY_LIST):
    
    warnings.warn('get_trusted_ip is deprecated and will be removed in 3.0.', DeprecationWarning)
    if trusted_proxies:
        meta_keys = ['HTTP_X_FORWARDED_FOR', 'X_FORWARDED_FOR']
        for key in meta_keys:
            value = request.META.get(key, request.META.get(key.replace('_', '-'), '')).strip()
            if value:
                ips = [ip.strip().lower() for ip in value.split(',')]
                if len(ips) > 1:
                    if right_most_proxy:
                        ips.reverse()
                    for proxy in trusted_proxies:
                        if proxy in ips[-1]:
                            return ips[0]
    return None
348521
def _findIPAddr(self):
        
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        try:
            s.connect(("google.com", 0))
            addr = s.getsockname()[0]
            # print('Using ip : {addr}'.format(addr=addr))
            s.close()
        except socket.error:
            raise NetworkInterfaceException(
                "Impossible to retrieve IP, please provide one manually"
            )
        return addr