Makes the best attempt to get the client's real IP or return
        the loopback
322676
def get_ip_address_from_request(request):
    
    remote_addr = request.META.get('REMOTE_ADDR', '')
    if remote_addr and is_valid_ip(remote_addr):
        return remote_addr.strip()
    return '127.0.0.1'
444085
def get_public_ip(self, addr_family=None, *args, **kwargs):
        """"""
        return self.get_ip('public', addr_family, *args, **kwargs)
423360
def _get_local_ip(self):
        """"""
        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

            # Use Google Public DNS server to determine own IP
            sock.connect(('8.8.8.8', 80))

            return sock.getsockname()[0]
        except socket.error:
            try:
                return socket.gethostbyname(socket.gethostname())
            except socket.gaierror:
                return '127.0.0.1'
        finally:
            sock.close()
889054
def detect(self):
        
        theip = find_ip(family=self.opts_family)
        self.set_current_value(theip)
        return theip
468183
def ipinfo_ip_check(ip):
    """"""
    if not is_IPv4Address(ip):
        return None

    response = requests.get('http://ipinfo.io/%s/json' % ip)
    return response.json()
63456
def get_own_ip():
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        sock.connect(("8.8.8.8", 80))
    except socket.gaierror:
        ip_ = "127.0.0.1"
    else:
        ip_ = sock.getsockname()[0]
    finally:
        sock.close()
    return ip_
628953
function getClientIpFromXForwardedFor(value) {
    if (!is.existy(value)) {
        return null;
    }

    if (is.not.string(value)) {
        throw new TypeError(`Expected a string, got "${typeof value}"`);
    }

    // x-forwarded-for may return multiple IP addresses in the format:
    // "client IP, proxy 1 IP, proxy 2 IP"
    // Therefore, the right-most IP address is the IP address of the most recent proxy
    // and the left-most IP address is the IP address of the originating client.
    // source: http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
    // Azure Web App's also adds a port for some reason, so we'll only use the first part (the IP)
    const forwardedIps = value.split(',').map((e) => {
        const ip = e.trim();
        if (ip.includes(':')) {
            const splitted = ip.split(':');
            // make sure we only use this if it's ipv4 (ip:port)
            if (splitted.length === 2) {
                return splitted[0];
            }
        }
        return ip;
    });

    // Sometimes IP addresses in this header can be 'unknown' (http://stackoverflow.com/a/11285650).
    // Therefore taking the left-most IP address that is not unknown
    // A Squid configuration directive can also set the value to "unknown" (http://www.squid-cache.org/Doc/config/forwarded_for/)
    return forwardedIps.find(is.ip);
}
319984
def detect(self):
        """"""
        if self.opts_family == AF_INET6:
            kind = IPV6_PUBLIC
        else:  # 'INET':
            kind = IPV4
        theip = None
        try:
            theip = detect_ip(kind)
        except GetIpException:
            LOG.exception("socket detector raised an exception:")
        self.set_current_value(theip)
        return theip
610533
def get_user_ip(self, request):
        

        client_ip_address = None

        # searching the IP address
        for key in self.configuration.network.ip_meta_precedence_order:

            ip_meta_value = request.META.get(key, '').strip()

            if ip_meta_value != '':
                ips = [ip.strip().lower() for ip in ip_meta_value.split(',')]

                for ip_str in ips:

                    if ip_str and is_valid_ip(ip_str):

                        if not ip_str.startswith(self.configuration.network.non_public_ip_prefixes):
                            return ip_str

                        elif not self.configuration.network.real_ip_only:
                            loopback = ('127.0.0.1', '::1')

                            if client_ip_address is None:
                                client_ip_address = ip_str

                            elif client_ip_address in loopback and ip_str not in loopback:
                                client_ip_address = ip_str

        if client_ip_address is None and settings.DEBUG:
            raise DobermanImproperlyConfigured(
                "Unknown IP, maybe you are working on localhost/development, "
                "so please set in your setting: DOBERMAN_REAL_IP_ONLY=False"
            )

        return client_ip_address
1221725
def get_private_ip(self, addr_family=None, *args, **kwargs):
        """"""
        return self.get_ip('private', addr_family, *args, **kwargs)
4821
public String getRemoteRealAddr(String realIpHeader) {
        String host = getProxyRemoteAddr(realIpHeader);
        if (host == null || host.equals("unknown")) {
            host = getRemoteAddr();
        }

        return host;
    }
1292124
def get(self, floating_ip_id):
        
        fip = self.client.show_floatingip(floating_ip_id).get('floatingip')
        self._set_instance_info(fip)
        return FloatingIp(fip)
1167100
def get_ip_address_from_request(request):
    
    PRIVATE_IPS_PREFIX = ('10.', '172.', '192.', '127.')
    ip_address = ''
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '')
    if x_forwarded_for and ',' not in x_forwarded_for:
        if not x_forwarded_for.startswith(PRIVATE_IPS_PREFIX) and is_valid_ip(x_forwarded_for):
            ip_address = x_forwarded_for.strip()
    else:
        ips = [ip.strip() for ip in x_forwarded_for.split(',')]
        for ip in ips:
            if ip.startswith(PRIVATE_IPS_PREFIX):
                continue
            elif not is_valid_ip(ip):
                continue
            else:
                ip_address = ip
                break
    if not ip_address:
        x_real_ip = request.META.get('HTTP_X_REAL_IP', '')
        if x_real_ip:
            if not x_real_ip.startswith(PRIVATE_IPS_PREFIX) and is_valid_ip(x_real_ip):
                ip_address = x_real_ip.strip()
    if not ip_address:
        remote_addr = request.META.get('REMOTE_ADDR', '')
        if remote_addr:
            if not remote_addr.startswith(PRIVATE_IPS_PREFIX) and is_valid_ip(remote_addr):
                ip_address = remote_addr.strip()
            if remote_addr.startswith(PRIVATE_IPS_PREFIX) and is_valid_ip(remote_addr):
                ip_address = remote_addr.strip()
    if not ip_address:
            ip_address = '127.0.0.1'
    return ip_address
903338
def get_ip(request):
    
    if config.BEHIND_REVERSE_PROXY:
        ip_address = request.META.get(config.REVERSE_PROXY_HEADER, '')
        ip_address = ip_address.split(",", 1)[0].strip()
        if ip_address == '':
            ip_address = get_ip_address_from_request(request)
    else:
        ip_address = get_ip_address_from_request(request)
    return ip_address
1109848
function realIP (request) {
  return request.ip || request.headers['x-real-ip'] || request.headers['x-forwarded-for'] || request.info['remoteAddress']
}
1297192
def getClientIP(request):
    """"""
    forwardedfor = request.META.get('HTTP_X_FORWARDED_FOR')
    if forwardedfor:
        ip = forwardedfor.split(',')[0]
    else:
        ip = request.META.get('REMOTE_ADDR')

    return ip
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