Change 110
Change 110 by nullbyte@nullbyte-gentoo on 2004/12/24 15:30:00
greylistd 0.31: whitelist file for the networks that never retry properly.
merry xmas, spammers. here is a lump of 450.
Affected files ...| //depot/projects/greylistd/lib/Mail/Greylist.pm#5 | ktext | |
| //depot/projects/greylistd/bin/greylistd#4 | xtext | |
| //depot/projects/greylistd/t/01-basic.t#2 | text | |
| //depot/projects/greylistd/Changes#4 | text |
==== //depot/projects/greylistd/lib/Mail/Greylist.pm#5 (ktext) ====
| @@ -11,7 +11,7 @@ | ||
| 11 | 11 | use DB_File; |
| 12 | 12 | use Fcntl; |
| 13 | 13 | |
| 14 | our $VERSION = '0.3'; | |
| 14 | our $VERSION = '0.31'; | |
| 15 | 15 | |
| 16 | 16 | my $DELAY = 300; # seconds a new triplet must wait |
| 17 | 17 | my $LIFETIME = 36 * 86400; # forget triplets after this long |
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | my $self = { |
| 22 | 22 | dbfile => $args{dbfile} || '/var/lib/greylistd/triplets.db', |
| 23 | 23 | delay => defined $args{delay} ? $args{delay} : $DELAY, |
| 24 | white => $args{whitelist} || [], | |
| 24 | 25 | db => {}, |
| 25 | 26 | }; |
| 26 | 27 | tie %{ $self->{db} }, 'DB_File', $self->{dbfile}, O_RDWR|O_CREAT, 0600, $DB_HASH |
| @@ -38,6 +39,9 @@ | ||
| 38 | 39 | # returns "DUNNO" to let postfix carry on, or a defer action |
| 39 | 40 | sub check { |
| 40 | 41 | my ($self, %req) = @_; |
| 42 | for my $re (@{ $self->{white} }) { | |
| 43 | return "DUNNO" if $req{client_address} =~ $re; | |
| 44 | } | |
| 41 | 45 | my $key = $self->triplet($req{client_address}, $req{sender}, $req{recipient}); |
| 42 | 46 | my $now = time; |
| 43 | 47 | |
==== //depot/projects/greylistd/bin/greylistd#4 (xtext) ====
| @@ -17,7 +17,18 @@ | ||
| 17 | 17 | |
| 18 | 18 | $| = 1; |
| 19 | 19 | openlog('greylistd', 'pid', 'mail'); |
| 20 | my $gl = Mail::Greylist->new(delay => $opt{d}, dbfile => $opt{f}); | |
| 20 | my @white; | |
| 21 | if (open my $wl, '<', '/etc/greylistd/whitelist') { | |
| 22 | while (<$wl>) { | |
| 23 | s/#.*//; | |
| 24 | s/^\s+|\s+$//g; | |
| 25 | push @white, qr/^\Q$_\E/ if length; | |
| 26 | } | |
| 27 | close $wl; | |
| 28 | } | |
| 29 | ||
| 30 | my $gl = Mail::Greylist->new(delay => $opt{d}, dbfile => $opt{f}, | |
| 31 | whitelist => \@white); | |
| 21 | 32 | my %req; |
| 22 | 33 | |
| 23 | 34 | while (my $line = <STDIN>) { |
==== //depot/projects/greylistd/t/01-basic.t#2 (text) ====
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | #!/usr/bin/perl -w |
| 2 | 2 | use strict; |
| 3 | use Test::More tests => 5; | |
| 3 | use Test::More tests => 7; | |
| 4 | 4 | use File::Temp qw(tempdir); |
| 5 | 5 | |
| 6 | 6 | use_ok('Mail::Greylist'); |
| @@ -17,3 +17,12 @@ | ||
| 17 | 17 | like($gl->check(%req), qr/^DEFER/, 'immediate retry still deferred'); |
| 18 | 18 | sleep 3; |
| 19 | 19 | is($gl->check(%req), 'DUNNO', 'retry after delay is accepted'); |
| 20 | ||
| 21 | # same /24 counts as the same sender (job000004) | |
| 22 | $req{client_address} = '10.1.2.99'; | |
| 23 | is($gl->check(%req), 'DUNNO', 'same /24 is accepted'); | |
| 24 | ||
| 25 | my $gl2 = Mail::Greylist->new(dbfile => "$dir/t2.db", | |
| 26 | whitelist => [ qr/^192\.168\./ ]); | |
| 27 | is($gl2->check(%req, client_address => '192.168.0.5'), 'DUNNO', | |
| 28 | 'whitelisted network skips the greylist'); | |
==== //depot/projects/greylistd/Changes#4 (text) ====
| @@ -1,5 +1,9 @@ | ||
| 1 | 1 | Revision history for Mail::Greylist |
| 2 | 2 | |
| 3 | 0.31 Fri Dec 24 2004 | |
| 4 | - /etc/greylistd/whitelist: one network prefix per line | |
| 5 | - tests for the /24 behaviour and the whitelist | |
| 6 | ||
| 3 | 7 | 0.3 Wed Jun 30 2004 |
| 4 | 8 | - log every decision via syslog |
| 5 | 9 | - Makefile.PL lists all prereqs |