]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ident.cpp
Fix SetModeParam to use std::string and handle edge cases.
[user/henk/code/inspircd.git] / src / modules / m_ident.cpp
index a5f81c6f4ebb6c1ca1014aefd5ffb4eb6fb8cea9..6db5847537af9b64e6830c54637189b8b799765c 100644 (file)
@@ -372,7 +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
-               const char *ip = user->GetIPString();
+               irc::sockets::sockaddrs laddr;
+               socklen_t laddrsz = sizeof(laddr);
+
+               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;
+               }
+
+               char ip[INET6_ADDRSTRLEN + 1];
+#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