X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nickflood.cpp;h=a267cd4043d448031046c3cd29db7e297bad9c91;hb=b43fc66c17c2bef6dca66a966676b8128d5774ee;hp=5a59814d4b7fd1c04511649962fc71c212be7db3;hpb=1524caf2f799cff54c2de330c9670a0b761ba3d8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 5a59814d4..a267cd404 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -17,10 +17,8 @@ /** Holds settings and state associated with channel mode +F */ -class nickfloodsettings : public classbase +class nickfloodsettings { - private: - InspIRCd* ServerInstance; public: int secs; int nicks; @@ -29,9 +27,9 @@ class nickfloodsettings : public classbase int counter; bool locked; - nickfloodsettings(InspIRCd *Instance, int b, int c) : ServerInstance(Instance), secs(b), nicks(c) + nickfloodsettings(int b, int c) : secs(b), nicks(c) { - reset = Instance->Time() + secs; + reset = ServerInstance->Time() + secs; counter = 0; locked = false; }; @@ -91,7 +89,7 @@ class NickFlood : public ModeHandler { public: SimpleExtItem ext; - NickFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'F', PARAM_SETONLY, MODETYPE_CHANNEL), + NickFlood(Module* Creator) : ModeHandler(Creator, "nickflood", 'F', PARAM_SETONLY, MODETYPE_CHANNEL), ext("nickflood", Creator) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) @@ -140,7 +138,7 @@ class NickFlood : public ModeHandler if (!f) { parameter = ConvToStr(nnicks) + ":" +ConvToStr(nsecs); - f = new nickfloodsettings(ServerInstance, nsecs, nnicks); + f = new nickfloodsettings(nsecs, nnicks); ext.set(channel, f); channel->SetModeParam('F', parameter); return MODEACTION_ALLOW; @@ -159,7 +157,7 @@ class NickFlood : public ModeHandler // new mode param, replace old with new if ((nsecs > 0) && (nnicks > 0)) { - f = new nickfloodsettings(ServerInstance, nsecs, nnicks); + f = new nickfloodsettings(nsecs, nnicks); ext.set(channel, f); channel->SetModeParam('F', parameter); return MODEACTION_ALLOW; @@ -197,12 +195,12 @@ class ModuleNickFlood : public Module public: - ModuleNickFlood(InspIRCd* Me) - : Module(Me), nf(Me, this) + ModuleNickFlood() + : nf(this) { if (!ServerInstance->Modes->AddMode(&nf)) throw ModuleException("Could not add new modes!"); - Extensible::Register(&nf.ext); + ServerInstance->Extensions.Register(&nf.ext); Implementation eventlist[] = { I_OnUserPreNick, I_OnUserPostNick }; ServerInstance->Modules->Attach(eventlist, this, 2); } @@ -215,11 +213,13 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { Channel *channel = *i; + ModResult res; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetPrefixValue(user) == OP_VALUE) + FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,channel,"nickflood")); + if (res == MOD_RES_ALLOW) continue; if (f->islocked()) @@ -232,7 +232,7 @@ class ModuleNickFlood : public Module { f->clear(); f->lock(); - channel->WriteChannelWithServ((char*)ServerInstance->Config->ServerName, "NOTICE %s :No nick changes are allowed for 60 seconds because there have been more than %d nick changes in %d seconds.", channel->name.c_str(), f->nicks, f->secs); + channel->WriteChannelWithServ((char*)ServerInstance->Config->ServerName.c_str(), "NOTICE %s :No nick changes are allowed for 60 seconds because there have been more than %d nick changes in %d seconds.", channel->name.c_str(), f->nicks, f->secs); return MOD_RES_DENY; } } @@ -252,11 +252,13 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i) { Channel *channel = *i; + ModResult res; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetPrefixValue(user) == OP_VALUE) + FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,channel,"nickflood")); + if (res == MOD_RES_ALLOW) return; /* moved this here to avoid incrementing the counter for nick @@ -271,7 +273,6 @@ class ModuleNickFlood : public Module ~ModuleNickFlood() { - ServerInstance->Modes->DelMode(&nf); } Version GetVersion()