From ac7e37c8542159fa0efa48b43c9ab346762f1638 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 26 Jul 2014 16:19:18 +0200 Subject: [PATCH] m_spanningtree Set the TS of the uuid nick to the same value on collision --- src/modules/m_spanningtree/commands.h | 4 ++++ src/modules/m_spanningtree/nick.cpp | 4 +++- src/modules/m_spanningtree/nickcollide.cpp | 3 ++- src/modules/m_spanningtree/save.cpp | 2 +- src/modules/m_spanningtree/uid.cpp | 4 +++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index 3047e7e60..c3ef2676c 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -295,6 +295,10 @@ class CommandPush : public ServerCommand class CommandSave : public ServerCommand { public: + /** Timestamp of the uuid nick of all users who collided and got their nick changed to uuid + */ + static const time_t SavedTimestamp = 100; + CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { } CmdResult Handle(User* user, std::vector& parameters); }; diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp index 43b713e14..9496c2874 100644 --- a/src/modules/m_spanningtree/nick.cpp +++ b/src/modules/m_spanningtree/nick.cpp @@ -36,7 +36,7 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector& throw ProtocolException("Attempted to change nick to an invalid or non-matching UUID"); // Timestamp of the new nick - const time_t newts = ServerCommand::ExtractTS(params[1]); + time_t newts = ServerCommand::ExtractTS(params[1]); /* * On nick messages, check that the nick doesn't already exist here. @@ -53,6 +53,8 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector& // Remote client lost, or both lost, rewrite this nick change as a change to uuid before // calling ChangeNick() and forwarding the message params[0] = user->uuid; + params[1] = ConvToStr(CommandSave::SavedTimestamp); + newts = CommandSave::SavedTimestamp; } } diff --git a/src/modules/m_spanningtree/nickcollide.cpp b/src/modules/m_spanningtree/nickcollide.cpp index a46e103e4..3401041aa 100644 --- a/src/modules/m_spanningtree/nickcollide.cpp +++ b/src/modules/m_spanningtree/nickcollide.cpp @@ -24,6 +24,7 @@ #include "treeserver.h" #include "utils.h" #include "commandbuilder.h" +#include "commands.h" /* * Yes, this function looks a little ugly. @@ -107,7 +108,7 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo params.push_back(ConvToStr(u->age)); params.Broadcast(); - u->ChangeNick(u->uuid); + u->ChangeNick(u->uuid, CommandSave::SavedTimestamp); } if (bChangeRemote) { diff --git a/src/modules/m_spanningtree/save.cpp b/src/modules/m_spanningtree/save.cpp index aac5795af..a382b8d66 100644 --- a/src/modules/m_spanningtree/save.cpp +++ b/src/modules/m_spanningtree/save.cpp @@ -35,7 +35,7 @@ CmdResult CommandSave::Handle(User* user, std::vector& params) time_t ts = atol(params[1].c_str()); if (u->age == ts) - u->ChangeNick(u->uuid); + u->ChangeNick(u->uuid, SavedTimestamp); return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index c7a98b2f4..958718202 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -65,7 +65,9 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector