]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Only send 320 numeric if the SSL user is on our port
[user/henk/code/inspircd.git] / src / xline.cpp
index 52648d1d1fa2416910755d13db7c193af1fa109a..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,14 +46,16 @@ using namespace std;
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "typedefs.h"
+#include "cull_list.h"
+
+extern ServerConfig *Config;
 
 extern int MODCOUNT;
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 extern ServerConfig* Config;
-extern std::stringstream config_f;
-/*typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;*/
 extern user_hash clientlist;
+extern std::vector<userrec*> local_users;
 
 /* Version two, now with optimized expiry!
  *
@@ -113,33 +114,33 @@ void read_xline_defaults()
        char host[MAXBUF];
        char reason[MAXBUF];
 
-       for (int i = 0; i < ConfValueEnum("badip",&config_f); i++)
+       for (int i = 0; i < Config->ConfValueEnum("badip",&Config->config_f); i++)
        {
-               ConfValue("badip","ipmask",i,ipmask,&config_f);
-               ConfValue("badip","reason",i,reason,&config_f);
+               Config->ConfValue("badip","ipmask",i,ipmask,&Config->config_f);
+               Config->ConfValue("badip","reason",i,reason,&Config->config_f);
                add_zline(0,"<Config>",reason,ipmask);
                log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
        }
        
-       for (int i = 0; i < ConfValueEnum("badnick",&config_f); i++)
+       for (int i = 0; i < Config->ConfValueEnum("badnick",&Config->config_f); i++)
        {
-               ConfValue("badnick","nick",i,nick,&config_f);
-               ConfValue("badnick","reason",i,reason,&config_f);
+               Config->ConfValue("badnick","nick",i,nick,&Config->config_f);
+               Config->ConfValue("badnick","reason",i,reason,&Config->config_f);
                add_qline(0,"<Config>",reason,nick);
                log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
        }
        
-       for (int i = 0; i < ConfValueEnum("badhost",&config_f); i++)
+       for (int i = 0; i < Config->ConfValueEnum("badhost",&Config->config_f); i++)
        {
-               ConfValue("badhost","host",i,host,&config_f);
-               ConfValue("badhost","reason",i,reason,&config_f);
+               Config->ConfValue("badhost","host",i,host,&Config->config_f);
+               Config->ConfValue("badhost","reason",i,reason,&Config->config_f);
                add_kline(0,"<Config>",reason,host);
                log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
        }
-       for (int i = 0; i < ConfValueEnum("exception",&config_f); i++)
+       for (int i = 0; i < Config->ConfValueEnum("exception",&Config->config_f); i++)
        {
-               ConfValue("exception","host",i,host,&config_f);
-               ConfValue("exception","reason",i,reason,&config_f);
+               Config->ConfValue("exception","host",i,host,&Config->config_f);
+               Config->ConfValue("exception","reason",i,reason,&Config->config_f);
                add_eline(0,"<Config>",reason,host);
                log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
        }
@@ -646,78 +647,61 @@ 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;
-       
-       while (go_again)
+
+       CullList* Goners = new CullList();
+       char* check = NULL;
+       for (std::vector<userrec*>::const_iterator u2 = local_users.begin(); u2 != local_users.end(); u2++)
        {
-               go_again = false;
-               for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+               userrec* u = (userrec*)(*u2);
+               u->MakeHost(host);
+               if (elines.size())
+               {
+                       // ignore people matching exempts
+                       if (matches_exception(host))
+                               continue;
+               }
+               if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
+               {
+                       if ((check = matches_gline(host)))
+                       {
+                               snprintf(reason,MAXBUF,"G-Lined: %s",check);
+                               Goners->AddItem(u,reason);
+                       }
+               }
+               if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
                {
-                       if (u->second->fd > -1)
+                       if ((check = matches_kline(host)))
                        {
-                               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()))
-                               {
-                                       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;
-                                       }
-                               }
-                               if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
-                               {
-                                       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;
-                                       }
-                               }
-                               if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
-                               {
-                                       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;
-                                       }
-                               }
-                               if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
-                               {
-                                       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,"K-Lined: %s",check);
+                               Goners->AddItem(u,reason);
+                       }
+               }
+               if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+               {
+                       if ((check = matches_qline(u->nick)))
+                       {
+                               snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
+                               Goners->AddItem(u,reason);
+                       }
+               }
+               if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+               {
+                       if ((check = matches_zline((char*)inet_ntoa(u->ip4))))
+                       {
+                               snprintf(reason,MAXBUF,"Z-Lined: %s",check);
+                               Goners->AddItem(u,reason);
                        }
                }
        }
+
+       Goners->Apply();
+       delete Goners;
 }
 
 void stats_k(userrec* user)
@@ -759,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);
 }
+