]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nickflood.cpp
Fix cloaking not ignoring the case of a user's hostname.
[user/henk/code/inspircd.git] / src / modules / m_nickflood.cpp
index abb3cdfafa4a1f4889cf103c3970a4d5802318f7..48f085dde937201623e3a2a9a47a9e8fff7cdf78 100644 (file)
@@ -19,6 +19,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 // The number of seconds nickname changing will be blocked for.
 static unsigned int duration;
@@ -53,10 +54,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 +84,25 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >
        NickFlood(Module* Creator)
                : ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >(Creator, "nickflood", 'F')
        {
+               syntax = "<nick-changes>:<seconds>";
        }
 
-       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<unsigned int>(parameter.substr(0, colon));
+               unsigned int nsecs = ConvToNum<unsigned int>(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 +119,13 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >
 
 class ModuleNickFlood : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        NickFlood nf;
 
  public:
        ModuleNickFlood()
-               : nf(this)
+               : exemptionprov(this)
+               , nf(this)
        {
        }
 
@@ -145,7 +145,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 +184,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 +199,7 @@ class ModuleNickFlood : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Channel mode F - nick flood protection", VF_VENDOR);
+               return Version("Provides channel mode +F, nick flood protection", VF_VENDOR);
        }
 };