diff options
author | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-13 15:34:43 +0000 |
---|---|---|
committer | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-13 15:34:43 +0000 |
commit | 0a1fe6cf293bef91b419f57374b96a6d2aec636e (patch) | |
tree | 9f00991dad943256f4d5de39ee07389fb46c5796 /src | |
parent | f8f8c81e6fd8993a9de830af0be1709955c28a5f (diff) |
Made m_ident bind ident requests to the same IP the user is connected on, which is much more sane and should fix IPv6. Bug #406
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8035 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_ident.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index c80c53b72..e4b22d78f 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -146,7 +146,6 @@ class ModuleIdent : public Module { private: int RequestTimeout; - std::string IdentBindIP; public: ModuleIdent(InspIRCd *Me) : Module(Me) @@ -175,7 +174,6 @@ class ModuleIdent : public Module RequestTimeout = MyConf.ReadInteger("ident", "timeout", 0, true); if (!RequestTimeout) RequestTimeout = 5; - IdentBindIP = MyConf.ReadValue("ident", "bind", 0); } virtual int OnUserRegister(userrec *user) @@ -189,7 +187,28 @@ class ModuleIdent : public Module user->WriteServ("NOTICE Auth :*** Looking up your ident..."); - IdentRequestSocket *isock = new IdentRequestSocket(ServerInstance, user, RequestTimeout, IdentBindIP); + // 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 + socklen_t laddrsz = sizeof(laddr); + + if (getsockname(user->GetFd(), (sockaddr*) &laddr, &laddrsz) != 0) + { + user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead.", user->ident); + 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 + + IdentRequestSocket *isock = new IdentRequestSocket(ServerInstance, user, RequestTimeout, ip); user->Extend("ident_socket", isock); return 0; } |