]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/userprocess.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / userprocess.cpp
index 30bb79872958a6f9fac4fdadc8c73c3521399c84..7468d0890886d460e070f63f7e0c3d0f6317e914 100644 (file)
@@ -33,10 +33,6 @@ using namespace std;
 #include <sstream>
 #include <vector>
 #include <deque>
-#include <sched.h>
-#ifdef THREADED_DNS
-#include <pthread.h>
-#endif
 #include "users.h"
 #include "ctables.h"
 #include "globals.h"
@@ -48,7 +44,6 @@ using namespace std;
 #include "commands.h"
 #include "xline.h"
 #include "inspstring.h"
-#include "dnsqueue.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "socketengine.h"
@@ -84,14 +79,14 @@ void ProcessUser(userrec* cu)
 
        log(DEBUG,"Processing user with fd %d",cu->fd);
 
-       if (Config->GetIOHook(cu->port))
+       if (Config->GetIOHook(cu->GetPort()))
        {
                int result2 = 0;
                int MOD_RESULT = 0;
 
                try
                {
-                       MOD_RESULT = Config->GetIOHook(cu->port)->OnRawSocketRead(cu->fd,data,65535,result2);
+                       MOD_RESULT = Config->GetIOHook(cu->GetPort())->OnRawSocketRead(cu->fd,data,65535,result2);
                        log(DEBUG,"Data result returned by module: %d",MOD_RESULT);
                }
                catch (ModuleException& modexcept)
@@ -173,9 +168,9 @@ void ProcessUser(userrec* cu)
                                }
                                else
                                {
-                                       WriteOpers("*** Excess flood from %s",(char*)insp_ntoa(current->ip4));
-                                       log(DEFAULT,"Excess flood from: %s",(char*)insp_ntoa(current->ip4));
-                                       add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_ntoa(current->ip4));
+                                       WriteOpers("*** Excess flood from %s",current->GetIPString());
+                                       log(DEFAULT,"Excess flood from: %s",current->GetIPString());
+                                       add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
                                        apply_lines(APPLY_ZLINES);
                                }
 
@@ -190,9 +185,9 @@ void ProcessUser(userrec* cu)
                                }
                                else
                                {
-                                       WriteOpers("*** Excess flood from %s",(char*)insp_ntoa(current->ip4));
-                                       log(DEFAULT,"Excess flood from: %s",(char*)insp_ntoa(current->ip4));
-                                       add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_ntoa(current->ip4));
+                                       WriteOpers("*** Excess flood from %s",current->GetIPString());
+                                       log(DEFAULT,"Excess flood from: %s",current->GetIPString());
+                                       add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
                                        apply_lines(APPLY_ZLINES);
                                }
 
@@ -226,7 +221,7 @@ void ProcessUser(userrec* cu)
                                        }
                                        else
                                        {
-                                               add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_ntoa(current->ip4));
+                                               add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
                                                apply_lines(APPLY_ZLINES);
                                        }
 
@@ -320,8 +315,6 @@ void DoBackgroundUserStuff(time_t TIME)
 {
        CullList GlobalGoners;
 
-       int cfd = 0;
-
        /* XXX: IT IS NOT SAFE TO USE AN ITERATOR HERE. DON'T EVEN THINK ABOUT IT. */
        for (unsigned long count2 = 0; count2 != local_users.size(); count2++)
        {
@@ -332,87 +325,68 @@ void DoBackgroundUserStuff(time_t TIME)
 
                if (curr)
                {
-                       cfd = curr->fd;
-
-                       if ((cfd > -1) && (cfd < MAX_DESCRIPTORS) && (fd_ref_table[cfd] == curr) && (curr))
+                       /*
+                        * registration timeout -- didnt send USER/NICK/HOST
+                        * in the time specified in their connection class.
+                        */
+                       if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != REG_ALL))
                        {
-                               /*
-                                * registration timeout -- didnt send USER/NICK/HOST
-                                * in the time specified in their connection class.
-                                */
-                               if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != REG_ALL))
-                               {
-                                       log(DEBUG,"InspIRCd: registration timeout: %s",curr->nick);
-                                       ZapThisDns(curr->fd);
-                                       GlobalGoners.AddItem(curr,"Registration timeout");
-                                       continue;
-                               }
-
-                               /*
-                                * user has signed on with USER/NICK/PASS, and dns has completed, all the modules
-                                * say this user is ok to proceed, fully connect them.
-                                */
-                               if ((TIME > curr->signon) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
-                               {
-                                       curr->dns_done = true;
-                                       ZapThisDns(curr->fd);
-                                       ServerInstance->stats->statsDnsBad++;
-                                       FullConnectUser(curr,&GlobalGoners);
-                                       continue;
-                               }
-
-                               if ((fd_ref_table[cfd] != curr) && (curr))
-                                       /* Somebody blatted this user in OnCheckReady (!) */
-                                       continue;
-       
-                               if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
-                               {
-                                       log(DEBUG,"dns done, registered=3, and modules ready, OK");
-                                       FullConnectUser(curr,&GlobalGoners);
-                                       ZapThisDns(curr->fd);
-                                       continue;
-                               }
-
-                               if ((fd_ref_table[cfd] != curr) && (curr))
-                                       /* Somebody blatted this user in OnCheckReady (!) */
-                                       continue;
-               
-                               // It's time to PING this user. Send them a ping.
-                               if ((TIME > curr->nping) && (curr->registered == REG_ALL))
+                               log(DEBUG,"InspIRCd: registration timeout: %s",curr->nick);
+                               //ZapThisDns(curr->fd);
+                               GlobalGoners.AddItem(curr,"Registration timeout");
+                               continue;
+                       }
+                       /*
+                        * user has signed on with USER/NICK/PASS, and dns has completed, all the modules
+                        * say this user is ok to proceed, fully connect them.
+                        */
+                       if ((TIME > curr->signon) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
+                       {
+                               curr->dns_done = true;
+                               //ZapThisDns(curr->fd);
+                               ServerInstance->stats->statsDnsBad++;
+                               FullConnectUser(curr,&GlobalGoners);
+                               continue;
+                       }
+                       if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
+                       {
+                               log(DEBUG,"dns done, registered=3, and modules ready, OK");
+                               FullConnectUser(curr,&GlobalGoners);
+                               //ZapThisDns(curr->fd);
+                               continue;
+                       }
+                       // It's time to PING this user. Send them a ping.
+                       if ((TIME > curr->nping) && (curr->registered == REG_ALL))
+                       {
+                               // This user didn't answer the last ping, remove them
+                               if (!curr->lastping)
                                {
-                                       // This user didn't answer the last ping, remove them
-                                       if (!curr->lastping)
-                                       {
-                                               GlobalGoners.AddItem(curr,"Ping timeout");
-                                               curr->lastping = 1;
-                                               curr->nping = TIME+curr->pingmax;
-                                               continue;
-                                       }
-       
-                                       Write(curr->fd,"PING :%s",Config->ServerName);
-                                       curr->lastping = 0;
+                                       GlobalGoners.AddItem(curr,"Ping timeout");
+                                       curr->lastping = 1;
                                        curr->nping = TIME+curr->pingmax;
+                                       continue;
                                }
+                               Write(curr->fd,"PING :%s",Config->ServerName);
+                               curr->lastping = 0;
+                               curr->nping = TIME+curr->pingmax;
                        }
 
                        /*
                         * We can flush the write buffer as the last thing we do, because if they
                         * match any of the above conditions its no use flushing their buffer anyway.
                         */
-
-                       /* Check again that theyre still here (something above may have changed that) */
-                       if ((cfd > -1) && (cfd < MAX_DESCRIPTORS) && (fd_ref_table[cfd] == curr) && (curr))
+       
+                       curr->FlushWriteBuf();
+                       if (*curr->GetWriteError())
                        {
-                               curr->FlushWriteBuf();
-                               if (*curr->GetWriteError())
-                               {
-                                       GlobalGoners.AddItem(curr,curr->GetWriteError());
-                                       continue;
-                               }
+                               GlobalGoners.AddItem(curr,curr->GetWriteError());
+                               continue;
                        }
                }
+
        }
 
+
        /* Remove all the queued users who are due to be quit, free memory used. */
        GlobalGoners.Apply();
 }