]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add SAVE s2s protocol command
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 15:37:16 +0000 (15:37 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 15:37:16 +0000 (15:37 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11660 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/nickcollide.cpp
src/modules/m_spanningtree/save.cpp [new file with mode: 0644]
src/modules/m_spanningtree/svsnick.cpp
src/modules/m_spanningtree/treesocket.h
src/modules/m_spanningtree/treesocket2.cpp

index ba83b62db3e59b3916526ea886397c970a27af6a..a723c114f082e2af24d44028b2b83c8a28d8710a 100644 (file)
@@ -25,7 +25,7 @@
  * Yes, this function looks a little ugly.
  * However, in some circumstances we may not have a User, so we need to do things this way.
  * Returns 1 if colliding local client, 2 if colliding remote, 3 if colliding both.
- * Sends SVSNICKs as appropriate and forces nickchanges too.
+ * Sends SAVEs as appropriate and forces nickchanges too.
  */
 int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remoteident, const std::string &remoteip, const std::string &remoteuid)
 {
@@ -86,11 +86,11 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei
 
        /*
         * Cheat a little here. Instead of a dedicated command to change UID,
-        * use SVSNICK and accept the losing client with its UID (as we know the SVSNICK will
+        * use SAVE and accept the losing client with its UID (as we know the SAVE will
         * not fail under any circumstances -- UIDs are netwide exclusive).
         *
         * This means that each side of a collide will generate one extra NICK back to where
-        * they have just linked (and where it got the SVSNICK from), however, it will
+        * they have just linked (and where it got the SAVE from), however, it will
         * be dropped harmlessly as it will come in as :928AAAB NICK 928AAAB, and we already
         * have 928AAAB's nick set to that.
         *   -- w00t
@@ -100,13 +100,12 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei
        {
                /*
                 * Local-side nick needs to change. Just in case we are hub, and
-                * this "local" nick is actually behind us, send an SVSNICK out.
+                * this "local" nick is actually behind us, send an SAVE out.
                 */
                parameterlist params;
                params.push_back(u->uuid);
-               params.push_back(u->uuid);
                params.push_back(ConvToStr(u->age));
-               Utils->DoOneToMany(ServerInstance->Config->GetSID(),"SVSNICK",params);
+               Utils->DoOneToMany(ServerInstance->Config->GetSID(),"SAVE",params);
 
                u->ForceNickChange(u->uuid.c_str());
 
@@ -119,9 +118,9 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei
                /*
                 * remote side needs to change. If this happens, we will modify
                 * the UID or halt the propagation of the nick change command,
-                * so other servers don't need to see the SVSNICK
+                * so other servers don't need to see the SAVE
                 */
-               WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" SVSNICK "+remoteuid+" " + remoteuid + " " + ConvToStr(remotets));
+               WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" SAVE "+remoteuid+" "+ ConvToStr(remotets));
 
                if (remote)
                {
diff --git a/src/modules/m_spanningtree/save.cpp b/src/modules/m_spanningtree/save.cpp
new file mode 100644 (file)
index 0000000..25f8112
--- /dev/null
@@ -0,0 +1,52 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "commands/cmd_whois.h"
+#include "commands/cmd_stats.h"
+#include "socket.h"
+#include "xline.h"
+#include "../transport.h"
+#include "socketengine.h"
+
+#include "main.h"
+#include "utils.h"
+#include "treeserver.h"
+#include "treesocket.h"
+
+/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
+
+/**
+ * SAVE command - force nick change to UID on timestamp match
+ */
+bool TreeSocket::ForceNick(const std::string &prefix, parameterlist &params)
+{
+       if (params.size() < 2)
+               return true;
+
+       User* u = this->ServerInstance->FindNick(params[0]);
+       time_t ts = atol(params[1].c_str());
+
+       if (u && u->age == ts)
+       {
+               Utils->DoOneToAllButSender(prefix,"SAVE",params,prefix);
+
+               if (!u->ForceNickChange(u->uuid.c_str()))
+               {
+                       this->ServerInstance->Users->QuitUser(u, "Nickname collision");
+               }
+       }
+
+       return true;
+}
+
index fe08b9ee2d082622a3f7cc0f75a4b9ec5ac55429..48e0c638a765f0dda19f0dd5b648314de780151e 100644 (file)
@@ -29,7 +29,7 @@
 /** Because Andy insists that services-compatible servers must
  * implement SVSNICK and SVSJOIN, that's exactly what we do :p
  */
-bool TreeSocket::ForceNick(const std::string &prefix, parameterlist &params)
+bool TreeSocket::SVSNick(const std::string &prefix, parameterlist &params)
 {
        if (params.size() < 3)
                return true;
index e9830f9ad54712f3f67446d25c9f9891a5399300..390978791065bd68f4fe1bc5f28aada7e82618c0 100644 (file)
@@ -294,6 +294,9 @@ class TreeSocket : public BufferedSocket
        /** Because Andy insists that services-compatible servers must
         * implement SVSNICK and SVSJOIN, that's exactly what we do :p
         */
+       bool SVSNick(const std::string &prefix, parameterlist &params);
+
+       /** SAVE to resolve nick collisions without killing */
        bool ForceNick(const std::string &prefix, parameterlist &params);
 
        /** PRIVMSG or NOTICE with server origin ONLY
index 085f141171d50efef76e64887c1b5c0dc0b2e4b0..e76b985687b057202e198f93ed6b41c4196e49b8 100644 (file)
@@ -412,6 +412,10 @@ bool TreeSocket::ProcessLine(std::string &line)
                                return this->DelLine(prefix,params);
                        }
                        else if (command == "SVSNICK")
+                       {
+                               return this->SVSNick(prefix,params);
+                       }
+                       else if (command == "SAVE")
                        {
                                return this->ForceNick(prefix,params);
                        }