]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ident.cpp
Test stuff to fix remote stats brokage
[user/henk/code/inspircd.git] / src / modules / m_ident.cpp
index 338535ad8b048f37fd0514ebdd3b3c4504214bc6..a0f590f9572f12ee92a2ae6fe8d28ee695334a30 100644 (file)
@@ -46,12 +46,8 @@ class RFC1413 : public InspSocket
                // so we just display a notice, and tidy off the ident_data.
                if (u && (Instance->SE->GetRef(ufd) == u))
                {
-                       char newident[MAXBUF];
                        u->Shrink("ident_data");
-                       u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using ~"+std::string(u->ident)+" instead.");
-                       strcpy(newident,"~");
-                       strlcat(newident,u->ident,IDENTMAX);
-                       strlcpy(u->ident,newident,IDENTMAX);
+                       Instance->next_call = Instance->Time();
                }
        }
 
@@ -121,6 +117,7 @@ class RFC1413 : public InspSocket
                // Fixes issue reported by webs, 7 Jun 2006
                if (u && (Instance->SE->GetRef(ufd) == u))
                {
+                       Instance->next_call = Instance->Time();
                        u->Shrink("ident_data");
                }
        }
@@ -129,6 +126,10 @@ class RFC1413 : public InspSocket
        {
                if (u && (Instance->SE->GetRef(ufd) == u))
                {
+                       if (*u->ident == '~')
+                               u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead.");
+
+                       Instance->next_call = Instance->Time();
                        u->Shrink("ident_data");
                }
        }
@@ -137,8 +138,8 @@ class RFC1413 : public InspSocket
        {
                if (u && (Instance->SE->GetRef(ufd) == u))
                {
-                       sockaddr* sock_us = new sockaddr;
-                       sockaddr* sock_them = new sockaddr;
+                       sockaddr* sock_us = new sockaddr[2];
+                       sockaddr* sock_them = new sockaddr[2];
                        bool success = false;
                        uslen = sizeof(sockaddr_in);
                        themlen = sizeof(sockaddr_in);
@@ -156,7 +157,8 @@ class RFC1413 : public InspSocket
 #endif
                        if (success)
                        {
-                               Instance->Log(DEBUG,"BUG: Ident: failed to get socket names");
+                               delete[] sock_us;
+                               delete[] sock_them;
                                return false;
                        }
                        else
@@ -171,11 +173,14 @@ class RFC1413 : public InspSocket
                                snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port));
 #endif
                                this->Write(ident_request);
+                               delete[] sock_us;
+                               delete[] sock_them;
                                return true;
                        }
                }
                else
                {
+                       Instance->next_call = Instance->Time();
                        return true;
                }
        }
@@ -185,7 +190,7 @@ class ModuleIdent : public Module
 {
 
        ConfigReader* Conf;
-       
+
        int IdentTimeout;
 
  public:
@@ -201,7 +206,7 @@ class ModuleIdent : public Module
        ModuleIdent(InspIRCd* Me)
                : Module::Module(Me)
        {
-               
+
                ReadSettings();
        }
 
@@ -223,6 +228,12 @@ class ModuleIdent : public Module
                 * is derived from InspSocket, and inserting it into the socket engine using the
                 * Server::AddSocket() call.
                 */
+               char newident[MAXBUF];
+               strcpy(newident,"~");
+               strlcat(newident,user->ident,IDENTMAX);
+               strlcpy(user->ident,newident,IDENTMAX);
+               
+
                user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident...");
                RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout);
                if ((ident->GetState() == I_CONNECTING) || (ident->GetState() == I_CONNECTED))
@@ -231,12 +242,8 @@ class ModuleIdent : public Module
                }
                else
                {
-                       char newident[MAXBUF];
-                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using ~"+std::string(user->ident)+" instead.");
-                       strcpy(newident,"~");
-                       strlcat(newident,user->ident,IDENTMAX);
-                       strlcpy(user->ident,newident,IDENTMAX);
-                       delete ident;
+                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using "+std::string(user->ident)+" instead.");
+                       ServerInstance->next_call = ServerInstance->Time();
                }
                return 0;
        }
@@ -266,7 +273,7 @@ class ModuleIdent : public Module
                                // to NULL and check it so that we dont write users who have gone away.
                                ident->u = NULL;
                                ServerInstance->SE->DelFd(ident);
-                               delete ident;
+                               //delete ident;
                        }
                }
        }
@@ -286,19 +293,19 @@ class ModuleIdent : public Module
                {
                        ident->u = NULL;
                        ServerInstance->SE->DelFd(ident);
-                       delete ident;
                }
        }
-       
+
        virtual ~ModuleIdent()
        {
+               ServerInstance->next_call = ServerInstance->Time();
        }
-       
+
        virtual Version GetVersion()
        {
                return Version(1,1,0,0,VF_VENDOR,API_VERSION);
        }
-       
+
 };
 
 class ModuleIdentFactory : public ModuleFactory
@@ -307,16 +314,16 @@ class ModuleIdentFactory : public ModuleFactory
        ModuleIdentFactory()
        {
        }
-       
+
        ~ModuleIdentFactory()
        {
        }
-       
+
        virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleIdent(Me);
        }
-       
+
 };