adismaug has asked for the wisdom of the Perl Monks concerning the following question:
Regards,#!/usr/bin/perl use Parallel::ForkManager; use IPTables::IPv4::IPQueue qw(:constants); use NetPacket::IP qw(:ALL); use Time::HiRes qw(time); my $i = 0; my $t0 = time; my $ipq = new IPTables::IPv4::IPQueue (copy_mode => IPQ_COPY_PACKET, copy_range => 1500); my $pm = new Parallel::ForkManager(3); $pm->run_on_finish( sub { my ($pid, $exit_code) = @_; $i++; } ); while (1) { if ($i == 100) { $elapsed = time - $t0; print "\n *************\n$elapsed\n********************\n"; $i = 0; my $t0 = time; $pm->wait_all_children; } $pm->start and next; # do the fork my $msg = $ipq->get_message; if (defined $msg) { my $ip = NetPacket::IP->decode($msg->payload); $ipAddr = $ip->{src_ip}; $DSTipAddr = $ip->{dest_ip}; @res = qx { /root/scripts/iptables/rbl.pl $ipAddr }; if (grep(/err/, @res)) { #qx { echo $ipAddr >> /root/scripts/iptables/stat/blackRbl +.log }; $ipq->set_verdict($msg->packet_id, NF_DROP); print "$ipAddr -> $DSTipAddr @res\n"; } else { $ipq->set_verdict($msg->packet_id, NF_ACCEPT); #print "$ipAddr -> $DSTipAddr @res\n"; } exit(0); } else { print "Not defined\n"; exit(0); } $pm->finish; # do the exit in the child process }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPQueue blacklist file
by Corion (Patriarch) on May 25, 2009 at 08:16 UTC | |
by adismaug (Acolyte) on May 25, 2009 at 12:20 UTC |