summaryrefslogtreecommitdiff
path: root/src/modules/m_ident.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-04-01 20:46:44 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-04-01 20:46:44 +0000
commita03554f504179e5e24de0c33079f3cb109f3d26e (patch)
treede5cf9328d9fce1dd74fd43813bb1cc5048e3ea2 /src/modules/m_ident.cpp
parent64184418d44649edb190df7c77297146bd6fc366 (diff)
Correct fix for bug #815, IPv6 code needs to check for IPv4 sa_family and handle it properly
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11276 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_ident.cpp')
-rw-r--r--src/modules/m_ident.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 04ad7ba4a..6db584753 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -372,25 +372,22 @@ class ModuleIdent : public Module
user->WriteServ("NOTICE Auth :*** Looking up your ident...");
// Get the IP that the user is connected to, and bind to that for the outgoing connection
- #ifndef IPV6
- sockaddr_in laddr;
- #else
- sockaddr_in6 laddr;
- #endif
+ irc::sockets::sockaddrs laddr;
socklen_t laddrsz = sizeof(laddr);
- if (getsockname(user->GetFd(), (sockaddr*) &laddr, &laddrsz) != 0)
+ if (getsockname(user->GetFd(), &laddr.sa, &laddrsz) != 0)
{
user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead.", user->ident.c_str());
return 0;
}
- #ifndef IPV6
- const char *ip = inet_ntoa(laddr.sin_addr);
- #else
char ip[INET6_ADDRSTRLEN + 1];
- inet_ntop(laddr.sin6_family, &laddr.sin6_addr, ip, INET6_ADDRSTRLEN);
- #endif
+#ifdef IPV6
+ if (laddr.sa.sa_family == AF_INET6)
+ inet_ntop(laddr.in6.sin6_family, &laddr.in6.sin6_addr, ip, INET6_ADDRSTRLEN);
+ else
+#endif
+ inet_ntop(laddr.in4.sin_family, &laddr.in4.sin_addr, ip, INET6_ADDRSTRLEN);
IdentRequestSocket *isock = NULL;
try