Adding ASN info
Steve Freegard
steve.freegard at fsl.com
Tue May 20 12:08:36 IST 2008
Hugo van der Kooij wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> Has anyone done any work on adding ASN info to a message in the way this
> procmail filter does it? I would prefer to do this in postfix but a
> custom call in MailScanner before SA is called upon would do as well.
>
> http://linuxmafia.com/~karsten/Download/procmail-asn-header
>
> It sounds like a fun idea to let the ASN info become part of the
> Bayesian selection. And we might add a decision to block all messages
> from certain countries. All I ever got from Nigeria are messages with
> wacky deals.
>
SpamAssassin can do this natively if you want to Bayes to consider the ASN:
http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Plugin_ASN.html
From MailWatch v2:
sub ip_to_asn {
my $ip = shift;
my $revip = join(".", reverse split(/\./,$ip));
use Net::DNS;
my $res = Net::DNS::Resolver->new;
my $query = $res->search("$revip.asn.routeviews.org","TXT");
if($query) {
my @answer = $query->answer;
my $asn = $answer[0]{char_str_list}[0];
return $asn;
}
return '4294967295';
}
You could hack this into MailScanner's Message.pm then in 'sub new{'
after the variables are initialized add:
$global::MS->{mta}->AddHeader($this, 'X-MailScanner-ASN:',
ip_to_asn($this->{clientip}));
And that would do the equivalent to your procmail script.
However - I wouldn't recommend either way as routeviews.org has been
known to slow and/or offline at times and it will adversely affect your
scanning and delivery times (I disabled this function in MWv2 for this
reason).
If you really need this and have RAM to spare, then rsync the zone file
and serve it locally (BIND format only however; it's not possible to use
rbldnsd).
Cheers,
Steve.
More information about the MailScanner
mailing list