]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/uid.cpp
Make the maximum hostname length configurable in the config.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / uid.cpp
index da75eebec27f3b78244e28a9a8726d405cc9ec24..0d96167b9c2e8850e03a90fc6c5db381982a1493 100644 (file)
@@ -25,7 +25,7 @@
 #include "utils.h"
 #include "treeserver.h"
 
-CmdResult CommandUID::Handle(User* serversrc, std::vector<std::string>& params)
+CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::string>& params)
 {
        /** Do we have enough parameters:
         *      0    1    2    3    4    5        6        7     8        9       (n-1)
@@ -36,12 +36,8 @@ CmdResult CommandUID::Handle(User* serversrc, std::vector<std::string>& params)
        std::string empty;
        const std::string& modestr = params[8];
 
-       TreeServer* remoteserver = Utils->FindServer(serversrc->server);
-
-       if (!remoteserver)
-               return CMD_INVALID;
        /* Is this a valid UID, and not misrouted? */
-       if (params[0].length() != 9 || params[0].substr(0,3) != serversrc->uuid)
+       if (params[0].length() != UIDGenerator::UUID_LENGTH || params[0].substr(0, 3) != remoteserver->GetID())
                return CMD_INVALID;
        /* Check parameters for validity before introducing the client, discovered by dmb */
        if (!age_t)
@@ -75,7 +71,7 @@ CmdResult CommandUID::Handle(User* serversrc, std::vector<std::string>& params)
        User* _new = NULL;
        try
        {
-               _new = new RemoteUser(params[0], remoteserver->GetName());
+               _new = new RemoteUser(params[0], remoteserver);
        }
        catch (...)
        {
@@ -136,38 +132,46 @@ CmdResult CommandUID::Handle(User* serversrc, std::vector<std::string>& params)
 
        bool dosend = true;
 
-       if ((Utils->quiet_bursts && remoteserver->bursting) || ServerInstance->SilentULine(_new->server))
+       if ((Utils->quiet_bursts && remoteserver->bursting) || _new->server->IsSilentULine())
                dosend = false;
 
        if (dosend)
-               ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
+               ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", remoteserver->GetName().c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
 
        FOREACH_MOD(OnPostConnect, (_new));
 
        return CMD_SUCCESS;
 }
 
-CmdResult CommandFHost::Handle(User* src, std::vector<std::string>& params)
+CmdResult CommandFHost::HandleRemote(RemoteUser* src, std::vector<std::string>& params)
 {
-       if (IS_SERVER(src))
-               return CMD_FAILURE;
        src->ChangeDisplayedHost(params[0]);
        return CMD_SUCCESS;
 }
 
-CmdResult CommandFIdent::Handle(User* src, std::vector<std::string>& params)
+CmdResult CommandFIdent::HandleRemote(RemoteUser* src, std::vector<std::string>& params)
 {
-       if (IS_SERVER(src))
-               return CMD_FAILURE;
        src->ChangeIdent(params[0]);
        return CMD_SUCCESS;
 }
 
-CmdResult CommandFName::Handle(User* src, std::vector<std::string>& params)
+CmdResult CommandFName::HandleRemote(RemoteUser* src, std::vector<std::string>& params)
 {
-       if (IS_SERVER(src))
-               return CMD_FAILURE;
        src->ChangeName(params[0]);
        return CMD_SUCCESS;
 }
 
+CommandUID::Builder::Builder(User* user)
+       : CmdBuilder(TreeServer::Get(user)->GetID(), "UID")
+{
+       push(user->uuid);
+       push_int(user->age);
+       push(user->nick);
+       push(user->host);
+       push(user->dhost);
+       push(user->ident);
+       push(user->GetIPString());
+       push_int(user->signon);
+       push('+').push_raw(user->FormatModes(true));
+       push_last(user->fullname);
+}