diff options
-rw-r--r-- | include/channels.h | 2 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_joinflood.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 36 |
6 files changed, 46 insertions, 2 deletions
diff --git a/include/channels.h b/include/channels.h index ade284709..17e47c88d 100644 --- a/include/channels.h +++ b/include/channels.h @@ -173,7 +173,7 @@ class chanrec : public Extensible * @param parameter The parameter string to associate with this mode character * @param mode_on True if you want to set the mode or false if you want to remove it */ - void SetModeParam(char mode,char* parameter,bool mode_on); + void SetModeParam(char mode,const char* parameter,bool mode_on); /** Returns true if a mode is set on a channel * @param mode The mode character you wish to query diff --git a/src/channels.cpp b/src/channels.cpp index a25b2927c..632e198e5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -65,7 +65,7 @@ void chanrec::SetMode(char mode,bool mode_on) } -void chanrec::SetModeParam(char mode,char* parameter,bool mode_on) +void chanrec::SetModeParam(char mode,const char* parameter,bool mode_on) { log(DEBUG,"SetModeParam called"); diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 6cc54db68..43b45be69 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -136,6 +136,8 @@ class JoinFlood : public ModeHandler { joinfloodsettings *f = new joinfloodsettings(nsecs,njoins); channel->Extend("joinflood",(char*)f); + channel->SetMode('j', true); + channel->SetModeParam('j', parameter.c_str(), true); return MODEACTION_ALLOW; } } @@ -153,6 +155,7 @@ class JoinFlood : public ModeHandler joinfloodsettings *f = (joinfloodsettings*)channel->GetExt("joinflood"); DELETE(f); channel->Shrink("joinflood"); + channel->SetMode('j', false); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 770b79db3..1c5333def 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -40,6 +40,8 @@ class KickRejoin : public ModeHandler } if ((!adding) || (atoi(parameter.c_str()) > 0)) { + channel->SetModeParam('J', parameter.c_str(), adding); + channel->SetMode('J', adding); return MODEACTION_ALLOW; } else diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 2cbecfdac..bcec8248b 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -135,6 +135,8 @@ class MsgFlood : public ModeHandler { floodsettings *f = new floodsettings(ban,nsecs,nlines); channel->Extend("flood",(char*)f); + channel->SetMode('f', true); + channel->SetModeParam('f', parameter.c_str(), true); return MODEACTION_ALLOW; } } @@ -153,6 +155,7 @@ class MsgFlood : public ModeHandler floodsettings *f = (floodsettings*)channel->GetExt("flood"); DELETE(f); channel->Shrink("flood"); + channel->SetMode('f', false); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 799eb25de..e3da4622f 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -24,6 +24,42 @@ using namespace std; /* $ModDesc: Provides channel mode +L (limit redirection) */ +class Redirect : public ModeHandler +{ + public: + Redirect() : ModeHandler('L', 1, 0, false, MODETYPE_CHANNEL, false) { } + + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + { + if (adding) + { + chanrec* c = NULL; + + if (!IsValidChannelName(parameter.c_str())) + { + WriteServ(user->fd,"403 %s %s :Invalid channel name",user->nick, parameter.c_str()); + parameter = ""; + return MODEACTION_DENY; + } + + c = Srv->FindChannel(parameter); + if (c) + { + /* Fix by brain: Dont let a channel be linked to *itself* either */ + if ((c == target) || (c->IsModeSet('L'))) + { + WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,parameter.c_str()); + parameter = ""; + return MODEACTION_DENY; + } + } + + c->SetMode('L', true); + c->SetModeParam('L', parameter); + return MODEACTION_ALLOW; + } + } +}; class ModuleRedirect : public Module { |