X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_joinflood.cpp;h=466ceb52e27f88088cbed0a8dd612c0c8b7d1e95;hb=83137d5f9274832f152acc7d19de3cb0897f9630;hp=3d342b636357f3efd72bb29ed750fff8de765c81;hpb=2b8ce39c6ea5e7a22fe39b21756f82051465f143;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 3d342b636..466ceb52e 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -12,9 +12,6 @@ */ #include "inspircd.h" -#include "users.h" -#include "channels.h" -#include "modules.h" /* $ModDesc: Provides channel mode +j (join flood protection) */ @@ -93,7 +90,7 @@ class JoinFlood : public ModeHandler public: JoinFlood(InspIRCd* Instance) : ModeHandler(Instance, 'j', 1, 0, false, MODETYPE_CHANNEL, false) { } - ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) { joinfloodsettings* x; if (channel->GetExt("joinflood",x)) @@ -102,13 +99,13 @@ class JoinFlood : public ModeHandler return std::make_pair(false, parameter); } - bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel) + bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel) { /* When TS is equal, the alphabetically later one wins */ return (their_param < our_param); } - ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool) { joinfloodsettings* dummy; @@ -197,7 +194,7 @@ class JoinFlood : public ModeHandler { joinfloodsettings *f; channel->GetExt("joinflood", f); - DELETE(f); + delete f; channel->Shrink("joinflood"); channel->SetMode('j', false); return MODEACTION_ALLOW; @@ -219,11 +216,13 @@ class ModuleJoinFlood : public Module { jf = new JoinFlood(ServerInstance); - if (!ServerInstance->AddMode(jf, 'j')) + if (!ServerInstance->Modes->AddMode(jf)) throw ModuleException("Could not add new modes!"); + Implementation eventlist[] = { I_OnChannelDelete, I_OnUserPreJoin, I_OnUserJoin }; + ServerInstance->Modules->Attach(eventlist, this, 3); } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) + virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs) { if (chan) { @@ -240,9 +239,15 @@ class ModuleJoinFlood : public Module return 0; } - virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent) + virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent) { joinfloodsettings *f; + + /* We arent interested in JOIN events caused by a network burst */ + if (sync) + return; + + /* But all others are OK */ if (channel->GetExt("joinflood",f)) { f->addjoin(); @@ -255,25 +260,21 @@ class ModuleJoinFlood : public Module } } - void OnChannelDelete(chanrec* chan) + void OnChannelDelete(Channel* chan) { joinfloodsettings *f; if (chan->GetExt("joinflood",f)) { - DELETE(f); + delete f; chan->Shrink("joinflood"); } } - void Implements(char* List) - { - List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserJoin] = 1; - } virtual ~ModuleJoinFlood() { ServerInstance->Modes->DelMode(jf); - DELETE(jf); + delete jf; } virtual Version GetVersion()