]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Converted more stuff to 'Implements' system
[user/henk/code/inspircd.git] / src / xline.cpp
index 415ed9ed22a2bbf7d1e0356130c6344c522f56dd..4a7cfdea5a337d29e7ad967565ded015dd576a4c 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -19,7 +19,6 @@ using namespace std;
 #include "inspircd_config.h"
 #include "inspircd.h"
 #include "inspircd_io.h"
-#include "inspircd_util.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/errno.h>
@@ -47,6 +46,7 @@ using namespace std;
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "typedefs.h"
+#include "cull_list.h"
 
 extern ServerConfig *Config;
 
@@ -646,78 +646,67 @@ void expire_lines()
 
 void apply_lines(const int What)
 {
-       bool go_again = true;
        char reason[MAXBUF];
        char host[MAXBUF];
        
-       if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()))
+       if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) &&
+       (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
                return;
+
+       CullList* Goners = new CullList();
        
-       while (go_again)
+       for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
        {
-               go_again = false;
-               for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+               if (u->second->fd > -1)
                {
-                       if (u->second->fd > -1)
+                       snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
+                       if (elines.size())
                        {
-                               snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
-                               if (elines.size())
-                               {
-                                       // ignore people matching exempts
-                                       if (matches_exception(host))
-                                               continue;
-                               }
-                               if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
+                               // ignore people matching exempts
+                               if (matches_exception(host))
+                                       continue;
+                       }
+                       if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
+                       {
+                               char* check = matches_gline(host);
+                               if (check)
                                {
-                                       char* check = matches_gline(host);
-                                       if (check)
-                                       {
-                                               WriteOpers("*** User %s matches G-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",check);
-                                               snprintf(reason,MAXBUF,"G-Lined: %s",check);
-                                               kill_link(u->second,reason);
-                                               go_again = true;
-                                               break;
-                                       }
+                                       snprintf(reason,MAXBUF,"G-Lined: %s",check);
+                                       Goners->AddItem(u->second,reason);
                                }
-                               if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+                       }
+                       if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+                       {
+                               char* check = matches_kline(host);
+                               if (check)
                                {
-                                       char* check = matches_kline(host);
-                                       if (check)
-                                       {
-                                               WriteOpers("*** User %s matches K-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",check);
-                                               snprintf(reason,MAXBUF,"K-Lined: %s",check);
-                                               kill_link(u->second,reason);
-                                               go_again = true;
-                                               break;
-                                       }
+                                       snprintf(reason,MAXBUF,"K-Lined: %s",check);
+                                       Goners->AddItem(u->second,reason);
                                }
-                               if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+                       }
+                       if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+                       {
+                               char* check = matches_qline(u->second->nick);
+                               if (check)
                                {
-                                       char* check = matches_qline(u->second->nick);
-                                       if (check)
-                                       {
-                                               snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
-                                               WriteOpers("*** Q-Lined nickname %s from %s: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",u->second->host,check);
-                                               kill_link(u->second,reason);
-                                               go_again = true;
-                                               break;
-                                       }
+                                       snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
+                                       Goners->AddItem(u->second,reason);
                                }
-                               if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+                       }
+                       if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+                       {
+                               char* check = matches_zline(u->second->ip);
+                               if (check)
                                {
-                                       char* check = matches_zline(u->second->ip);
-                                       if (check)
-                                       {
-                                               snprintf(reason,MAXBUF,"Z-Lined: %s",check);
-                                               WriteOpers("*** User %s matches Z-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",u->second->host,check);
-                                               kill_link(u->second,reason);
-                                               go_again = true;
-                                               break;
-                                       }
+                                       snprintf(reason,MAXBUF,"Z-Lined: %s",check);
+                                       Goners->AddItem(u->second,reason);
                                }
                        }
                }
        }
+
+       Goners->Apply();
+       delete Goners;
 }
 
 void stats_k(userrec* user)