From: Romain Tartière Date: Thu, 26 Nov 2020 02:23:54 +0000 (-1000) Subject: Unwrap SRS e-mail addresses X-Git-Tag: AWSTATS_7_9~9^2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F193%2Fhead;p=thirdparty%2FAWStats.git Unwrap SRS e-mail addresses When building statistics from mail servers, messages which where processed by Sender Rewriting Scheme (SRS) are mis-classified as internal mail while they are external, and appear to come from a huge number of different addresses which in fact correspond to the same actual sender. Add a rewriting function that detects such addresses and extract the relevant information from it. --- diff --git a/tools/maillogconvert.pl b/tools/maillogconvert.pl index d5f7b06b..6fb3a8b4 100755 --- a/tools/maillogconvert.pl +++ b/tools/maillogconvert.pl @@ -76,9 +76,15 @@ sub CleanVadminUser { $_=shift||''; return $_; } +sub UnwrapSRS { $_=shift||''; + s/^SRS1=.*=([^=]+)=([^@]+)@.*$/\2@\1/g; + s/^SRS0=[^=]+=[^=]+=([^=]+)=([^@]+)@.*$/\2@\1/g; + return $_; +} + sub CleanEmail { $_=shift||''; s/[#<|>\[\]]//g; # Remove unwanted characters first - return $_; + return &UnwrapSRS($_); } # Clean host addresses