From b42eac75023e2956e6096c13ad31fa0736141911 Mon Sep 17 00:00:00 2001 From: Valery Yatsko Date: Mon, 28 Jul 2008 10:06:01 +0400 Subject: [PATCH] quick draft fix of ip_cloaking to make module work with ipv6 ips, cleanup later --- extensions/ip_cloaking.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/ip_cloaking.c b/extensions/ip_cloaking.c index 27cb3922..e80a19a4 100644 --- a/extensions/ip_cloaking.c +++ b/extensions/ip_cloaking.c @@ -100,10 +100,17 @@ do_host_cloak_ip(const char *inbuf, char *outbuf) char *tptr; unsigned int accum = get_string_weighted_entropy(inbuf); char buf[HOSTLEN]; + int ipv6 = 0; strncpy(buf, inbuf, HOSTLEN); tptr = strrchr(buf, '.'); + if (tptr == NULL) + { + tptr = strrchr(buf, ':'); + ipv6 = 1; + } + if (tptr == NULL) { strncpy(outbuf, inbuf, HOSTLEN); @@ -112,7 +119,14 @@ do_host_cloak_ip(const char *inbuf, char *outbuf) *tptr++ = '\0'; - snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum); + if(ipv6) + { + snprintf(outbuf, HOSTLEN, "%s:%x", buf, accum); + } + else + { + snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum); + } } static void