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 )