X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nickflood.cpp;h=c3cff2cd18566576962c4cead46e1cda67ec4341;hb=ad47ea662698e72ff8f79b03512b1e7fe81bdf53;hp=04d7c8b5e2cc86d28e812cf578bcc4a64639f282;hpb=349106f3f9f75d7f957fc5d1e71ca650f4807bb9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 04d7c8b5e..c3cff2cd1 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -20,8 +20,6 @@ #include "inspircd.h" -/* $ModDesc: Provides channel mode +F (nick flood protection) */ - /** Holds settings and state associated with channel mode +F */ class nickfloodsettings @@ -94,7 +92,7 @@ class NickFlood : public ModeHandler std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { - source->WriteNumeric(608, "%s %s :Invalid flood parameter",source->nick.c_str(),channel->name.c_str()); + source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); return MODEACTION_DENY; } @@ -104,7 +102,7 @@ class NickFlood : public ModeHandler if ((nnicks<1) || (nsecs<1)) { - source->WriteNumeric(608, "%s %s :Invalid flood parameter",source->nick.c_str(),channel->name.c_str()); + source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); return MODEACTION_DENY; } @@ -115,16 +113,14 @@ class NickFlood : public ModeHandler ext.set(channel, new nickfloodsettings(nsecs, nnicks)); parameter = ConvToStr(nnicks) + ":" + ConvToStr(nsecs); - channel->SetModeParam('F', parameter); return MODEACTION_ALLOW; } else { - if (!channel->IsModeSet('F')) + if (!channel->IsModeSet(this)) return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam('F', ""); return MODEACTION_ALLOW; } } @@ -135,25 +131,13 @@ class ModuleNickFlood : public Module NickFlood nf; public: - ModuleNickFlood() : nf(this) { } - void init() - { - ServerInstance->Modules->AddService(nf); - ServerInstance->Modules->AddService(nf.ext); - Implementation eventlist[] = { I_OnUserPreNick, I_OnUserPostNick }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - } - - ModResult OnUserPreNick(User* user, const std::string &newnick) + ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE { - if (ServerInstance->NICKForced.get(user)) /* Allow forced nick changes */ - return MOD_RES_PASSTHRU; - for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { Channel *channel = *i; @@ -168,7 +152,7 @@ class ModuleNickFlood : public Module if (f->islocked()) { - user->WriteNumeric(447, "%s :%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", user->nick.c_str(), channel->name.c_str(), f->nicks, f->secs); + user->WriteNumeric(ERR_CANTCHANGENICK, ":%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), f->nicks, f->secs); return MOD_RES_DENY; } @@ -188,7 +172,7 @@ class ModuleNickFlood : public Module /* * XXX: HACK: We do the increment on the *POST* event here (instead of all together) because we have no way of knowing whether other modules would block a nickchange. */ - void OnUserPostNick(User* user, const std::string &oldnick) + void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE { if (isdigit(user->nick[0])) /* allow switches to UID */ return; @@ -214,11 +198,7 @@ class ModuleNickFlood : public Module } } - ~ModuleNickFlood() - { - } - - Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Channel mode F - nick flood protection", VF_VENDOR); }