given the ip, block it
546241
def block_ip(ip_address):
    
    if not ip_address:
        # no reason to continue when there is no ip
        return
    if config.DISABLE_IP_LOCKOUT:
        # no need to block, we disabled it.
        return
    key = get_ip_blocked_cache_key(ip_address)
    if config.COOLOFF_TIME:
        REDIS_SERVER.set(key, 'blocked', config.COOLOFF_TIME)
    else:
        REDIS_SERVER.set(key, 'blocked')
    send_ip_block_signal(ip_address)
1068402
def block_view(request):
    
    blocked_ip_list = get_blocked_ips()
    blocked_username_list = get_blocked_usernames()

    context = {'blocked_ip_list': blocked_ip_list,
               'blocked_username_list': blocked_username_list}
    return render(request, 'defender/admin/blocks.html', context)
697577
public static function ipCidrCheck($p_ip, $p_cidr)
    {
        if (strpos($p_cidr, '/') !== false) {
            list ($net, $mask) = split("/", $p_cidr);
            $ip_net            = ip2long($net);
            $ip_mask           = ~((1 << (32 - $mask)) - 1);
            $ip_ip             = ip2long($p_ip);
            $ip_ip_net         = $ip_ip & $ip_mask;
            
            return ($ip_ip_net == $ip_net);
        } else {
            return (ip2long($p_ip) == ip2long($p_cidr));
        }
    }
31179
def block(self, warn_only=False):
        """"""
        self._state = "not finished"
        if self._return_code is None:
            proc = subprocess.Popen(
                self.cmd, cwd=self.cwd, env=self.env,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
            self._stdout, self._stderr = proc.communicate(timeout=self.timeout)
            self._return_code = proc.returncode

        self._state = FINISHED
        if not warn_only:
            self.raise_for_error()
1775
async def main():
    """"""
    async with aiohttp.ClientSession() as session:
        data = Hole('192.168.0.215', loop, session)
        await data.get_data()

        # Get the raw data
        print(json.dumps(data.data, indent=4, sort_keys=True))

        print("Status:", data.status)
        print("Domains being blocked:", data.domains_being_blocked)
684087
def RemoveForwardedIp(self, address, interface):
    
    ip = netaddr.IPNetwork(address)
    self._RunIfconfig(args=[interface, '-alias', str(ip.ip)])
1080173
def block(self):
        

        self._nosig = True
        yield
        self._nosig = False
        if self._interrupted:
            raise SystemExit("Aborted...")
834533
def do_blockrep(self, line):
        """"""
        mns = self._split_args(line, 1, -1)
        self._command_processor.get_session().get_replication_policy().add_blocked(mns)
        self._print_info_if_verbose(
            "Set {} as blocked replication target(s)".format(", ".join(mns))
        )
1326745
def __ip_addr(addr, address_family=socket.AF_INET):
    '''
    
    '''
    mask_max = '32'
    if address_family == socket.AF_INET6:
        mask_max = '128'

    try:
        if '/' not in addr:
            addr = '{addr}/{mask_max}'.format(addr=addr, mask_max=mask_max)
    except TypeError:
        return False

    ip, mask = addr.rsplit('/', 1)

    # Verify that IP address is valid
    try:
        socket.inet_pton(address_family, ip)
    except socket.error:
        return False

    # Verify that mask is valid
    try:
        mask = int(mask)
    except ValueError:
        return False
    else:
        if not 1 <= mask <= int(mask_max):
            return False

    return True
1319110
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def block_resource(app):
        return DefaultIPPolicy(app, conf)
    return block_resource
1075439
def stop(self):
        """"""
        if (self.cf.link is not None):
            if (self.id is None):
                logger.warning('Stopping block, but no block registered')
            else:
                logger.debug('Sending stop logging for block id=%d', self.id)
                pk = CRTPPacket()
                pk.set_header(5, CHAN_SETTINGS)
                pk.data = (CMD_STOP_LOGGING, self.id)
                self.cf.send_packet(
                    pk, expected_reply=(CMD_STOP_LOGGING, self.id))
918480
def block_here(duration=0):
    
    try:
        while not duration:
            time.sleep(0.001)

        while duration:
            time.sleep(0.001)
            duration -= 1
    except KeyboardInterrupt as err:
        raise SystemExit(1)
454247
public function filter_ip( ){

		// get IP
		$ip = $_SERVER['REMOTE_ADDR'];
		if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
			$ip = $_SERVER['HTTP_CLIENT_IP'];
		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
			$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
		}

		return $ip;

	}
1356841
def ip(self, value):
        
        if value == self._defaults['ai.location.ip'] and 'ai.location.ip' in self._values:
            del self._values['ai.location.ip']
        else:
            self._values['ai.location.ip'] = value
1124017
def ip
      ip = request.remote_ip
      if ip && Ahoy.mask_ips
        Ahoy.mask_ip(ip)
      else
        ip
      end
    end
253392
def _set_ip(self):
        """"""
        self._ip = socket.gethostbyname(self._fqdn)
        log.debug('IP: %s' % self._ip)
15938
def disassociate_public_ip(self, public_ip_id):
        """"""
        floating_ip = self.client.floating_ips.get(public_ip_id)
        floating_ip = floating_ip.to_dict()
        instance_id = floating_ip.get('instance_id')
        address = floating_ip.get('ip')

        self.client.servers.remove_floating_ip(instance_id, address)

        return True