App-BlockWebFlooders
view release on metacpan or search on metacpan
script/block-web-flooders view on Meta::CPAN
warn "$PROG: Line '$line': Can't parse IP address, skipped\n";
next;
};
my $ip = $1;
next if $Blocked{$ip};
OUTPUT:
{
last unless !$last_update_output_time ||
$last_update_output_time <= $now-2;
print "\e[2J\e[;H"; # clear screen + put cursor at top (0,0)
printf "Blocked IPs: %s%4d%s | Log lines: %s%6d%s | Running for: %s%s%s\n",
color('bold'), (scalar keys %Blocked), color('reset'),
color('bold'), $num_lines, color('reset'),
color('bold'), Time::Duration::concise(Time::Duration::duration($now-$^T, 2)), color('reset');
$last_update_output_time = $now;
printf "Top IPs:\n";
my $i = 0;
for my $ip (sort { scalar(@{ $Ips{$b} }) <=> scalar(@{ $Ips{$a} }) } keys %Ips) {
last if $i++ >= 10;
printf " %15s (%4d)\n", $ip, scalar(@{ $Ips{$ip} });
( run in 0.222 second using v1.01-cache-2.11-cpan-4d50c553e7e )