summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2013-12-15 13:10:33 +0100
committerAttila Molnar <attilamolnar@hush.com>2013-12-15 13:10:33 +0100
commit24fc55bbfd367bf2ef68230173ffe1cb58f744fa (patch)
tree087ca6e8040673b95ae1ab92e568a55ba453166e /src/modules/m_spanningtree
parent4b9d53b05207cca559f24e098d50c43811fcf176 (diff)
m_spanningtree Fix nick TS desync on SVSNICK
Don't accept invalid timestamps
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/main.cpp4
-rw-r--r--src/modules/m_spanningtree/main.h5
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp15
3 files changed, 21 insertions, 3 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 37cd8c9a2..d702ab4a2 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -38,6 +38,7 @@
#include "protocolinterface.h"
ModuleSpanningTree::ModuleSpanningTree()
+ : KeepNickTS(false)
{
Utils = new SpanningTreeUtilities(this);
commands = new SpanningTreeCommands(this);
@@ -704,11 +705,12 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick)
/** IMPORTANT: We don't update the TS if the oldnick is just a case change of the newnick!
*/
- if (irc::string(user->nick.c_str()) != assign(oldnick))
+ if ((irc::string(user->nick.c_str()) != assign(oldnick)) && (!this->KeepNickTS))
user->age = ServerInstance->Time();
params.push_back(ConvToStr(user->age));
Utils->DoOneToMany(user->uuid,"NICK",params);
+ this->KeepNickTS = false;
}
else if (!loopCall && user->nick == user->uuid)
{
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index ae6e2e602..eb17c4195 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -63,6 +63,11 @@ class ModuleSpanningTree : public Module
*/
bool loopCall;
+ /** If true OnUserPostNick() won't update the nick TS before sending the NICK,
+ * used when handling SVSNICK.
+ */
+ bool KeepNickTS;
+
/** Constructor
*/
ModuleSpanningTree();
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index 79dc27ea3..59973202d 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -34,17 +34,28 @@ CmdResult CommandSVSNick::Handle(const std::vector<std::string>& parameters, Use
if (isdigit(nick[0]))
nick = u->uuid;
+ // Don't update the TS if the nick is exactly the same
+ if (u->nick == nick)
+ return CMD_FAILURE;
+
+ time_t NickTS = ConvToInt(parameters[2]);
+ if (NickTS <= 0)
+ return CMD_FAILURE;
+
+ ModuleSpanningTree* st = (ModuleSpanningTree*)(Module*)creator;
+ st->KeepNickTS = true;
+ u->age = NickTS;
+
if (!u->ForceNickChange(nick.c_str()))
{
/* buh. UID them */
if (!u->ForceNickChange(u->uuid.c_str()))
{
ServerInstance->Users->QuitUser(u, "Nickname collision");
- return CMD_SUCCESS;
}
}
- u->age = atoi(parameters[2].c_str());
+ st->KeepNickTS = false;
}
return CMD_SUCCESS;