]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Fixed bug where if channel limit was lower than the user count users could still...
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 27325901931bc9b9acc11075bfd500a0902d4d9e..3e70d27f543eeaecca9f4ffe747ce4272ef1beed 100644 (file)
@@ -1567,7 +1567,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
                
                                        if (Ptr->limit)
                                        {
-                                               if (usercount(Ptr) == Ptr->limit)
+                                               if (usercount(Ptr) >= Ptr->limit)
                                                {
                                                        WriteServ(user->fd,"471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
                                                        return NULL;
@@ -1780,7 +1780,6 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
 
        int MOD_RESULT = 0;
        FOREACH_RESULT(OnAccessCheck(src,user,Ptr,AC_KICK));
-       
        if (MOD_RESULT == ACR_DENY)
                return;
 
@@ -1800,7 +1799,14 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
                        return;
                }
        }
-       
+
+       MOD_RESULT = 0;
+       FOREACH_RESULT(OnUserPreKick(src,user,Ptr,reason));
+       if (MOD_RESULT)
+               return;
+
+       FOREACH_MOD OnUserKick(src,user,Ptr,reason);
+
        for (int i =0; i != MAXCHANS; i++)
        {
                /* zap it from the channel list of the user */
@@ -1814,7 +1820,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
                        break;
                }
        }
-       
+
        /* if there are no users left on the channel */
        if (!usercount(Ptr))
        {
@@ -2328,7 +2334,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
        strncpy(clientlist[tempnick]->host, host,160);
        strncpy(clientlist[tempnick]->dhost, host,160);
        strncpy(clientlist[tempnick]->server, ServerName,256);
-       strncpy(clientlist[tempnick]->ident, "unknown",9);
+       strncpy(clientlist[tempnick]->ident, "unknown",12);
        clientlist[tempnick]->registered = 0;
        clientlist[tempnick]->signon = TIME+dns_timeout;
        clientlist[tempnick]->lastping = 1;
@@ -2575,11 +2581,26 @@ void FullConnectUser(userrec* user)
         NetSendToAll(buffer);
 }
 
+
+// this returns 1 when all modules are satisfied that the user should be allowed onto the irc server
+// (until this returns true, a user will block in the waiting state, waiting to connect up to the
+// registration timeout maximum seconds)
+bool AllModulesReportReady(userrec* user)
+{
+       for (int i = 0; i <= MODCOUNT; i++)
+       {
+               int res = modules[i]->OnCheckReady(user);
+                       if (!res)
+                               return false;
+       }
+       return true;
+}
+
 /* shows the message of the day, and any other on-logon stuff */
 void ConnectUser(userrec *user)
 {
        // dns is already done, things are fast. no need to wait for dns to complete just pass them straight on
-       if ((user->dns_done) && (user->registered >= 3))
+       if ((user->dns_done) && (user->registered >= 3) && (AllModulesReportReady(user)))
        {
                FullConnectUser(user);
        }
@@ -3906,14 +3927,16 @@ int InspIRCd(void)
                                                        kill_link(count2->second,"Registration timeout");
                                                        goto label;
                                                }
-                                               if ((TIME > count2->second->signon) && (count2->second->registered == 3))
+                                               if ((TIME > count2->second->signon) && (count2->second->registered == 3) && (AllModulesReportReady(count2->second)))
                                                {
+                                                       log(DEBUG,"signon exceed, registered=3, and modules ready, OK");
                                                        count2->second->dns_done = true;
                                                        FullConnectUser(count2->second);
                                                        goto label;
                                                }
-                                               if ((count2->second->dns_done) && (count2->second->registered == 3)) // both NICK and USER... and DNS
+                                               if ((count2->second->dns_done) && (count2->second->registered == 3) && (AllModulesReportReady(count2->second))) // both NICK and USER... and DNS
                                                {
+                                                       log(DEBUG,"dns done, registered=3, and modules ready, OK");
                                                        FullConnectUser(count2->second);
                                                        goto label;
                                                }