summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/listensocket.cpp12
-rw-r--r--src/modules/m_cloaking.cpp6
-rw-r--r--src/users.cpp8
3 files changed, 18 insertions, 8 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index 313396ed7..86d36cce0 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -128,15 +128,19 @@ void ListenSocketBase::AcceptInternal()
if (this->family == AF_INET6)
{
inet_ntop(AF_INET6, &((const sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf));
- if (!strncmp(buf, "::ffff:", 7))
- {
- memmove(buf, buf+7, sizeof(buf)-7);
- }
socklen_t raddrsz = sizeof(sockaddr_in6);
if (getsockname(incomingSockfd, (sockaddr*) raddr, &raddrsz) == 0)
inet_ntop(AF_INET6, &((const sockaddr_in6*)raddr)->sin6_addr, target, sizeof(target));
else
ServerInstance->Logs->Log("SOCKET", DEBUG, "Can't get peername: %s", strerror(errno));
+ if (!strncmp(buf, "::ffff:", 7))
+ {
+ memmove(buf, buf+7, sizeof(buf)-7);
+ }
+ if (!strncmp(target, "::ffff:", 7))
+ {
+ memmove(target, target+7, sizeof(target)-7);
+ }
}
else
#endif
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 761f37c18..58de93da9 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -418,8 +418,10 @@ class ModuleCloaking : public Module
#ifdef IPV6
in6_addr testaddr;
in_addr testaddr2;
- if ((dest->GetProtocolFamily() == AF_INET6) && (inet_pton(AF_INET6,dest->host.c_str(),&testaddr) < 1) && (hostcloak.length() <= 64))
- /* Invalid ipv6 address, and ipv6 user (resolved host) */
+ if ((dest->GetProtocolFamily() == AF_INET6) &&
+ (inet_pton(AF_INET6,dest->host.c_str(),&testaddr) < 1) &&
+ (inet_aton(dest->host.c_str(),&testaddr2) < 1) && (hostcloak.length() <= 64))
+ /* Invalid ipv4/ipv6 address, and ipv6 user (resolved host) */
b = hostcloak;
else if ((dest->GetProtocolFamily() == AF_INET) && (inet_aton(dest->host.c_str(),&testaddr2) < 1) && (hostcloak.length() <= 64))
/* Invalid ipv4 address, and ipv4 user (resolved host) */
diff --git a/src/users.cpp b/src/users.cpp
index 848f2a1eb..c6f5e498f 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1254,8 +1254,12 @@ const char* User::GetIPString()
/* IP addresses starting with a : on irc are a Bad Thing (tm) */
if (*buf == ':')
{
- strlcpy(&temp[1], buf, sizeof(temp) - 1);
- *temp = '0';
+ if (!strncmp(buf, "::ffff:", 7) && isdigit(buf[7])) {
+ strlcpy(temp, buf+7, sizeof(temp) - 1);
+ } else {
+ strlcpy(&temp[1], buf, sizeof(temp) - 1);
+ *temp = '0';
+ }
this->cachedip = temp;
return temp;
}