summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h6
-rw-r--r--include/modes/cmode_k.h1
-rw-r--r--include/modes/cmode_l.h2
-rw-r--r--src/mode.cpp13
-rw-r--r--src/modes/cmode_k.cpp6
-rw-r--r--src/modes/cmode_l.cpp2
-rw-r--r--src/modules/m_joinflood.cpp6
-rw-r--r--src/modules/m_kicknorejoin.cpp6
-rw-r--r--src/modules/m_messageflood.cpp6
-rw-r--r--src/modules/m_nickflood.cpp6
-rw-r--r--src/modules/m_spanningtree/fmode.cpp2
11 files changed, 15 insertions, 41 deletions
diff --git a/include/mode.h b/include/mode.h
index 3e658e206..cbb9b9e94 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -266,14 +266,12 @@ class CoreExport ModeHandler : public Extensible
* override this function and use it to return true or false. The default implementation just returns true if
* theirs < ours. This will only be called for non-listmodes with parameters, when adding the mode and where
* theirs == ours (therefore the default implementation will always return false).
- * @param theirs The timestamp of the remote side
- * @param ours The timestamp of the local side
* @param their_param Their parameter if the mode has a parameter
* @param our_param Our parameter if the mode has a parameter
* @param channel The channel we are checking against
* @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, Channel* channel);
+ virtual bool CheckTimeStamp(std::string &their_param, const std::string &our_param, Channel* channel);
/**
* When a remote server needs to bounce a set of modes, it will call this method for every mode
@@ -536,7 +534,7 @@ class CoreExport ModeParser : public classbase
* and *user->server == NULL.
* @param servermode True if a server is setting the mode.
*/
- void Process(const std::vector<std::string>& parameters, User *user, bool servermode);
+ void Process(const std::vector<std::string>& parameters, User *user, bool servermode, bool merge = false);
/** Find the mode handler for a given mode and type.
* @param modeletter mode letter to search for
diff --git a/include/modes/cmode_k.h b/include/modes/cmode_k.h
index 72dc125e8..671143be6 100644
--- a/include/modes/cmode_k.h
+++ b/include/modes/cmode_k.h
@@ -23,7 +23,6 @@ class ModeChannelKey : public ModeHandler
ModeChannelKey(InspIRCd* Instance);
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode);
ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter);
- bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel);
void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
void RemoveMode(User* user, irc::modestacker* stack = NULL);
};
diff --git a/include/modes/cmode_l.h b/include/modes/cmode_l.h
index 0dfe779e0..eba711095 100644
--- a/include/modes/cmode_l.h
+++ b/include/modes/cmode_l.h
@@ -23,5 +23,5 @@ class ModeChannelLimit : public ModeHandler
ModeChannelLimit(InspIRCd* Instance);
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode);
ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter);
- bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel);
+ bool CheckTimeStamp(std::string &their_param, const std::string &our_param, Channel* channel);
};
diff --git a/src/mode.cpp b/src/mode.cpp
index c8fecafa5..1986ed2bb 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -155,9 +155,9 @@ void ModeHandler::OnParameterMissing(User* user, User* dest, Channel* channel)
{
}
-bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&, const std::string&, Channel*)
+bool ModeHandler::CheckTimeStamp(std::string& theirs, const std::string& ours, Channel*)
{
- return (ours < theirs);
+ return (theirs < ours);
}
SimpleUserModeHandler::SimpleUserModeHandler(InspIRCd* Instance, char modeletter) : ModeHandler(Instance, modeletter, 0, 0, false, MODETYPE_USER, false)
@@ -471,7 +471,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
return MODEACTION_ALLOW;
}
-void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool servermode)
+void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool servermode, bool merge)
{
std::string target = parameters[0];
Channel* targetchannel = ServerInstance->FindChan(target);
@@ -562,6 +562,13 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
/* Make sure the user isn't trying to slip in an invalid parameter */
if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
continue;
+ if (merge && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
+ {
+ std::string ours = targetchannel->GetModeParameter(modechar);
+ if (!mh->CheckTimeStamp(parameter, ours, targetchannel))
+ /* we won the mode merge, don't apply this mode */
+ continue;
+ }
}
ModeAction ma = TryMode(user, targetuser, targetchannel, adding, modechar, parameter, servermode, SkipAccessChecks);
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index 59d401ebb..b270966da 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -61,12 +61,6 @@ void ModeChannelKey::RemoveMode(User*, irc::modestacker* stack)
{
}
-bool ModeChannelKey::CheckTimeStamp(time_t, time_t, const std::string &their_param, const std::string &our_param, Channel*)
-{
- /* When TS is equal, the alphabetically later channel key wins */
- return (their_param < our_param);
-}
-
ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding, bool servermode)
{
bool exists = channel->IsModeSet('k');
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index f20256e87..d60c9b3a7 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -34,7 +34,7 @@ ModePair ModeChannelLimit::ModeSet(User*, User*, Channel* channel, const std::st
}
}
-bool ModeChannelLimit::CheckTimeStamp(time_t, time_t, const std::string &their_param, const std::string &our_param, Channel*)
+bool ModeChannelLimit::CheckTimeStamp(std::string &their_param, const std::string &our_param, Channel*)
{
/* When TS is equal, the higher channel limit wins */
return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 1af3ebe1d..b3abeaf61 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -97,12 +97,6 @@ class JoinFlood : 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, Channel* channel)
- {
- /* When TS is equal, the alphabetically later one wins */
- return (their_param < our_param);
- }
-
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
{
joinfloodsettings* dummy;
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index 678321033..835f73443 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -40,12 +40,6 @@ class KickRejoin : 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, Channel* channel)
- {
- /* When TS is equal, the alphabetically later one wins */
- return (their_param < our_param);
- }
-
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
{
if (!adding)
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 75f88232b..087d8e47e 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -87,12 +87,6 @@ class MsgFlood : 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, Channel* channel)
- {
- /* When TS is equal, the alphabetically later one wins */
- return (their_param < our_param);
- }
-
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
{
floodsettings *f;
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index 1ed30f767..edb5aff3e 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -101,12 +101,6 @@ class NickFlood : 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, Channel* channel)
- {
- /* When TS is equal, the alphabetically later one wins */
- return (their_param < our_param);
- }
-
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
{
nickfloodsettings* dummy;
diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp
index 3421f8045..0328ad40b 100644
--- a/src/modules/m_spanningtree/fmode.cpp
+++ b/src/modules/m_spanningtree/fmode.cpp
@@ -97,7 +97,7 @@ bool TreeSocket::ForceMode(const std::string &source, parameterlist &params)
*/
if (TS <= ourTS)
{
- ServerInstance->Modes->Process(modelist, who, (who == Utils->ServerUser));
+ ServerInstance->Modes->Process(modelist, who, (who == Utils->ServerUser), true);
/* HOT POTATO! PASS IT ON! */
Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);