X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nickflood.cpp;h=3db6f5e641ad84b87d4a7b42b202a7df250c0347;hb=6c2edc2c5ab07a1fa8c32d3fa9abd6b9149b804c;hp=748ecf1d5a06313ffb866bada8589599347b40ff;hpb=c4d6ce8c5e1802e5b834d5845e31c3adf7700585;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 748ecf1d5..3db6f5e64 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -1,23 +1,30 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2007, 2009 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * 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 + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" /* $ModDesc: Provides channel mode +F (nick flood protection) */ /** Holds settings and state associated with channel mode +F */ -class nickfloodsettings : public classbase +class nickfloodsettings { public: int secs; @@ -92,15 +99,6 @@ class NickFlood : public ModeHandler 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) - { - nickfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->nicks)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { nickfloodsettings *f = ext.get(channel); @@ -200,24 +198,26 @@ class ModuleNickFlood : public Module { 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); } ModResult OnUserPreNick(User* user, const std::string &newnick) { - if (isdigit(newnick[0])) /* allow switches to UID */ + 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; + ModResult res; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT('F') && channel->GetPrefixValue(user) == OP_VALUE) + res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + if (res == MOD_RES_ALLOW) continue; if (f->islocked()) @@ -250,11 +250,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('F') && channel->GetPrefixValue(user) == OP_VALUE) + res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + if (res == MOD_RES_ALLOW) return; /* moved this here to avoid incrementing the counter for nick @@ -273,7 +275,7 @@ class ModuleNickFlood : public Module Version GetVersion() { - return Version("Channel mode F - nick flood protection", VF_COMMON | VF_VENDOR); + return Version("Channel mode F - nick flood protection", VF_VENDOR); } };