X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fxline.cpp;h=268804f9dce804981a14f4f9e700e6746ffef23b;hb=af7e1a1ca8b36064593becf62b1a91468ad32237;hp=56bd029d7a754b8fefb9f9b3dd8ef1daa35c4d00;hpb=85a79e990de2b1c05a161ea49857a9586567b8c2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/xline.cpp b/src/xline.cpp index 56bd029d7..268804f9d 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -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 @@ -69,7 +70,7 @@ void XLineManager::CheckELines() if (ELines.empty()) return; - for (std::vector::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); @@ -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(); @@ -198,7 +203,7 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* void ELine::Unset() { /* remove exempt from everyone and force recheck after deleting eline */ - for (std::vector::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); u->exempt = false; @@ -284,26 +289,28 @@ 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::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::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); } // applies lines, removing clients and changing nicks etc as applicable void XLineManager::ApplyLines() { - for (std::vector::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); @@ -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); } @@ -522,7 +536,7 @@ bool GLine::Matches(const std::string &str) void ELine::OnAdd() { /* When adding one eline, only check the one eline */ - for (std::vector::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); if (this->Matches(u)) @@ -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;