]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Removed some debug notices that were mistakenly in the DEFAULT loglevel
[user/henk/code/inspircd.git] / src / xline.cpp
index c6c4cd8a91d7161ce7a888903766f805c41d642a..bfffd0d84bd367080a47c73ccc729b28803f451c 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2006 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;
 
@@ -55,6 +55,7 @@ extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 extern ServerConfig* Config;
 extern user_hash clientlist;
+extern std::vector<userrec*> local_users;
 
 /* Version two, now with optimized expiry!
  *
@@ -642,124 +643,59 @@ void expire_lines()
        
 }
 
-class CullItem
-{
- private:
-       userrec* user;
-       std::string reason;
- public:
-       CullItem(userrec* u, std::string r)
-       {
-               this->user = u;
-               this->reason = r;
-       }
-
-       userrec* GetUser()
-       {
-               return this->user;
-       }
-
-       std::string GetReason()
-       {
-               return this->reason;
-       }
-};
-
-
-class CullList
-{
- private:
-        std::vector<CullItem> list;
-        char exempt[65535];
- public:
-        CullList()
-        {
-                memset(exempt,0,65535);
-                line = ltype;
-        }
-        
-        AddItem(userrec* user, std::string reason)
-        {
-                if ((user->fd > -1) && (exempt[user->fd] == 0))
-                {
-                        CullItem item(user,reason);
-                        list.push_back(item);
-                        exempt[user->fd] = 1;
-                }
-        }
-
-        Apply()
-        {
-                while (list.size())
-                {
-                       std::vector<CullItem>::iterator a = list.begin();
-                       userrec* u = a->GetUser();
-                       std::string reason = a->GetReason();
-                       kill_link(u,reason);
-                       list.erase(list.begin());
-                }
-        }
-}
-
 // applies lines, removing clients and changing nicks etc as applicable
 
 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();
-       
-       for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+       char* check = NULL;
+       for (std::vector<userrec*>::const_iterator u2 = local_users.begin(); u2 != local_users.end(); u2++)
        {
-               if (u->second->fd > -1)
+               userrec* u = (userrec*)(*u2);
+               u->MakeHost(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()))
+               {
+                       if ((check = matches_gline(host)))
                        {
-                               char* check = matches_gline(host);
-                               if (check)
-                               {
-                                       snprintf(reason,MAXBUF,"G-Lined: %s",check);
-                                       Goners->AddItem(u->second,reason);
-                               }
+                               snprintf(reason,MAXBUF,"G-Lined: %s",check);
+                               Goners->AddItem(u,reason);
                        }
-                       if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+               }
+               if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+               {
+                       if ((check = matches_kline(host)))
                        {
-                               char* check = matches_kline(host);
-                               if (check)
-                               {
-                                       snprintf(reason,MAXBUF,"K-Lined: %s",check);
-                                       Goners->AddItem(u->second,reason);
-                               }
+                               snprintf(reason,MAXBUF,"K-Lined: %s",check);
+                               Goners->AddItem(u,reason);
                        }
-                       if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+               }
+               if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+               {
+                       if ((check = matches_qline(u->nick)))
                        {
-                               char* check = matches_qline(u->second->nick);
-                               if (check)
-                               {
-                                       snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
-                                       Goners->AddItem(u->second,reason);
-                               }
+                               snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
+                               Goners->AddItem(u,reason);
                        }
-                       if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+               }
+               if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+               {
+                       if ((check = matches_zline((char*)inet_ntoa(u->ip4))))
                        {
-                               char* check = matches_zline(u->second->ip);
-                               if (check)
-                               {
-                                       snprintf(reason,MAXBUF,"Z-Lined: %s",check);
-                                       Goners->AddItem(u->second,reason);
-                               }
+                               snprintf(reason,MAXBUF,"Z-Lined: %s",check);
+                               Goners->AddItem(u,reason);
                        }
                }
        }
@@ -807,3 +743,4 @@ void stats_e(userrec* user)
        for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
                WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
 }
+