If a client IP is specified, verify it is permitted.
439914
def check_client_ip(self, rule):
        """"""

        if not rule.get('from'):
            self.logdebug('no "from" requirement.\n')
            return True

        allow_from = rule.get('from')
        if not isinstance(allow_from, list):
            allow_from = [allow_from]
        client_ip = self.get_client_ip()

        if client_ip in allow_from:
            self.logdebug('client_ip %s in %s\n' % (client_ip, allow_from))
            return True
        else:
            self.logdebug('client_ip %s not in %s' % (client_ip, allow_from))
            return False
232782
def validate_address!(addr)
      ip = IPAddr.new(addr)

      unless ip.ipv4?
        raise NotImplementedError, 'Only IPv4 is supported by this library'
      end

      if addr.include?('/')
        raise ArgumentError, 'Please specify a host IP address (without mask)'
      end

      addr.to_s
    end
114068
def validate_ip(self):
        
        if self.request.app.get('_check_ip', False):
            ip_address, accept = self.check_ip()
            if not accept:
                raise web.HTTPUnauthorized()
997843
def is_ipv4(ip: str) -> bool:
    
    try:
        socket.inet_aton(ip)
    except socket.error:
        return False
    return True
836333
private function isIpWhitelisted()
    {
        $whitelist = $this->config->get('RateLimitWhitelist', [], true);
        if (in_array($this->ip, $whitelist)) {
            return true;
        }

        return false;
    }
391716
def _is_ipv4(self, ip):
        
        try:
            p = IPy.IP(ip)
        except ValueError:
            return False

        if p.version() == 4:
            return True
        return False
5167
def _supported_rule(protocol, ethertype):
        """"""
        if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
            return False

        if ethertype != n_const.IPv4:
            return False

        return True
82149
def _ip_frag_check(*args, func=None):
    """"""
    func = func or inspect.stack()[2][3]
    for var in args:
        dict_check(var, func=func)
        bufid = var.get('bufid')
        str_check(bufid[3], func=func)
        bool_check(var.get('mf'), func=func)
        ip_check(bufid[0], bufid[1], func=func)
        bytearray_check(var.get('header'), var.get('payload'), func=func)
        int_check(bufid[2], var.get('num'), var.get('fo'),
                  var.get('ihl'), var.get('tl'), func=func)
1024072
def check_ip(addr):
    '''
    
    '''

    try:
        addr = addr.rsplit('/', 1)
    except AttributeError:
        # Non-string passed
        return False

    if salt.utils.network.is_ipv4(addr[0]):
        try:
            if 1 <= int(addr[1]) <= 32:
                return True
        except ValueError:
            # Non-int subnet notation
            return False
        except IndexError:
            # No subnet notation used (i.e. just an IPv4 address)
            return True

    if salt.utils.network.is_ipv6(addr[0]):
        try:
            if 8 <= int(addr[1]) <= 128:
                return True
        except ValueError:
            # Non-int subnet notation
            return False
        except IndexError:
            # No subnet notation used (i.e. just an IPv4 address)
            return True

    return False
538462
private function isAllowed($ip) {
        // Look for a wildcard
        if (in_array('*', $this->params['allow'])) {
            // There is a wildcard in the list, all IP's are allowed
            return true;
        }

        // Remove IP's which is not of the same type as $ip before matching
        if ($this->isIPv6($ip)) {
            $list = array_filter($this->params['allow'], [$this, 'isIPv6']);
        } else {
            $list = array_filter($this->params['allow'], [$this, 'isIPv4']);
        }

        foreach ($list as $range) {
            if ((strpos($range, '/') !== false && $this->cidrMatch($ip, $range)) || $ip === $range) {
                return true;
            }
        }

        return false;
    }
1170867
def _permission_denied_check(request):
    '''

    '''
    allowed_ips = settings.EUL_INDEXER_ALLOWED_IPS
    if allowed_ips != "ANY" and not request.META['REMOTE_ADDR'] in allowed_ips:
        return True

    return False
1212429
def is_ip(address):
    
    try:
        # Test to see if already an IPv4/IPv6 address
        address = netaddr.IPAddress(address)
        return True
    except (netaddr.AddrFormatError, ValueError):
        return False
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
948910
private boolean verifyIpAddress(String ipAddress, X509Certificate certificate) {
        List<String> altNames = getSubjectAltNames(certificate, ALT_IPA_NAME);
        for (int i = 0, size = altNames.size(); i < size; i++) {
            if (ipAddress.equalsIgnoreCase(altNames.get(i))) {
                return true;
            }
        }

        X500Principal principal = certificate.getSubjectX500Principal();
        // RFC 2818 advises using the most specific name for matching.
        String cn = new DistinguishedNameParser(principal).findMostSpecific("cn");

        // NOTE: In case of empty Common Name (CN), not checking
        return (cn == null) || ipAddress.equalsIgnoreCase(cn);
    }
1209878
def ip_check(ip, netmask_expected=False):
    
    try:
        if netmask_expected:
            if "/" not in ip:
                raise netaddr.core.AddrFormatError()
            netaddr.IPNetwork(ip)
        else:
            netaddr.IPAddress(ip)
    except netaddr.core.AddrFormatError:
        if netmask_expected:
            raise ArgsError("Not a valid CIDR (%s)" % ip)
        else:
            raise ArgsError("Not a valid IP address (%s)" % ip)
    except Exception as e:
        raise ArgsError("Invalid format: %s" % str(e))
1157530
def is_whitelisted(self, request: AxesHttpRequest, credentials: dict = None) -> bool:  # pylint: disable=unused-argument
        

        if is_client_ip_address_whitelisted(request):
            return True

        if is_client_method_whitelisted(request):
            return True

        return False
901271
protected function validateIp($ip)
    {
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_IPV6) === false) {
            return false;
        }

        return true;
    }