]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ident.cpp
Annotations
[user/henk/code/inspircd.git] / src / modules / m_ident.cpp
index 4ee49d4ecedeb9f6df53a1383d1d3c86b8f9d2a0..93fa498fcaacd643e94410314a779e7e86686102 100644 (file)
@@ -23,10 +23,6 @@ using namespace std;
 #include "modules.h"
 #include "inspircd.h"
 
-
-
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
 /* $ModDesc: Provides support for RFC 1413 ident lookups */
 
 // Version 1.5.0.0 - Updated to use InspSocket, faster and neater.
@@ -45,15 +41,16 @@ class RFC1413 : public InspSocket
        userrec* u;              // user record that the lookup is associated with
        int ufd;
 
-       RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user), ufd(user->fd)
+       RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user)
        {
+               ufd = user->GetFd();
        }
 
        virtual void OnTimeout()
        {
                // When we timeout, the connection failed within the allowed timeframe,
                // so we just display a notice, and tidy off the ident_data.
-               if (u && (fd_ref_table[ufd] == u))
+               if (u && (Instance->SE->GetRef(ufd) == u))
                {
                        u->Shrink("ident_data");
                        u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead.");
@@ -84,7 +81,7 @@ class RFC1413 : public InspSocket
                                                                *j = '\0'; // truncate at invalid chars
                                                        if (*section)
                                                        {
-                                                               if (u && (fd_ref_table[ufd] == u))
+                                                               if (u && (Instance->SE->GetRef(ufd) == u))
                                                                {
                                                                        if (this->Instance->IsIdent(section))
                                                                        {
@@ -125,7 +122,7 @@ class RFC1413 : public InspSocket
                // descriptor that they were when the lookup began.
                //
                // Fixes issue reported by webs, 7 Jun 2006
-               if (u && (fd_ref_table[ufd] == u))
+               if (u && (Instance->SE->GetRef(ufd) == u))
                {
                        u->Shrink("ident_data");
                }
@@ -133,7 +130,7 @@ class RFC1413 : public InspSocket
 
        virtual void OnError(InspSocketError e)
        {
-               if (u && (fd_ref_table[ufd] == u))
+               if (u && (Instance->SE->GetRef(ufd) == u))
                {
                        u->Shrink("ident_data");
                }
@@ -141,11 +138,12 @@ class RFC1413 : public InspSocket
 
        virtual bool OnConnected()
        {
-               if (u && (fd_ref_table[ufd] == u))
+               Instance->Log(DEBUG,"Ident: connected");
+               if (u && (Instance->SE->GetRef(ufd) == u))
                {
                        uslen = sizeof(sock_us);
                        themlen = sizeof(sock_them);
-                       if ((getsockname(this->u->fd,(sockaddr*)&sock_us,&uslen) || getpeername(this->u->fd, (sockaddr*)&sock_them, &themlen)))
+                       if ((getsockname(this->u->GetFd(),(sockaddr*)&sock_us,&uslen) || getpeername(this->u->GetFd(), (sockaddr*)&sock_them, &themlen)))
                        {
                                Instance->Log(DEBUG,"Ident: failed to get socket names, bailing");
                                return false;
@@ -214,16 +212,12 @@ class ModuleIdent : public Module
                 */
                user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident...");
                RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout);
-               if (ident->GetState() != I_ERROR)
+               if ((ident->GetState() == I_CONNECTING) || (ident->GetState() == I_CONNECTED))
                {
                        user->Extend("ident_data", (char*)ident);
-                       ServerInstance->AddSocket(ident);
                }
                else
-               {
-                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using "+std::string(user->ident)+" instead.");
-                       DELETE(ident);
-               }
+                       delete ident;
        }
 
        virtual bool OnCheckReady(userrec* user)
@@ -250,7 +244,6 @@ class ModuleIdent : public Module
                                // a user which has now vanished! To prevent this, set ident::u
                                // to NULL and check it so that we dont write users who have gone away.
                                ident->u = NULL;
-                               ServerInstance->RemoveSocket(ident);
                        }
                }
        }
@@ -269,7 +262,6 @@ class ModuleIdent : public Module
                if (user->GetExt("ident_data", ident))
                {
                        ident->u = NULL;
-                       ServerInstance->RemoveSocket(ident);
                }
        }