X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_xline%2Fcmd_zline.cpp;h=31030adce5ce715162e4dba3d9f53a8430b2b71a;hb=f2e3fd5952b23209b084bde4f464e6643c8a00ff;hp=eda5b2a4623fa572da9eb02f73d22a1d5b3f47e1;hpb=c67d3103e9f7397f0ab9631bf07a5e5547deb2c3;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_xline/cmd_zline.cpp b/src/coremods/core_xline/cmd_zline.cpp index eda5b2a46..31030adce 100644 --- a/src/coremods/core_xline/cmd_zline.cpp +++ b/src/coremods/core_xline/cmd_zline.cpp @@ -21,23 +21,16 @@ #include "inspircd.h" #include "xline.h" -/** Handle /ZLINE. - */ -class CommandZline : public Command +#include "core_xline.h" + +CommandZline::CommandZline(Module* parent) + : Command(parent, "ZLINE", 1, 3) { - public: - /** Constructor for zline. - */ - CommandZline ( Module* parent) : Command(parent,"ZLINE",1,3) { flags_needed = 'o'; Penalty = 0; syntax = " [ :]"; } - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector& parameters, User *user); -}; + flags_needed = 'o'; + syntax = " [ :]"; +} -CmdResult CommandZline::Handle (const std::vector& parameters, User *user) +CmdResult CommandZline::Handle(User* user, const Params& parameters) { std::string target = parameters[0]; @@ -45,7 +38,7 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User { if (target.find('!') != std::string::npos) { - user->WriteNotice("*** You cannot include a nickname in a zline, a zline must ban only an IP mask"); + user->WriteNotice("*** You cannot include a nickname in a Z-line, a Z-line must ban only an IP mask."); return CMD_FAILURE; } @@ -65,10 +58,16 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User ipaddr++; } - if (ServerInstance->IPMatchesEveryone(ipaddr,user)) + IPMatcher matcher; + if (InsaneBan::MatchesEveryone(ipaddr, matcher, user, "Z", "ipmasks")) return CMD_FAILURE; - unsigned long duration = InspIRCd::Duration(parameters[1]); + unsigned long duration; + if (!InspIRCd::Duration(parameters[1], duration)) + { + user->WriteNotice("*** Invalid duration for Z-line."); + return CMD_FAILURE; + } ZLine* zl = new ZLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr); if (ServerInstance->XLines->AddLine(zl,user)) { @@ -88,7 +87,7 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User else { delete zl; - user->WriteNotice("*** Z-Line for " + std::string(ipaddr) + " already exists"); + user->WriteNotice("*** Z-line for " + std::string(ipaddr) + " already exists."); } } else @@ -99,7 +98,7 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User } else { - user->WriteNotice("*** Z-Line " + target + " not found in list, try /stats Z."); + user->WriteNotice("*** Z-line " + target + " not found in list, try /stats Z."); return CMD_FAILURE; } } @@ -107,4 +106,7 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandZline) +bool CommandZline::IPMatcher::Check(User* user, const std::string& ip) const +{ + return InspIRCd::MatchCIDR(user->GetIPString(), ip, ascii_case_insensitive_map); +}