Change 67
Change 67 by nullbyte@nullbyte-gentoo on 2004/04/11 14:02:38
key on the /24 instead of the full IP. hotmail retries from a different box in the
farm every time so their mail was never getting through. also -d/-f options, purge().
Jobs fixed ...- job000004 fixed
| //depot/projects/greylistd/lib/Mail/Greylist.pm#3 | ktext | |
| //depot/projects/greylistd/bin/greylistd#2 | xtext | |
| //depot/projects/greylistd/Changes#2 | text |
==== //depot/projects/greylistd/lib/Mail/Greylist.pm#3 (ktext) ====
| @@ -11,7 +11,7 @@ | ||
| 11 | 11 | use DB_File; |
| 12 | 12 | use Fcntl; |
| 13 | 13 | |
| 14 | our $VERSION = '0.1'; | |
| 14 | our $VERSION = '0.2'; | |
| 15 | 15 | |
| 16 | 16 | my $DELAY = 300; # seconds a new triplet must wait |
| 17 | 17 | my $LIFETIME = 36 * 86400; # forget triplets after this long |
| @@ -30,7 +30,9 @@ | ||
| 30 | 30 | |
| 31 | 31 | sub triplet { |
| 32 | 32 | my ($self, $ip, $from, $to) = @_; |
| 33 | return join("/", $ip, lc($from || '<>'), lc $to); | |
| 33 | # big ISPs retry from a different box in the same farm; key on the /24 | |
| 34 | (my $net = $ip) =~ s/\.\d+$//; | |
| 35 | return join("/", $net, lc($from || '<>'), lc $to); | |
| 34 | 36 | } |
| 35 | 37 | |
| 36 | 38 | # returns "DUNNO" to let postfix carry on, or a defer action |
| @@ -50,6 +52,14 @@ | ||
| 50 | 52 | return "DUNNO"; |
| 51 | 53 | } |
| 52 | 54 | |
| 55 | sub purge { | |
| 56 | my $self = shift; | |
| 57 | my $now = time; | |
| 58 | my @old = grep { $now - $self->{db}{$_} > $LIFETIME } keys %{ $self->{db} }; | |
| 59 | delete @{ $self->{db} }{@old}; | |
| 60 | return scalar @old; | |
| 61 | } | |
| 62 | ||
| 53 | 63 | sub DESTROY { |
| 54 | 64 | my $self = shift; |
| 55 | 65 | untie %{ $self->{db} }; |
==== //depot/projects/greylistd/bin/greylistd#2 (xtext) ====
| @@ -9,9 +9,13 @@ | ||
| 9 | 9 | use strict; |
| 10 | 10 | use lib '/usr/local/lib/greylistd'; |
| 11 | 11 | use Mail::Greylist; |
| 12 | use Getopt::Std; | |
| 12 | 13 | |
| 14 | my %opt; | |
| 15 | getopts('d:f:', \%opt) or die "usage: greylistd [-d delay] [-f dbfile]\n"; | |
| 16 | ||
| 13 | 17 | $| = 1; |
| 14 | my $gl = Mail::Greylist->new(); | |
| 18 | my $gl = Mail::Greylist->new(delay => $opt{d}, dbfile => $opt{f}); | |
| 15 | 19 | my %req; |
| 16 | 20 | |
| 17 | 21 | while (my $line = <STDIN>) { |
==== //depot/projects/greylistd/Changes#2 (text) ====
| @@ -1,4 +1,10 @@ | ||
| 1 | 1 | Revision history for Mail::Greylist |
| 2 | 2 | |
| 3 | 0.2 Sun Apr 11 2004 | |
| 4 | - key triplets on the client /24, not the full IP (job000004). | |
| 5 | hotmail's outbound farm was never getting through. | |
| 6 | - purge() for stale triplets | |
| 7 | - greylistd: -d and -f options | |
| 8 | ||
| 3 | 9 | 0.1 Tue Mar 2 2004 |
| 4 | 10 | - first cut. works on my box. spam down 80% overnight. |