X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_messageflood.cpp;h=52fed00f0b47822dd9014b0ebebafcb57d46b1cb;hb=1484a054870bdfe94346057053d5c8e48a708232;hp=2cbecfdac409e3b32160029972d481a078bdbf8c;hpb=9d8022a06563e9a11b6d16b139090cde82fad877;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 2cbecfdac..52fed00f0 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -25,7 +25,7 @@ using namespace std; /* $ModDesc: Provides channel mode +f (message flood protection) */ -class floodsettings +class floodsettings : public classbase { public: bool ban; @@ -90,6 +90,8 @@ class MsgFlood : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { + floodsettings *f; + if (adding) { char ndata[MAXBUF]; @@ -131,10 +133,13 @@ class MsgFlood : public ModeHandler } else { - if (!channel->GetExt("flood")) + if (!channel->GetExt("flood", f)) { + parameter = ConvToStr(nlines) + ":" +ConvToStr(nsecs); floodsettings *f = new floodsettings(ban,nsecs,nlines); - channel->Extend("flood",(char*)f); + channel->Extend("flood",f); + channel->SetMode('f', true); + channel->SetModeParam('f', parameter.c_str(), true); return MODEACTION_ALLOW; } } @@ -148,11 +153,11 @@ class MsgFlood : public ModeHandler } else { - if (channel->GetExt("flood")) + if (channel->GetExt("flood", f)) { - floodsettings *f = (floodsettings*)channel->GetExt("flood"); DELETE(f); channel->Shrink("flood"); + channel->SetMode('f', false); return MODEACTION_ALLOW; } } @@ -180,8 +185,8 @@ class ModuleMsgFlood : public Module { if (IS_LOCAL(user)) { - floodsettings *f = (floodsettings*)dest->GetExt("flood"); - if (f) + floodsettings *f; + if (dest->GetExt("flood", f)) { f->addmessage(user); if (f->shouldkick(user)) @@ -190,11 +195,23 @@ class ModuleMsgFlood : public Module f->clear(user); if (f->ban) { - char* parameters[3]; + const char* parameters[3]; parameters[0] = dest->name; parameters[1] = "+b"; parameters[2] = user->MakeWildHost(); Srv->SendMode(parameters,3,user); + std::deque n; + /* Propogate the ban to other servers. + * We dont know what protocol we may be using, + * so this event is picked up by our protocol + * module and formed into a ban command that + * suits the protocol in use. + */ + n.push_back(dest->name); + n.push_back("+b"); + n.push_back(user->MakeWildHost()); + Event rmode((char *)&n, NULL, "send_mode"); + rmode.Send(); } Srv->KickUser(NULL, user, dest, "Channel flood triggered (mode +f)"); } @@ -220,9 +237,9 @@ class ModuleMsgFlood : public Module void OnChannelDelete(chanrec* chan) { - if (chan->GetExt("flood")) + floodsettings* f; + if (chan->GetExt("flood", f)) { - floodsettings *f = (floodsettings*)chan->GetExt("flood"); DELETE(f); chan->Shrink("flood"); }