#!/usr/bin/perl -wT
=head1 NAME

anonymize_received

=head1 DESCRIPTION

Plugin that remove the login from "Received" header
(replaced with a md5_base64 of the login) and the
version of qpsmtpd

=head1 AUTHOR

Daniel Berteaud <daniel@firewall-services.com>

=head1 LICENSE

GNU GPL (GNU General Public License)


=cut


use POSIX qw(strftime);
use Digest::MD5 qw(md5_base64);

sub hook_received_line {
    my ( $self, $transaction, $smtp, $authheader, $sslheader ) = @_;

    my $auth = '';
    $auth = "smtp-auth username ".md5_base64($1).$2
        if ($authheader =~ /smtp-auth\ username (\w+)(,.*)/);

    return OK, "from ".$self->connection->remote_info
        ." (HELO ".$self->connection->hello_host
        . ") (".$self->connection->remote_ip
        . ")\n $auth by ".$self->qp->config('me')
        ." (qpsmtpd) "
        ."with $sslheader$smtp; "
        . (strftime('%a, %d %b %Y %H:%M:%S %z', localtime));
}

