]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / xline.cpp
index c292cc1702f8768f91ed2b5fe3ff46f8c7f28459..20df92dd0003503989ceed3997ff7210eb21abc4 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -16,6 +16,7 @@
 #include "inspircd.h"
 #include "wildcard.h"
 #include "xline.h"
+#include "bancache.h"
 
 /*
  * This is now version 3 of the XLine subsystem, let's see if we can get it as nice and 
@@ -150,6 +151,8 @@ bool XLineManager::AddLine(XLine* line, User* user)
 {
        /*IdentHostPair ih = IdentSplit(hostmask);*/
 
+       ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here?
+
        if (DelLine(line->Displayable(), line->type, user, true))
                return false;
 
@@ -180,6 +183,8 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User*
        if (simulate)
                return true;
 
+       ServerInstance->BanCache->RemoveEntries(y->second->type, true);
+
        FOREACH_MOD(I_OnDelLine,OnDelLine(user, y->second));
 
        y->second->Unset();
@@ -284,19 +289,21 @@ XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pat
 // removes lines that have expired
 void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
 {
-               item->second->DisplayExpiry();
-               item->second->Unset();
+       FOREACH_MOD(I_OnExpireLine, OnExpireLine(item->second));
+
+       item->second->DisplayExpiry();
+       item->second->Unset();
 
-               /* TODO: Can we skip this loop by having a 'pending' field in the XLine class, which is set when a line
-                * is pending, cleared when it is no longer pending, so we skip over this loop if its not pending?
-                * -- Brain
-                */
-               std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), item->second);
-               if (pptr != pending_lines.end())
-                       pending_lines.erase(pptr);
+       /* TODO: Can we skip this loop by having a 'pending' field in the XLine class, which is set when a line
+        * is pending, cleared when it is no longer pending, so we skip over this loop if its not pending?
+        * -- Brain
+        */
+       std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), item->second);
+       if (pptr != pending_lines.end())
+               pending_lines.erase(pptr);
 
-               delete item->second;
-               container->second.erase(item);
+       delete item->second;
+       container->second.erase(item);
 }
 
 
@@ -383,7 +390,7 @@ void XLine::Apply(User* u)
 {
 }
 
-void XLine::DefaultApply(User* u, const std::string &line)
+void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
 {
        char reason[MAXBUF];
        snprintf(reason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason);
@@ -393,6 +400,13 @@ void XLine::DefaultApply(User* u, const std::string &line)
                User::QuitUser(ServerInstance, u, line + "-Lined", reason);
        else
                User::QuitUser(ServerInstance, u, reason);
+
+
+       if (bancache)
+       {
+               ServerInstance->Log(DEBUG, std::string("BanCache: Adding positive hit (") + line + ") for " + u->GetIPString());
+               ServerInstance->BanCache->AddHit(u->GetIPString(), this->type, line + "-Lined: " + this->reason);
+       }
 }
 
 bool KLine::Matches(User *u)
@@ -413,7 +427,7 @@ bool KLine::Matches(User *u)
 
 void KLine::Apply(User* u)
 {
-       DefaultApply(u, "K");
+       DefaultApply(u, "K", (strcmp(this->identmask, "*") == 0) ? true : false);
 }
 
 bool GLine::Matches(User *u)
@@ -434,7 +448,7 @@ bool GLine::Matches(User *u)
 
 void GLine::Apply(User* u)
 {       
-       DefaultApply(u, "G");
+       DefaultApply(u, "G", (strcmp(this->identmask, "*") == 0) ? true : false);
 }
 
 bool ELine::Matches(User *u)
@@ -466,7 +480,7 @@ bool ZLine::Matches(User *u)
 
 void ZLine::Apply(User* u)
 {       
-       DefaultApply(u, "Z");
+       DefaultApply(u, "Z", true);
 }
 
 
@@ -483,8 +497,8 @@ bool QLine::Matches(User *u)
 
 void QLine::Apply(User* u)
 {       
-       /* Can we force the user to their uid here instead? */
-       DefaultApply(u, "Q");
+       /* Force to uuid on apply of qline, no need to disconnect any more :) */
+       u->ForceNickChange(u->uuid);
 }
 
 
@@ -608,7 +622,7 @@ XLineFactory* XLineManager::GetFactory(const std::string &type)
 {
        XLineFactMap::iterator n = line_factory.find(type);
 
-       if (n != line_factory.end())
+       if (n == line_factory.end())
                return NULL;
 
        return n->second;