/*
Check if IP filter is active
322072
public function isAvailable($quote = null)
    {
        $isAvailable = parent::isAvailable($quote);
        // check if ip range is enabled
        $ipFilter = $this->_getConfigData('ip_filter', 'adyen_cash');

        if ($isAvailable && $ipFilter) {
            // check if ip is in range
            $ip = Mage::helper('adyen')->getClientIp();
            $from = $this->_getConfigData('ip_filter_from', 'adyen_cash');
            $to = $this->_getConfigData('ip_filter_to', 'adyen_cash');
            $isAvailable = Mage::helper('adyen')->ipInRange($ip, $from, $to);
        }

        return $isAvailable;
    }
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
424264
public static onlinkipv6prefix[] get_filtered(nitro_service service, String filter) throws Exception{
		onlinkipv6prefix obj = new onlinkipv6prefix();
		options option = new options();
		option.set_filter(filter);
		onlinkipv6prefix[] response = (onlinkipv6prefix[]) obj.getfiltered(service, option);
		return response;
	}
1365053
protected function validateIp($ip)
    {
        $filter = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
        return filter_var($ip, FILTER_VALIDATE_IP, $filter);
    }
228247
function ispublic($addr) {
		return (bool)filter_var($addr,FILTER_VALIDATE_IP,
			FILTER_FLAG_IPV4|FILTER_FLAG_IPV6|
			FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE);
	}
707873
function filter(socket, message, rinfo) {
  const isAllowedAddress = socket.remoteAddress === rinfo.address;
  const isAllowedPort = socket.remotePort === rinfo.port;

  return isAllowedAddress && isAllowedPort;
}
378737
public function isAllowed ($ip, $priority = 'deny,allow')
	{
		
		// Convert IP to decimal
		
		$ipDec = (float)sprintf ("%u", ip2long ($ip));
		
		// Check
		
		foreach (explode (',', $priority) as $type)
		{
			
			switch ($type)
			{
				
				// Check if the IP is allowed
				
				case 'allow':
					
					foreach ($this->allowIPs as $name => $range)
					{
						if ($this->isInside ($ipDec, $name, $range))
						{
							return TRUE;
						}
					}
					
					break;
				
				// Check if IP is denied
					
				case 'deny':
					
					foreach ($this->denyIPs as $name => $range)
					{
						if ($this->isInside ($ipDec, $name, $range))
						{
							return FALSE;
						}
					}
					
					break;
				
			}
			
		}
		
		// Not allowed by default
		
		return FALSE;
		
	}
386749
def is_api_filter(self, filter_field):
        """"""
        if self.filter_type == 'server':
            for choice in self.filter_choices:
                if (choice[0] == filter_field and len(choice) > 2 and
                        choice[2]):
                    return True
        return False
367945
def detect(self):
        
        if self.opts_url and self.opts_parser:
            url = self.opts_url
            parser = self.opts_parser
        else:
            url, parser = choice(self.urls)  # noqa: S311
        parser = globals().get("_parser_" + parser)
        theip = _get_ip_from_url(url, parser)
        if theip is None:
            LOG.info("Could not detect IP using webcheck! Offline?")
        self.set_current_value(theip)
        return theip
24722
def set_neighbor_out_filter(neigh_ip_address, filters):
    """"""
    core = CORE_MANAGER.get_core_service()
    peer = core.peer_manager.get_by_addr(neigh_ip_address)
    peer.out_filters = filters
    return True
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
296042
def get_neighbor_in_filter(neigh_ip_address):
    """"""
    core = CORE_MANAGER.get_core_service()
    peer = core.peer_manager.get_by_addr(neigh_ip_address)
    return peer.in_filters
1008406
static function isIPInNet( $ipaddress, $network, $mask = 24 )
    {
        $lnet = ip2long( $network );
        $lip = ip2long( $ipaddress );
        $binnet = str_pad( decbin( $lnet ), 32, '0', STR_PAD_LEFT );
        $firstpart = substr( $binnet, 0, $mask );
        $binip = str_pad( decbin( $lip ), 32, '0', STR_PAD_LEFT );
        $firstip = substr( $binip, 0, $mask );
        return( strcmp( $firstpart, $firstip ) == 0 );
    }
315500
def set_neighbor_in_filter(neigh_ip_address, filters):
    """"""
    core = CORE_MANAGER.get_core_service()
    peer = core.peer_manager.get_by_addr(neigh_ip_address)
    peer.in_filters = filters
    return True
1298612
def needs_check(self):
        
        if self.lastcheck is None:
            return True
        return time.time() - self.lastcheck >= self.ipchangedetection_sleep
1168552
protected function ipMatchesWhitelist()
    {
        $whitelist = $this->getWhitelistedIps();
        // Continue if no whitelist is defined
        if (empty($whitelist)) {
            return false;
        }

        $userIp = $_SERVER['REMOTE_ADDR'];
        if (in_array($userIp, $whitelist)) {
            return true;
        }

        return false;
    }
803541
def check_ip(ip, log=False):
        """"""
        if log:
            print('Checking ip: {}...'.format(ip))

        request_timeout = 0.1

        try:
            tv_url = 'http://{}:6095/request?action=isalive'.format(ip)
            request = requests.get(tv_url, timeout=request_timeout)
        except requests.exceptions.ConnectTimeout:
            return False

        return request.status_code == 200