summaryrefslogtreecommitdiff
path: root/src/modules/m_banredirect.cpp
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-15 21:09:42 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-15 21:09:42 +0000
commitbac6b35d70223e230f4a7f38663aed17be3ebdc2 (patch)
treec0d3e7e7e9118761ab9dc0244d24a77f66588de9 /src/modules/m_banredirect.cpp
parentb4480be526457da49dbcfeefd0d4071900a86f84 (diff)
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
Diffstat (limited to 'src/modules/m_banredirect.cpp')
-rw-r--r--src/modules/m_banredirect.cpp44
1 files 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<BanRedirectEntry> BanRedirectList;
+typedef std::deque<std::string> 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<unsigned>(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");
}