-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Jul 16, 2004 at 02:19:48PM -0400, Samuel Hill wrote:
>Maybe you could post that script.
>Someone may benefit from it.
>
>Also, 20 minutes?
>I would spend time working on that problem rather than this one.

It's somewhat by choice.  I'm adding hashcash to everything I send out.
That's part of why it's slow and part of why I'm more concerned about
sending out too many challenges; the challenges themselves slow things
down.  Beyond that, I'm filtering something like 5000 messages a day on a
400MHz Linux box which has other duties besides.  I'll be getting a faster
computer from a different dumpster any day now.  8-)

As for the script, it's pretty short:

#!/usr/bin/perl

#
# We're going to:
# * read in the headers of an email message,
# * SHA1 them
# * consult a directory for that SHA1
# * If it's in the directory, add a header
# * If not, put it in the directory, and pass the email unmolested
#

use strict;
use Digest::SHA1 qw( sha1_hex );

my $dir = '/home/kyle/.spam-bomb/incoming-sha1';

my $head = '';
my $separator = '';

while ( <> ) {
    if ( ! /\S/ ) {
        $separator = $_;
        last;
    }
    else {
        $head .= $_;
    }
}

my $sha1 = sha1_hex( $head );
my $file = "$dir/$sha1";

if ( -e $file ) {
    $head .= "X-Local-TMDA-Advice: hold\n";
}

open( TOUCH, ">$file" ) || die "Can't write $file: $!\n";
close( TOUCH );

print "$head$separator";
print while ( <> );

exit;

I call it from maildrop like this:

if ( ! /^X-Local-TMDA-Advice: / )
{
        dotlock "$PROCLOCK" {
                xfilter "perl $HOME/bin/advise-dupes"
        }
}

I account for it (and others) at the very end of my TMDA incoming filter
like this (it has to be at the end so white/black lists take precedence):

headers 'X-Local-TMDA-Advice: hold' hold
headers 'X-Local-TMDA-Advice: drop' drop
headers 'X-Local-TMDA-Advice: confirm' confirm
headers 'X-Local-TMDA-Advice: ok' ok

And, finally, there's the cron job to flush out those crusty old hashes
(all one line):

16 * * * * test -d /home/kyle/.spam-bomb/incoming-sha1 &&
find /home/kyle/.spam-bomb/incoming-sha1 -mtime +1 -print0 | xargs -0 rm -f

I'm not VERY proud of all that, but it works as far as I can tell, and
people are welcome to it.
- -- 
Kyle Hasselbacher                Peace in the world depends on
[EMAIL PROTECTED]              peace in the hearts of individuals.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA+B9n10sofiqUxIQRAqLWAKC62UzQJ9pmXhMqcZTvDMOciEKouACfcIIs
ea4chRBBLy8VC41oorXTpks=
=s1S5
-----END PGP SIGNATURE-----
_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to