App-Waf
view release on metacpan or search on metacpan
lib/App/Waf.pm view on Meta::CPAN
# must be root user;
# å¿
é¡»rootç¨æ·æå¯ä»¥æä½iptablesï¼å½ç¶ä¹å¿
é¡»æiptablesæå¡è·å¨ç
my $IP = shift;
my $ips = `/sbin/iptables-save`;
my @ipsline = split /\n/sm, $ips;
my $dist = 0;
for (@ipsline) {
$dist = 1 if ( /$IP/ and /INPUT/ and /DROP/ );
}
unless ($dist) {
`/sbin/iptables -I INPUT -s $IP -j DROP`;
my $btime = localtime( time() );
print "$btime :band $IP \n";
}
else {
print "band alread!\n";
}
}
( run in 0.374 second using v1.01-cache-2.11-cpan-c6e0e5ac2a7 )