Regex for Postfix rewrite IPv6 in header_checks

I posted this before I checked the default cost, which is why I deleted the last one. This should be a simple regex creation.

Background: My Postfix mail server rewrites the header using the following regular expression in /etc/postfix/header_checks:

/^Received: from (.* \([-._[:alnum:]]+ \[[.[:digit:]]{7,15}\]\)).*?([[:space:]]+).*\(Authenticated sender: ([^)]+)\).*by (example\.com) \(([^)]+)\) with (E?SMTPS?A?) id ([A-F[:digit:]]+).*/

REPLACE Received: from [] (localhost [])$2(Authenticated sender: $3)${2}with $6 id $7

What this does is replace the IP address and hostname of sender with something generic like localhost and instead of the PC name and true client IP address, which would otherwise pose a security risk. I don't mind having the "authenticated sender" in there. I just don't want all recipients to know from where the clients are sending.

Problem description: while the above regex works fine for IPv4, it obviously does not work when clients are using IPv6. So, would like to modify or append that regex/replace statement so that it works for both IPv6 and IPv4. I believe this should be pretty straightforward. I have extremely verbose logging turned on in my Postfix instance so can see the re-writes as they happen with the postfix/cleanup daemon in the logs. This is not a lot of work, just some expertise in regex and Postfix.

Habilidades: Linux, Perl, Instalação de Script, Shell Script, Administrador do Sistema

Veja mais: postfix header_checks, header_checks, what is the problem statement, what is problem statement, what is a regular expression, what is a problem statement example, what is a problem statement, using regular expression, using regex in c, statement problem example, statement of the problem example, simple problem statement example, regular expression using, regular expression or example, regular expression in linux example, regular expression in linux, regular expression in c, regular expression example, regular expression 0, regex is, regex in c, regex example, regex c, problem statement example, example problem statement

Acerca do Empregador:
( 1 comentário ) Honolulu, United States

ID do Projeto: #5138851

Concedido a:


Like I suggested on your last post. send me both examples of IPv4 and IPv6 incomes, and your regex output for IPv4 (what regex extract from the income) and I'll rewrite the regex above to snatch both IPv4+6 Delivery Mais

$45 USD em 2 dias
(1 Comentário)

2 freelancers are bidding on average $38 for this job


Linux system administrator with 10 years of experience. I have done this before with IPv4. I believe I can also do it with IPv6.

$30 USD in 0 dias
(0 Comentários)