Thread View: news.software.nntp
1 messages
1 total messages
Started by Nomen Nescio
Sat, 13 Jun 2009 09:30
Re: Can someone write a nnrpd perl filter ?
Author: Nomen Nescio
Date: Sat, 13 Jun 2009 09:30
Date: Sat, 13 Jun 2009 09:30
66 lines
3275 bytes
3275 bytes
Etian wrote:
> While you are developing it, you need it to work by itself. So in the
> main body, you store some data to the parts of %hdr that you want to
> test, and you call the functions to test them, and run it from the
> command line. After its working by itself, then you strip that stuff
> from the body.
>
> A big concern with INN, is that if the filter dies, then the x-trace and
> host are exposed to the world. Since this seems to be a concern shared
> by most of us, we could hope that in a future release the maintainers
> might allow these to be set in the authentication script rather than
> covering them up in the filter.
>
This is the best i can do. I wanted some basic rbl checks , but , honest ,
i'm still miles away from writing my own , a little help will be appreciated ,
thanks !
>use strict;
>use Digest::SHA1;
>our (%hdr, $modify_headers);
>sub filter_post {
> # Hash the NNTP-Posting-Host header
> my $ctx = Digest::SHA1->new;
> $ctx->add($hdr{'NNTP-Posting-Host'});
> $ctx->add("Would you like some salt with that?");
> $hdr{'NNTP-Posting-Host'} = $ctx->hexdigest;
> undef $hdr{'X-Trace'};
> # Refuse these From addresses
> if ($hdr{From} =~ /(
> \@darkshado\.ca
> | arcturianone\@earthlink\.net
> )/ix) {
> return "Sender address ($1) is blacklisted";
> };
> # Blacklist these groups
> if ($hdr{Newsgroups} =~ /(
> rec\.radio\.amateur\.policy
> | hr\.alt\.trash
> )/x) {
> return "Posting to $1 is currently blocked";
> };
> my $rval = "" ;
> if ($hdr{"Subject"} =~ /make.*money/i) {
> $rval = "Spam is not acceptable here..." ;
> } elsif ($hdr{'Subject'} =~ /^Re: /o and $hdr{'References'} eq "") {
> $rval = "Followup without References:";
> } elsif ($hdr{'From'} =~ /^\w*$/o or
> $hdr{'From'} !~ /^(.+?)\@([-\w\d]+\.)*([-\w\d]+)\.([-\w\d]{2,})$/o) {
> $rval = "From: is invalid, must be user\@[host.]domain.tld";
> }
> $modify_headers = 1;
> return '';
>}
>}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads