]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Unwrap SRS e-mail addresses 193/head
authorRomain Tartière <romain@blogreen.org>
Thu, 26 Nov 2020 02:23:54 +0000 (16:23 -1000)
committerRomain Tartière <romain@blogreen.org>
Thu, 26 Nov 2020 02:35:15 +0000 (16:35 -1000)
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.

tools/maillogconvert.pl

index d5f7b06bb9f217a903b2695831fc2e98192f2892..6fb3a8b4c8211b5fdadb4ad5fc50f0fd2523fdc1 100755 (executable)
@@ -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