IP Stripping (replace)
Martin Bock
postfixbuch at mnbo.de
Mo Jul 18 19:57:08 CEST 2016
Hi,
Ich hatte mal was zusammengeschrieben und getestet, bei mir funktioniert
das:
/^(Received: from)(.*)\s*(by.*)(with ESMTPSA)(\s*)(.*)/ REPLACE $1
localhost (localhost [127.0.0.1]) $5$3$4$5$6
Passt natürlich auf meine Header:
Received: from [1.2.3.4] (5-6-7-8.hostname.tld [5.6.7.8])
by hostname (Postfix) with ESMTPSA
for <user at hostname>; Sun, 17 Jul 2016 19:30:53 +0200 (CEST)
Jetzt habe ich mein Pattern kurz angepasst, bekommt man vermutlich
eleganter hin aber es scheint zu funktionieren und erkennt deinen Header
(oberflächlich getestet auf regex101.com und per postmap):
/^(Received: from)(.*)\s*(\(.*\)\s*){3}(by.*)(with ESMTPSA)(\s*)(.*)/
Gruß Martin
Am 18.07.2016 um 16:48 schrieb Daniel:
> Hi,
>
> also habe es noch mal probiert, denke so langsam wird es was mit regex101.com, jedoch klappt es in der postmap Query nicht.
>
> Bin aktuell bei
> /^(Received: from) (.*) \((.*) \[(.*)\]\)\s+\((.*\(.*\))\s+\((.*)\)\s+\((.*) (.*)\)\s+by (.*) \(Postfix\) with (E?SMTPS?A?) id ([A-Z\d]+)\s+for <(.*)>; (.*)/ REPLACE $1 [::1] (localhost [::1])($5)($7 ok) by $9 (Postfix) with $10 id $11 for <$12>; $13
>
> für
> Received: from UserPC (unknown [IPv6:200x:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx])
> (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
> (Client did not present a certificate)
> (Authenticated sender: Username)
> by Mailserverhostname (Postfix) with ESMTPSA id C103E3316001
> for <check-auth at verifier.port25.com>; Sun, 17 Jul 2016 16:18:03 +0200 (CEST)
>
> MATCH 1
> 1. [0-14] `Received: from`
> 2. [15-21] `UserPC`
> 3. [23-30] `unknown`
> 4. [32-76] `IPv6:200x:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx`
> 5. [80-148] `using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)`
> 6. [151-187] `Client did not present a certificate`
> 7. [190-211] `Authenticated sender:`
> 8. [212-220] `Username`
> 9. [225-243] `Mailserverhostname`
> 10. [259-266] `ESMTPSA`
> 11. [270-282] `C103E3316001`
> 12. [288-318] `check-auth at verifier.port25.com`
> 13. [321-359] `Sun, 17 Jul 2016 16:18:03 +0200 (CEST)`
>
> Gruß Daniel
>
>
Mehr Informationen über die Mailingliste Postfixbuch-users