X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nickflood.cpp;h=e20ab1258113c19b50542f222fb5f01afd180c6a;hb=ff766773bc547b03ffa3a15cb1c89896a2a7b8cf;hp=abb3cdfafa4a1f4889cf103c3970a4d5802318f7;hpb=b841e4bb855f43533601171fb405c74f04b4ea71;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index abb3cdfaf..e20ab1258 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -1,8 +1,12 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2013, 2016-2019 Sadie Powell + * Copyright (C) 2012, 2019 Robby + * Copyright (C) 2012, 2014 Attila Molnar + * Copyright (C) 2010 Craig Edwards * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2007, 2009 Robin Burchell + * Copyright (C) 2007-2009 Robin Burchell * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -19,6 +23,7 @@ #include "inspircd.h" +#include "modules/exemption.h" // The number of seconds nickname changing will be blocked for. static unsigned int duration; @@ -53,10 +58,6 @@ class nickfloodsettings bool shouldlock() { - /* XXX HACK: using counter + 1 here now to allow the counter to only be incremented - * on successful nick changes; this will be checked before the counter is - * incremented. - */ return ((ServerInstance->Time() <= reset) && (counter == this->nicks)); } @@ -87,24 +88,25 @@ class NickFlood : public ParamMode > NickFlood(Module* Creator) : ParamMode >(Creator, "nickflood", 'F') { + syntax = ":"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) + ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { - source->WriteNumeric(608, channel->name, "Invalid flood parameter"); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); return MODEACTION_DENY; } /* Set up the flood parameters for this channel */ - unsigned int nnicks = ConvToInt(parameter.substr(0, colon)); - unsigned int nsecs = ConvToInt(parameter.substr(colon+1)); + unsigned int nnicks = ConvToNum(parameter.substr(0, colon)); + unsigned int nsecs = ConvToNum(parameter.substr(colon+1)); if ((nnicks<1) || (nsecs<1)) { - source->WriteNumeric(608, channel->name, "Invalid flood parameter"); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); return MODEACTION_DENY; } @@ -121,11 +123,13 @@ class NickFlood : public ParamMode > class ModuleNickFlood : public Module { + CheckExemption::EventProvider exemptionprov; NickFlood nf; public: ModuleNickFlood() - : nf(this) + : exemptionprov(this) + , nf(this) { } @@ -145,7 +149,7 @@ class ModuleNickFlood : public Module nickfloodsettings *f = nf.ext.get(channel); if (f) { - res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + res = CheckExemption::Call(exemptionprov, user, channel, "nickflood"); if (res == MOD_RES_ALLOW) continue; @@ -184,7 +188,7 @@ class ModuleNickFlood : public Module nickfloodsettings *f = nf.ext.get(channel); if (f) { - res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + res = CheckExemption::Call(exemptionprov, user, channel, "nickflood"); if (res == MOD_RES_ALLOW) return; @@ -199,7 +203,7 @@ class ModuleNickFlood : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Channel mode F - nick flood protection", VF_VENDOR); + return Version("Adds channel mode F (nickflood) which helps protect against spammers which mass-change nicknames.", VF_VENDOR); } };