Article View: news.software.nntp
Article #16878INN 1.5 perl hooks -- useful
From: Jeff Garzik
Date: Thu, 10 Apr 1997 00:00
Date: Thu, 10 Apr 1997 00:00
63 lines
2680 bytes
2680 bytes
I really like the INN 1.5.1 perl hooks, I just set them up on my
server. In the first 20 minutes I've had it up and running, there have
been over 450 spam rejections, with no articles incorrectly rejected.
It doesn't seem to be sucking much CPU at all either.
For you Linux'ers (I'm Linux 2.0/Slackware 3.1), here's what you need in
config.data to compile the Perl support:
PERL_LIB -L/usr/lib/perl5/i586-linux/5.003/CORE -lperl -lm
PERL_INC -I/usr/lib/perl5/i586-linux/5.003/CORE -Dbool=char -DHAS_BOOL
Listed below is my filter_art routine. There is nothing new here, but
there are some important changes from the sample. First, the EMP filter
was broken -- an article was removed from the hash when the first EMP
article is flushed from the queue, not the when the last copy of the EMP
is flushed. Second, Perl is very big on shortcuts and optimizing
execution paths. Short, common code paths were placed first, followed
by the slower operations. In general, you want to get in and out of
this routine as quickly as possible.
Note the "EMP rejected" messages logs an EMP article's reference count
in the history array, not the actual number of rejected EMP article
copies.
sub filter_art {
return "MMF rejected ($hdr{'From'} $hdr{'Subject'})"
if (($hdr{"Subject"} =~ /make.*money.*fast/io) ||
($hdr{"Subject"} =~ /cash.*cash.*cash/io));
@newsgroups_hdr = split(/,/, $hdr{"Newsgroups"});
return "ECP rejected" if ($#newsgroups_hdr > 40);
$rval = "";
## Keep track of the From and subject.
$i = "$hdr{'From'} $hdr{'Subject'}";
push(@history, $i);
$history{$i}++;
## Reject the EMP.
## Change 3 to whatever your EMP threshold is
## Remember that EMP tolerance is much lower than crosspost tolerance
if ($history{$i} > 3) {
$rval = "EMP rejected (x$history{$i}): $i";
}
## Remove too old things.
## Change 1000 to whatever size history queue you want
while ($#history > 1000) {
$tmp_hist = shift(@history);
if ($history{$tmp_hist} < 2) {
delete $history{$tmp_hist};
} else {
$history{$tmp_hist}--;
}
}
return $rval;
}
Technical Details
Message-ID:
<334CB994.6847F7B9@spinne.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <334CB994.6847F7B9@spinne.com> Subject: INN 1.5 perl hooks -- useful Date: Thu, 10 Apr 1997 00:00:00 +0000 From: Jeff Garzik <jeff.garzik@spinne.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 232011772 Organization: Spinne http://spinne.com Newsgroups: news.software.nntp