]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/uid.cpp
Revert automated conversion by Special, as it (unfortunately) neglects some details...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / uid.cpp
index f68da8a1c79e862b49674bb8473d780df9fd3dce..ce7718324639d2d058f746d823a9180e30eab4a7 100644 (file)
@@ -29,7 +29,7 @@
 #include "m_spanningtree/resolvers.h"
 #include "m_spanningtree/handshaketimer.h"
 
-/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */
+/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h m_spanningtree/handshaketimer.h */
 
 bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &params)
 {
@@ -46,12 +46,8 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
 
        time_t age_t = ConvToInt(params[1]);
        time_t signon = ConvToInt(params[8]);
-       const char* tempnick = params[2].c_str();
        std::string empty;
 
-       /* XXX probably validate UID length too -- w00t */
-       cmd_validation valid[] = { {"Nickname", 2, NICKMAX}, {"Hostname", 3, 64}, {"Displayed hostname", 4, 64}, {"Ident", 5, IDENTMAX + 1}, {"GECOS", 9, MAXGECOS}, {"", 0, 0} };
-
        TreeServer* remoteserver = Utils->FindServer(source);
 
        if (!remoteserver)
@@ -67,31 +63,20 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
                return true;
        }
 
-       for (size_t x = 0; valid[x].length; ++x)
-       {
-               if (params[valid[x].param].length() > valid[x].length)
-               {
-                       this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (" + valid[x].item + " > " + ConvToStr(valid[x].length) + ")");
-                       return true;
-               }
-       }
-
-
        /* check for collision */
-       user_hash::iterator iter = this->Instance->Users->clientlist->find(tempnick);
+       user_hash::iterator iter = this->Instance->Users->clientlist->find(params[2]);
 
        if (iter != this->Instance->Users->clientlist->end())
        {
                /*
                 * Nick collision.
                 */
-               Instance->Logs->Log("m_spanningtree",DEBUG,"*** Collision on %s", tempnick);
-               int collide = this->DoCollision(iter->second, age_t, params[5].c_str(), params[7].c_str(), params[0].c_str());
+               Instance->Logs->Log("m_spanningtree",DEBUG,"*** Collision on %s", params[2].c_str());
+               int collide = this->DoCollision(iter->second, age_t, params[5], params[7], params[0]);
 
                if (collide == 2)
                {
                        /* remote client changed, make sure we change their nick for the hash too */
-                       tempnick = params[0].c_str();
                        params[2] = params[0];
                }
        }
@@ -109,14 +94,14 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
                SendError("Protocol violation - Duplicate UUID '" + params[0] + "' on introduction of new user");
                return false;
        }
-       (*(this->Instance->Users->clientlist))[tempnick] = _new;
+       (*(this->Instance->Users->clientlist))[params[2]] = _new;
        _new->SetFd(FD_MAGIC_NUMBER);
-       _new->nick.assign(tempnick, NICKMAX - 1);
-       strlcpy(_new->host, params[3].c_str(),64);
+       _new->nick.assign(params[2], 0, MAXBUF);
+       _new->host.assign(params[3], 0, 64);
        _new->dhost.assign(params[4], 0, 64);
        _new->server = this->Instance->FindServerNamePtr(remoteserver->GetName().c_str());
-       _new->ident.assign(params[5], 0, IDENTMAX + 1);
-       _new->fullname.assign(params[9], 0, MAXGECOS);
+       _new->ident.assign(params[5], 0, MAXBUF);
+       _new->fullname.assign(params[9], 0, MAXBUF);
        _new->registered = REG_ALL;
        _new->signon = signon;
        _new->age = age_t;
@@ -152,16 +137,17 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
        Instance->Users->AddGlobalClone(_new);
 
        bool dosend = true;
-       
+
        if ((this->Utils->quiet_bursts && remoteserver->bursting) || this->Instance->SilentULine(_new->server))
                dosend = false;
-       
+
        if (dosend)
-               this->Instance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]",_new->server,_new->nick.c_str(),_new->ident.c_str(),_new->host, _new->GetIPString(), _new->fullname.c_str());
+               this->Instance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]", _new->server, _new->nick.c_str(), _new->ident.c_str(), _new->host.c_str(), _new->GetIPString(), _new->fullname.c_str());
 
        params[9] = ":" + params[9];
        Utils->DoOneToAllButSender(source, "UID", params, source);
 
+       Instance->PI->Introduce(_new);
        FOREACH_MOD_I(Instance,I_OnPostConnect,OnPostConnect(_new));
 
        return true;