From bac6b35d70223e230f4a7f38663aed17be3ebdc2 Mon Sep 17 00:00:00 2001 From: om Date: Mon, 15 Jan 2007 21:09:42 +0000 Subject: [PATCH] Convert all redirecting bans to non-redirecting ones when the module unloads. Stop the module allowing bans which will immediately be blocked by the core for exceeding the ban limit. Fix something else, I think, I forget what it was... git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6348 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_banredirect.cpp | 44 ++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 269c22db4..a185b8c48 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -32,6 +32,7 @@ class BanRedirectEntry }; typedef std::vector BanRedirectList; +typedef std::deque StringDeque; class BanRedirect : public ModeWatcher { @@ -61,7 +62,14 @@ class BanRedirect : public ModeWatcher std::string mask[4]; enum { NICK, IDENT, HOST, CHAN } current = NICK; std::string::iterator start_pos = param.begin(); + long maxbans = channel->GetMaxBans(); + if(channel->bans.size() > static_cast(maxbans)) + { + source->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)", source->nick, channel->name, channel->name, maxbans); + return false; + } + for(std::string::iterator curr = start_pos; curr != param.end(); curr++) { switch(*curr) @@ -147,13 +155,13 @@ class BanRedirect : public ModeWatcher channel->Shrink("banredirects"); } - /* Append the channel so the default +b handler can remove the entry too */ - param.append(mask[CHAN]); - break; } } } + + /* Append the channel so the default +b handler can remove the entry too */ + param.append(mask[CHAN]); } } } @@ -205,6 +213,36 @@ class ModuleBanRedirect : public Module if(chan->GetExt("banredirects", redirects)) { + irc::modestacker modestack(false); + StringDeque stackresult; + const char* mode_junk[MAXMODES+1]; + userrec* myhorriblefakeuser = new userrec(Srv); + myhorriblefakeuser->SetFd(FD_MAGIC_NUMBER); + + mode_junk[0] = chan->name; + + for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++) + { + modestack.Push('b', i->targetchan.insert(0, i->banmask)); + } + + for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++) + { + modestack.PushPlus(); + modestack.Push('b', i->banmask); + } + + while(modestack.GetStackedLine(stackresult)) + { + for(StringDeque::size_type i = 0; i < stackresult.size(); i++) + { + mode_junk[i+1] = stackresult[i].c_str(); + } + + Srv->SendMode(mode_junk, stackresult.size() + 1, myhorriblefakeuser); + } + + delete myhorriblefakeuser; delete redirects; chan->Shrink("banredirects"); } -- 2.39.5