M. Feenstra ?????
QTFG: pftabled

Thanks... I did the "QTFG"-part quite a bit but never ran into "pftabled" but you are correct. This is exactly what I was looking for.. Looks like a very nice implementation also. Nice readable code.
Thanks again..
you are welcome :)
i use pftabled in my antispam system for blocking annoying hosts.
below you can see my script for manage pftabled. i think it is more simple than code from author.

use IO::Socket;
use Digest::HMAC_SHA1 qw(hmac_sha1);

my($sock, $server_host, $msg, $port, $ipaddr, $hishost,
$MAXLEN, $PORTNO, $TIMEOUT);

$MAXLEN = 1024;
$TIMEOUT = 5;
$PFTBLVERSION = 2;
$PFTBLCOMMAND = 1; # 0x01 - add, 0x02 - del, 0x03 -flush
$PFTBLMASK = 32;
$PFTBLNAME = "spamzone";
$PFTBLPORT = 56789;

@servers = ('xxx.xxx.xxx.xxx','xxx.xxx.xxx.xxx');

foreach my $server_host (@servers)
{
$sock = IO::Socket::INET->new(Proto => 'udp',
PeerPort => $PFTBLPORT,
PeerAddr => $server_host)
or die "Creating socket: $!\n";
$key = "20bytes_key";
my $addr = $ARGV[0];
$addr =~ s/[^0-9.]//g;
my $block = pack("C1 S1 C1",$PFTBLVERSION,$PFTBLCOMMAND,$PFTBLMASK).inet_aton($addr).pack("a32 N*",$PFTBLNAME,time());
$digest = hmac_sha1($block, $key);
$block .= $digest;
$sock->send($block) or die "send: $!";
}

Reply via email to