X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fxline.cpp;h=dedf8c7a9c917a4c838ee31acce445d0eab3a57a;hb=aa05a6fd4d5c11dc8e8adc469134a2802446fe9f;hp=4bb9551ecc6d8c1006f6b70459ec936004c78047;hpb=b36ce84c7da93f680fc397bcb4c877abe063eaaa;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/xline.cpp b/src/xline.cpp index 4bb9551ec..dedf8c7a9 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -23,7 +23,6 @@ #include "inspircd.h" #include "xline.h" -#include "bancache.h" /** An XLineFactory specialized to generate GLine* pointers */ @@ -156,7 +155,8 @@ void XLineManager::CheckELines() if (ELines.empty()) return; - for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++) { LocalUser* u = *u2; @@ -276,7 +276,7 @@ bool XLineManager::AddLine(XLine* line, User* user) if (!xlf) return false; - ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here? + ServerInstance->BanCache.RemoveEntries(line->type, false); // XXX perhaps remove ELines here? if (xlf->AutoApplyToUserList(line)) pending_lines.push_back(line); @@ -284,7 +284,7 @@ bool XLineManager::AddLine(XLine* line, User* user) lookup_lines[line->type][line->Displayable().c_str()] = line; line->OnAdd(); - FOREACH_MOD(I_OnAddLine,OnAddLine(user, line)); + FOREACH_MOD(OnAddLine, (user, line)); return true; } @@ -306,15 +306,13 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* if (simulate) return true; - ServerInstance->BanCache->RemoveEntries(y->second->type, true); + ServerInstance->BanCache.RemoveEntries(y->second->type, true); - FOREACH_MOD(I_OnDelLine,OnDelLine(user, y->second)); + FOREACH_MOD(OnDelLine, (user, y->second)); y->second->Unset(); - std::vector::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), y->second); - if (pptr != pending_lines.end()) - pending_lines.erase(pptr); + stdalgo::erase(pending_lines, y->second); delete y->second; x->second.erase(y); @@ -326,7 +324,8 @@ 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 (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++) { LocalUser* u = *u2; u->exempt = false; @@ -409,7 +408,7 @@ XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pat // removes lines that have expired void XLineManager::ExpireLine(ContainerIter container, LookupIter item) { - FOREACH_MOD(I_OnExpireLine, OnExpireLine(item->second)); + FOREACH_MOD(OnExpireLine, (item->second)); item->second->DisplayExpiry(); item->second->Unset(); @@ -418,9 +417,7 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item) * 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); + stdalgo::erase(pending_lines, item->second); delete item->second; container->second.erase(item); @@ -430,10 +427,10 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item) // applies lines, removing clients and changing nicks etc as applicable void XLineManager::ApplyLines() { - LocalUserList::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin(); - while (u2 != ServerInstance->Users->local_users.rend()) + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator j = list.begin(); j != list.end(); ++j) { - LocalUser* u = *u2++; + LocalUser* u = *j; // Don't ban people who are exempt. if (u->exempt) @@ -471,7 +468,7 @@ void XLineManager::InvokeStats(const std::string &type, int numeric, User* user, ExpireLine(n, i); } else - results.push_back(ServerInstance->Config->ServerName+" "+ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+ + results.push_back(ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+ ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason); i = safei; } @@ -533,11 +530,11 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) { const std::string banReason = line + "-Lined: " + reason; - if (!ServerInstance->Config->MoronBanner.empty()) - u->WriteNotice("*** " + ServerInstance->Config->MoronBanner); + if (!ServerInstance->Config->XLineMessage.empty()) + u->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage); if (ServerInstance->Config->HideBans) - ServerInstance->Users->QuitUser(u, line + "-Lined", banReason.c_str()); + ServerInstance->Users->QuitUser(u, line + "-Lined", &banReason); else ServerInstance->Users->QuitUser(u, banReason); @@ -545,7 +542,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) if (bancache) { ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Adding positive hit (" + line + ") for " + u->GetIPString()); - ServerInstance->BanCache->AddHit(u->GetIPString(), this->type, line + "-Lined: " + this->reason, this->duration); + ServerInstance->BanCache.AddHit(u->GetIPString(), this->type, banReason, this->duration); } } @@ -642,7 +639,7 @@ bool QLine::Matches(User *u) void QLine::Apply(User* u) { /* Force to uuid on apply of qline, no need to disconnect any more :) */ - u->ForceNickChange(u->uuid); + u->ChangeNick(u->uuid); } @@ -680,7 +677,8 @@ bool GLine::Matches(const std::string &str) void ELine::OnAdd() { /* When adding one eline, only check the one eline */ - for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++) { LocalUser* u = *u2; if (this->Matches(u))