]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_redirect.cpp
Now with added ANGRY MONKEYS.
[user/henk/code/inspircd.git] / src / modules / m_redirect.cpp
index b289c1a0e34ebf5dc59ca407fec714669a476739..8d2d152c204d7c282c3a2cb96bb0523a83e8cb83 100644 (file)
@@ -24,13 +24,15 @@ using namespace std;
 
 /* $ModDesc: Provides channel mode +L (limit redirection) */
 
+extern chan_hash chanlist;
+
 class Redirect : public ModeHandler
 {
        Server* Srv;
  public:
        Redirect(Server* s) : ModeHandler('L', 1, 0, false, MODETYPE_CHANNEL, false), Srv(s) { }
 
-        std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+        ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
         {
                 if (channel->IsModeSet('L'))
                         return std::make_pair(true, channel->GetModeParameter('L'));
@@ -38,6 +40,12 @@ class Redirect : 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)
+       {
+               /* When TS is equal, the alphabetically later one wins */
+               return (their_param < our_param);
+        }
+       
        ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
        {
                if (adding)
@@ -57,10 +65,21 @@ class Redirect : public ModeHandler
                                /* Fix by brain: Dont let a channel be linked to *itself* either */
                                if ((c == channel) || (c->IsModeSet('L')))
                                {
-                                       WriteServ(source->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",source->nick,parameter.c_str());
+                                       WriteServ(source->fd,"690 %s :Circular or chained +L to %s not allowed (Channel already has +L). Pack of wild dogs has been unleashed.",source->nick,parameter.c_str());
                                        parameter = "";
                                        return MODEACTION_DENY;
                                }
+                               else
+                               {
+                                       for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
+                                       {
+                                               if ((i->second != channel) && (i->second->IsModeSet('L')) && (irc::string(i->second->GetModeParameter('L').c_str()) == irc::string(channel->name)))
+                                               {
+                                                       WriteServ(source->fd,"690 %s :Circular or chained +L to %s not allowed (Already forwarded here from %s). Angry monkeys dispatched.",source->nick,parameter.c_str(),i->second->name);
+                                                       return MODEACTION_DENY;
+                                               }
+                                       }
+                               }
                        }
 
                        channel->SetMode('L', true);