X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_shun.cpp;h=66cc7fd58dc488e2a4585d57d76ffa9675bc1ac0;hb=451e687f681ccab5c02a8de1a7d59b324efbfe08;hp=dbc1812c700ce96e42f244097e1d13fa4d6bf40e;hpb=d24619c012b34d5a3d4cfb93e7bea3ff3d5721e7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index dbc1812c7..66cc7fd58 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -44,6 +44,9 @@ public: if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext)) return true; + if (InspIRCd::MatchCIDR(u->GetIPString(), matchtext, ascii_case_insensitive_map)) + return true; + return false; } @@ -103,13 +106,17 @@ class CommandShun : public Command if (parameters.size() == 1) { - if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", user)) + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SHUN", user)) + { + ServerInstance->SNO->WriteToSnoMask('x', "%s removed SHUN on %s", user->nick.c_str(), parameters[0].c_str()); + } + else if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s removed SHUN on %s",user->nick.c_str(),target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s removed SHUN on %s", user->nick.c_str(), target.c_str()); } else { - user->WriteNotice("*** Shun " + target + " not found in list, try /stats H."); + user->WriteNotice("*** Shun " + parameters[0] + " not found in list, try /stats H."); return CMD_FAILURE; } } @@ -140,7 +147,7 @@ class CommandShun : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s", user->nick.c_str(), target.c_str(), timestr.c_str(), expr.c_str()); } @@ -168,7 +175,7 @@ class ModuleShun : public Module { CommandShun cmd; ShunFactory f; - std::set ShunEnabledCommands; + insp::flat_set ShunEnabledCommands; bool NotifyOfShun; bool affectopers; @@ -180,9 +187,6 @@ class ModuleShun : public Module void init() CXX11_OVERRIDE { ServerInstance->XLines->RegisterFactory(&f); - ServerInstance->Modules->AddService(cmd); - - OnRehash(NULL); } ~ModuleShun() @@ -191,22 +195,22 @@ class ModuleShun : public Module ServerInstance->XLines->UnregisterFactory(&f); } - void Prioritize() + void Prioritize() CXX11_OVERRIDE { Module* alias = ServerInstance->Modules->Find("m_alias.so"); - ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIORITY_BEFORE, &alias); + ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIORITY_BEFORE, alias); } - ModResult OnStats(char symbol, User* user, string_list& out) CXX11_OVERRIDE + ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE { - if (symbol != 'H') + if (stats.GetSymbol() != 'H') return MOD_RES_PASSTHRU; - ServerInstance->XLines->InvokeStats("SHUN", 223, user, out); + ServerInstance->XLines->InvokeStats("SHUN", 223, stats); return MOD_RES_DENY; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); std::string cmds = tag->getString("enabledcommands"); @@ -217,10 +221,10 @@ class ModuleShun : public Module ShunEnabledCommands.clear(); - std::stringstream dcmds(cmds); + irc::spacesepstream dcmds(cmds); std::string thiscmd; - while (dcmds >> thiscmd) + while (dcmds.GetToken(thiscmd)) { ShunEnabledCommands.insert(thiscmd); } @@ -246,9 +250,7 @@ class ModuleShun : public Module return MOD_RES_PASSTHRU; } - std::set::iterator i = ShunEnabledCommands.find(command); - - if (i == ShunEnabledCommands.end()) + if (!ShunEnabledCommands.count(command)) { if (NotifyOfShun) user->WriteNotice("*** Command " + command + " not processed, as you have been blocked from issuing commands (SHUN)");