[syslog-ng] [PATCH] anonymizing filter

Micah Anderson micah at riseup.net
Tue Dec 4 16:40:36 CET 2007


* Wolfram Schlich <lists at wolfram.schlich.org> [071204 06:05]:
> * Micah Anderson <micah at riseup.net> [2007-11-30 20:04]:
> [...]
> > +  if (!g_ascii_strcasecmp(re, "ips"))
> > +    re = "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])([\\.\\-](25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3}";
> 
> Urgh, that's IPv4 only. Boo!! :-P

Same boo happened last time around and nobody could come up with a more
elegant one than proposed:

It can get complex. Here is an example IPv6 regexp:
(http://blogs.msdn.com/mpoulson/archive/2005/01/10/350037.aspx)
> Const strIPv6Pattern as string =
> "\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\z"
> Const strIPv6Pattern_HEXCompressed as string =
> "\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\z"
> Const StrIPv6Pattern_6Hex4Dec as string =
> "\A((?:[0-9A-Fa-f]{1,4}:){6,6})(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\z"
> Const StrIPv6Pattern_Hex4DecCompressed as string =
> "\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
> ::((?:[0-9A-Fa-f]{1,4}:)*)(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\z"

The tricky part is that you can mix decimal IPv4 with hex IPv6, and
leave out multiple blocks of 0's, but not more than once. Anyone have a
more elegant expression?

micah
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.balabit.hu/pipermail/syslog-ng/attachments/20071204/fdaf37ce/attachment.pgp 


More information about the syslog-ng mailing list