Try to determine the local IP address of the machine.
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()
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()
682090
def _wait_for_ip(name, session):
    '''
    
    '''
    start_time = datetime.now()
    status = None
    while status is None:
        status = get_vm_ip(name, session)
        if status is not None:
            # ignore APIPA address
            if status.startswith('169'):
                status = None
        check_time = datetime.now()
        delta = check_time - start_time
        log.debug(
            'Waited %s seconds for %s to report ip address...',
            delta.seconds, name
        )
        if delta.seconds > 180:
            log.warning('Timeout getting IP address')
            break
        time.sleep(5)
697889
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def check_last_ip(app):
        return LastIpCheck(app, conf)
    return check_last_ip
832399
def _check_ip_available(ip_addr):
    '''
    
    '''
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
        vm_config = vm_details['config']
        if ip_addr in vm_config['ip_address'] or vm_config['ip_address'] == ip_addr:
            log.debug('IP "%s" is already defined', ip_addr)
            return False

    log.debug('IP \'%s\' is available to be defined', ip_addr)
    return True
1160221
function DetectLocalIPAddress(callback, stream) {
        if (!DetectRTC.isWebRTCSupported) {
            return;
        }

        var isPublic = true,
            isIpv4 = true;
        getIPs(function(ip) {
            if (!ip) {
                callback(); // Pass nothing to tell that ICE-gathering-ended
            } else if (ip.match(regexIpv4Local)) {
                isPublic = false;
                callback('Local: ' + ip, isPublic, isIpv4);
            } else if (ip.match(regexIpv6)) { //via https://ourcodeworld.com/articles/read/257/how-to-get-the-client-ip-address-with-javascript-only
                isIpv4 = false;
                callback('Public: ' + ip, isPublic, isIpv4);
            } else {
                callback('Public: ' + ip, isPublic, isIpv4);
            }
        }, stream);
    }
102219
def _check_ip(ip: str) -> bool:
    
    address = ipaddress.IPv4Address(ip)
    return address in allowed_ips
93651
public static function getLocalIP() {
        $s = &$_SERVER;

        $ipAddress = $s['REMOTE_ADDR'];

        if (array_key_exists('HTTP_X_FORWARDED_FOR', $s)) {
            $temp = explode(',', $s['HTTP_X_FORWARDED_FOR']);
            $ipAddress = array_pop($temp);
        }

        $result = $ipAddress == '::1' ? "127.0.0.1" : $ipAddress;

        return $result;
    }
987126
def _get_ip(self, interface):
        
        if interface in ni.interfaces():
            addresses = ni.ifaddresses(interface)
            if ni.AF_INET in addresses:
                return addresses[ni.AF_INET][0]["addr"]
        return ""
122426
protected function checkIP()
    {
        if (getenv("HTTP_CLIENT_IP"))
            $this->_ip = getenv("HTTP_CLIENT_IP");
        elseif (getenv("HTTP_X_FORWARDED_FOR"))
            $this->_ip = getenv("HTTP_X_FORWARDED_FOR");
        else
            $this->_ip = getenv("REMOTE_ADDR");
    }
657328
def get_my_ip():
    """"""
    ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1]
    return ip.strip()
844898
def read_address(self, ip_address):
        
        '''
            
        '''
        
        title = '%s.read_address' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'ip_address': ip_address
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
    
    # report query
        self.iam.printer('Querying AWS region %s for properties of elastic ip %s.' % (self.iam.region_name, ip_address))
        
    # discover details associated with instance id
        try:
            response = self.connection.describe_addresses(PublicIps=[ ip_address ])
            address_info = response['Addresses'][0]
        except:
            raise AWSConnectionError(title)

    # create dictionary of instance details
        address_details = {
            'instance_id': '',
            'public_ip': '',
            'allocation_id': '',
            'association_id': '',
            'domain': '',
            'network_interface_id': '',
            'network_interface_owner_id': '',
            'private_ip_address': '',
            'tags': [],
            'region': self.iam.region_name
        }
        address_details = self.iam.ingest(address_info, address_details)

        return address_details
1317927
def get_conn_info(self):
        """"""
        return session.ConnectionInfo(self.request.remote_ip,
                                      self.request.cookies,
                                      self.request.arguments,
                                      self.request.headers,
                                      self.request.path)
545526
def __getIP(self, public):
        """"""

        maybeNot = (lambda x: x) if public else (lambda x: not x)
        nets_id = [net.id for net in self.networks if maybeNot(net.isPublic())]
        for s in self.systems:
            i = 0
            while True:
                value = s.getValue("net_interface.%d.connection" % i)
                if not value:
                    break
                if value in nets_id:
                    ip = s.getValue("net_interface.%d.ip" % i)
                    if ip:
                        return ip
                i += 1
        return None
1158821
def hasIP(self, ip):
        """"""

        for f in self.features:
            if (f.prop.startswith("net_interface.") and
                    f.prop.endswith(".ip") and f.value == ip):
                return True
        return False
619187
def local_ip():
    """"""
    try:
        ip = socket.gethostbyname(socket.gethostname())
    except IOError:
        ip = socket.gethostbyname('localhost')
    if ip.startswith('127.'):
        ip = get_local_ip_by_interfaces()
        if ip is None:
            ip = get_local_ip_by_socket()
    return ip
1315402
def get_ip(host):
    '''
    
    '''
    hosts = _list_hosts()
    if not hosts:
        return ''
    # Look for the op
    for addr in hosts:
        if host in hosts[addr]:
            return addr
    # ip not found
    return ''