diff options
-rw-r--r-- | include/mode.h | 2 | ||||
-rw-r--r-- | include/modes/cmode_h.h | 1 | ||||
-rw-r--r-- | include/modes/cmode_k.h | 1 | ||||
-rw-r--r-- | include/modes/cmode_l.h | 1 | ||||
-rw-r--r-- | include/modes/cmode_o.h | 1 | ||||
-rw-r--r-- | include/modes/cmode_v.h | 1 | ||||
-rw-r--r-- | include/u_listmode.h | 17 | ||||
-rw-r--r-- | src/mode.cpp | 12 | ||||
-rw-r--r-- | src/modes/cmode_h.cpp | 17 | ||||
-rw-r--r-- | src/modes/cmode_k.cpp | 13 | ||||
-rw-r--r-- | src/modes/cmode_l.cpp | 12 | ||||
-rw-r--r-- | src/modes/cmode_o.cpp | 17 | ||||
-rw-r--r-- | src/modes/cmode_v.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_chanprotect.cpp | 51 | ||||
-rw-r--r-- | src/modules/m_joinflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 5 |
19 files changed, 202 insertions, 0 deletions
diff --git a/include/mode.h b/include/mode.h index 76389c6a4..ce1c085ac 100644 --- a/include/mode.h +++ b/include/mode.h @@ -181,6 +181,8 @@ class ModeHandler : public Extensible * @return True if the other side wins the merge, false if we win the merge for this mode. */ virtual bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel); + + virtual std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; /** diff --git a/include/modes/cmode_h.h b/include/modes/cmode_h.h index 1cec864d1..963052180 100644 --- a/include/modes/cmode_h.h +++ b/include/modes/cmode_h.h @@ -9,5 +9,6 @@ class ModeChannelHalfOp : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); std::string AddHalfOp(userrec *user,const char *dest,chanrec *chan,int status); std::string DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status); + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; diff --git a/include/modes/cmode_k.h b/include/modes/cmode_k.h index f855afee9..bcb67b945 100644 --- a/include/modes/cmode_k.h +++ b/include/modes/cmode_k.h @@ -5,4 +5,5 @@ class ModeChannelKey : public ModeHandler public: ModeChannelKey(); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; diff --git a/include/modes/cmode_l.h b/include/modes/cmode_l.h index d13bd0459..3eb332c7f 100644 --- a/include/modes/cmode_l.h +++ b/include/modes/cmode_l.h @@ -5,4 +5,5 @@ class ModeChannelLimit : public ModeHandler public: ModeChannelLimit(); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; diff --git a/include/modes/cmode_o.h b/include/modes/cmode_o.h index cf223b97f..ad34f501c 100644 --- a/include/modes/cmode_o.h +++ b/include/modes/cmode_o.h @@ -9,5 +9,6 @@ class ModeChannelOp : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); std::string AddOp(userrec *user,const char *dest,chanrec *chan,int status); std::string DelOp(userrec *user,const char *dest,chanrec *chan,int status); + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; diff --git a/include/modes/cmode_v.h b/include/modes/cmode_v.h index 8cf1ad994..f61f183c5 100644 --- a/include/modes/cmode_v.h +++ b/include/modes/cmode_v.h @@ -9,5 +9,6 @@ class ModeChannelVoice : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); std::string AddVoice(userrec *user,const char *dest,chanrec *chan,int status); std::string DelVoice(userrec *user,const char *dest,chanrec *chan,int status); + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter); }; diff --git a/include/u_listmode.h b/include/u_listmode.h index 036319b9e..c7568897f 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -64,6 +64,23 @@ class ListModeBase : public ModeHandler infokey = "exceptionbase_mode_" + std::string(1, mode) + "_list"; } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + modelist* el; + channel->GetExt(infokey, el); + if (el) + { + for (modelist::iterator it = el->begin(); it != el->end(); it++) + { + if(parameter == it->mask) + { + return std::make_pair(true, parameter); + } + } + } + return std::make_pair(false, parameter); + } + virtual void DisplayList(userrec* user, chanrec* channel) { modelist* el; diff --git a/src/mode.cpp b/src/mode.cpp index 86b0024c0..56d1f398f 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -113,6 +113,18 @@ ModeAction ModeHandler::OnModeChange(userrec* source, userrec* dest, chanrec* ch return MODEACTION_DENY; } +std::pair<bool,std::string> ModeHandler::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + if (dest) + { + return std::make_pair(dest->IsModeSet(this->mode), ""); + } + else + { + return std::make_pair(channel->IsModeSet(this->mode), ""); + } +} + void ModeHandler::DisplayList(userrec* user, chanrec* channel) { } diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 2c96b4224..4a2c5fa69 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -26,6 +26,23 @@ ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_C { } +std::pair<bool,std::string> ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + userrec* x = Find(parameter); + if (x) + { + if (cstatus(x, channel) == STATUS_HOP) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + return std::make_pair(false, parameter); +} + ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { /* If halfops are not enabled in the conf, we don't execute diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index 9e69ed13b..2f06ba55c 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -8,6 +8,19 @@ ModeChannelKey::ModeChannelKey() : ModeHandler('k', 1, 1, false, MODETYPE_CHANNE { } +std::pair<bool,std::string> ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + if (channel->modes[CM_KEY]) + { + return std::make_pair(true, channel->key); + } + else + { + return std::make_pair(false, parameter); + } +} + + ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { if (channel->modes[CM_KEY] != adding) diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp index 10ff3135a..a5fa5329b 100644 --- a/src/modes/cmode_l.cpp +++ b/src/modes/cmode_l.cpp @@ -8,6 +8,18 @@ ModeChannelLimit::ModeChannelLimit() : ModeHandler('l', 1, 0, false, MODETYPE_CH { } +std::pair<bool,std::string> ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + if (channel->limit) + { + return std::make_pair(true, ConvToStr(channel->limit)); + } + else + { + return std::make_pair(false, parameter); + } +} + ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index dfa3a1a10..853bb86e5 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -26,6 +26,23 @@ ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL, { } +std::pair<bool,std::string> ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + userrec* x = Find(parameter); + if (x) + { + if (cstatus(x, channel) == STATUS_OP) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + return std::make_pair(false, parameter); +} + ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { int status = cstatus(source, channel); diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index 87d391109..a72e6bf18 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -26,6 +26,23 @@ ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHA { } +std::pair<bool,std::string> ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + userrec* x = Find(parameter); + if (x) + { + if (cstatus(x, channel) == STATUS_VOICE) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + return std::make_pair(false, parameter); +} + ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { int status = cstatus(source, channel); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 208dc8362..675e95e96 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -31,6 +31,32 @@ class ChanFounder : public ModeHandler public: ChanFounder(Server* s) : ModeHandler('q', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + userrec* x = Find(parameter); + if (x) + { + if (!channel->HasUser(x)) + { + return std::make_pair(false, parameter); + } + else + { + std::string founder = "cm_founder_"+std::string(channel->name); + if (x->GetExt(founder,dummyptr)) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + } + return std::make_pair(false, parameter); + } + + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { userrec* theuser = Srv->FindNick(parameter); @@ -109,6 +135,31 @@ class ChanProtect : public ModeHandler public: ChanProtect(Server* s) : ModeHandler('a', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + userrec* x = Find(parameter); + if (x) + { + if (!channel->HasUser(x)) + { + return std::make_pair(false, parameter); + } + else + { + std::string founder = "cm_protect_"+std::string(channel->name); + if (x->GetExt(founder,dummyptr)) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + } + return std::make_pair(false, parameter); + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { userrec* theuser = Srv->FindNick(parameter); diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 33b6b8b61..0d038b48d 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -99,6 +99,15 @@ class JoinFlood : public ModeHandler public: JoinFlood() : ModeHandler('j', 1, 0, false, MODETYPE_CHANNEL, false) { } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + joinfloodsettings* x; + if (channel->GetExt("joinflood",x)) + return std::make_pair(true, ConvToStr(x->joins)+":"+ConvToStr(x->secs)); + else + return std::make_pair(false, parameter); + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { joinfloodsettings* dummy; diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 80e1fb8d0..97b766e36 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -25,6 +25,14 @@ class KickRejoin : public ModeHandler public: KickRejoin() : ModeHandler('J', 1, 0, false, MODETYPE_CHANNEL, false) { } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + if (channel->IsModeSet('J')) + return std::make_pair(true, channel->GetModeParameter('J')); + else + return std::make_pair(false, parameter); + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { if (!adding) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 52fed00f0..7efe8e8ec 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -88,6 +88,15 @@ class MsgFlood : public ModeHandler public: MsgFlood() : ModeHandler('f', 1, 0, false, MODETYPE_CHANNEL, false) { } + std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) + { + floodsettings* x; + if (channel->GetExt("flood",x)) + return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs)); + else + return std::make_pair(false, parameter); + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { floodsettings *f; diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 6e239cb08..b289c1a0e 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -30,6 +30,14 @@ class Redirect : public ModeHandler 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 ¶meter) + { + if (channel->IsModeSet('L')) + return std::make_pair(true, channel->GetModeParameter('L')); + else + return std::make_pair(false, parameter); + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index f14cc69de..e1834721d 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -945,6 +945,11 @@ class TreeSocket : public InspSocket } } DoOneToOne(source,"FMODE",params,source); + /* XXX: We should check that we arent bouncing anything thats already set at this end. + * If we are, bounce +ourmode. + * + * E.G. They send +l 50, we have +l 10 set. rather than bounce -l 50, we bounce +l 10. + */ log(DEBUG,"Mode bounced, our TS less than theirs"); } else |