]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Set the TS of the uuid nick to the same value on collision
authorAttila Molnar <attilamolnar@hush.com>
Sat, 26 Jul 2014 14:19:18 +0000 (16:19 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Sat, 26 Jul 2014 14:19:18 +0000 (16:19 +0200)
src/modules/m_spanningtree/commands.h
src/modules/m_spanningtree/nick.cpp
src/modules/m_spanningtree/nickcollide.cpp
src/modules/m_spanningtree/save.cpp
src/modules/m_spanningtree/uid.cpp

index 3047e7e60960ca99089af45a2d6949af416c5e63..c3ef2676c0a620e0f82b7a1128ca81020d2d6604 100644 (file)
@@ -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<std::string>& parameters);
 };
index 43b713e14d0e96dfd8057237147f25dfb50332db..9496c2874015808afe94a4486553f26b22e6d4fc 100644 (file)
@@ -36,7 +36,7 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>&
                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<std::string>&
                        // 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;
                }
        }
 
index a46e103e468ad4d9ce1b32d110907cf842570cac..3401041aa3a43ac3d17c946759bece1950644df3 100644 (file)
@@ -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)
        {
index aac5795af558b7ad5f6b803efab3bd25032743d0..a382b8d66807cf9880a01f8b30b39f7049106c14 100644 (file)
@@ -35,7 +35,7 @@ CmdResult CommandSave::Handle(User* user, std::vector<std::string>& 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;
 }
index c7a98b2f46504dabe4c4e55cf921a6a9a040b030..958718202174fee6027f87da9675cb6cec029860 100644 (file)
@@ -65,7 +65,9 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
                if (they_change)
                {
                        // The client being introduced needs to change nick to uuid, change the nick in the message before
-                       // processing/forwarding it.
+                       // processing/forwarding it. Also change the nick TS to CommandSave::SavedTimestamp.
+                       age_t = CommandSave::SavedTimestamp;
+                       params[1] = ConvToStr(CommandSave::SavedTimestamp);
                        params[2] = params[0];
                }
        }