mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 08:42:34 +01:00
quick draft fix of ip_cloaking to make module work with ipv6 ips, cleanup later
This commit is contained in:
parent
c287438827
commit
b42eac7502
1 changed files with 15 additions and 1 deletions
|
@ -100,10 +100,17 @@ do_host_cloak_ip(const char *inbuf, char *outbuf)
|
||||||
char *tptr;
|
char *tptr;
|
||||||
unsigned int accum = get_string_weighted_entropy(inbuf);
|
unsigned int accum = get_string_weighted_entropy(inbuf);
|
||||||
char buf[HOSTLEN];
|
char buf[HOSTLEN];
|
||||||
|
int ipv6 = 0;
|
||||||
|
|
||||||
strncpy(buf, inbuf, HOSTLEN);
|
strncpy(buf, inbuf, HOSTLEN);
|
||||||
tptr = strrchr(buf, '.');
|
tptr = strrchr(buf, '.');
|
||||||
|
|
||||||
|
if (tptr == NULL)
|
||||||
|
{
|
||||||
|
tptr = strrchr(buf, ':');
|
||||||
|
ipv6 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (tptr == NULL)
|
if (tptr == NULL)
|
||||||
{
|
{
|
||||||
strncpy(outbuf, inbuf, HOSTLEN);
|
strncpy(outbuf, inbuf, HOSTLEN);
|
||||||
|
@ -112,8 +119,15 @@ do_host_cloak_ip(const char *inbuf, char *outbuf)
|
||||||
|
|
||||||
*tptr++ = '\0';
|
*tptr++ = '\0';
|
||||||
|
|
||||||
|
if(ipv6)
|
||||||
|
{
|
||||||
|
snprintf(outbuf, HOSTLEN, "%s:%x", buf, accum);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
|
snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_host_cloak_host(const char *inbuf, char *outbuf)
|
do_host_cloak_host(const char *inbuf, char *outbuf)
|
||||||
|
|
Loading…
Reference in a new issue