]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Nickname collision: third revisitation
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 19:02:32 +0000 (19:02 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 19:02:32 +0000 (19:02 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7909 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/treesocket1.cpp

index 3e7d5f2d4238757d72b0891741753074dbe73ffa..bb568a2c7cd862c79c6717c12d9e92ad7aa47baf 100644 (file)
@@ -969,14 +969,58 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
                 *  Under old protocol rules, we would have had to kill both clients.
                 *  Really, this sucks.
                 * These days, we have UID. And, so what we do is, force nick change client(s)
-                * involved to their UUID. No more kills. -- w00t
+                * involved according to timestamp rules.
+                *
+                * RULES:        
+                *  user@ip equal:       
+                *   Force nick change on OLDER timestamped client       
+                *  user@ip differ:      
+                *   Force nick change on NEWER timestamped client       
+                *  TS EQUAL:    
+                *   FNC both.   
+                *       
+                * Note that remote clients MUST be dealt with also to remove desyncs.   
+                *  XXX we don't do this yet.    
+                *       
+                * This stops abusive use of collisions, simplifies problems with loops, and so on.      
+                *   -- w00t
                 */
                Instance->Log(DEBUG,"*** Collision on %s", tempnick);
 
-               iter->second->ForceNickChange(iter->second->uuid);
-               this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" SVSNICK "+params[0]+" " + params[0]);
-               /* also, don't trample on the hash - use their UID as nick */
-               tempnick = params[0].c_str();
+               bool bChangeLocal = true;
+               bool bChangeRemote = true;
+
+               /* mmk. let's do this again. */
+               if (age == iter->second->age)
+               {
+                       /* equal. fuck them both! do nada, let the handler at the bottom figure this out. */
+               }
+               else
+               {
+                       /* fuck. now it gets complex. */
+
+                       /* first, let's see if ident@host matches. */
+                       bool SamePerson = strcmp(iter->second->ident, parv[5])
+                                       && !strcmp(iter->second->GetIP(), parv[7]);
+
+                       /*
+                        * if ident@ip is equal, and theirs is newer, or
+                        * ident@ip differ, and ours is newer
+                        */
+                       if((SamePerson && age < iter->second->age) ||
+                          (!SamePerson && age > iter->second->age))
+                       {
+                               /* remote needs to change */
+                               this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" SVSNICK "+params[0]+" " + params[0]);
+                               /* also, don't trample on the hash - use their UID as nick */
+                               tempnick = params[0].c_str();
+                       }
+                       else
+                       {
+                               /* ours needs to change */
+                               iter->second->ForceNickChange(iter->second->uuid);
+                       }
+               }
        }
 
        /* IMPORTANT NOTE: For remote users, we pass the UUID in the constructor. This automatically