]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket2.cpp
m_operjoin Remove duplicated code
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket2.cpp
index 8d14ff5ff07c9de0183b8548ca0c42e621774c00..4639a237ede4f329a5f4a2ed9f6a475c27330928 100644 (file)
@@ -229,7 +229,6 @@ void TreeSocket::ProcessLine(std::string &line)
 void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, parameterlist& params)
 {
        User* who = ServerInstance->FindUUID(prefix);
-       std::string direction;
 
        if (!who)
        {
@@ -269,10 +268,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
                }
        }
 
-       // Make sure prefix is still good
-       direction = who->server;
-       prefix = who->uuid;
-
        /*
         * Check for fake direction here, and drop any instances that are found.
         * What is fake direction? Imagine the following server setup:
@@ -289,12 +284,10 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
         * a valid SID or a valid UUID, so that invalid UUID or SID never makes it
         * to the higher level functions. -- B
         */
-       TreeServer* route_back_again = Utils->BestRouteTo(direction);
-       if ((!route_back_again) || (route_back_again->GetSocket() != this))
+       TreeServer* route_back_again = TreeServer::Get(who)->GetRoute();
+       if (route_back_again->GetSocket() != this)
        {
-               if (route_back_again)
-                       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'",
-                               prefix.c_str(),linkID.c_str());
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'", prefix.c_str(), linkID.c_str());
                return;
        }
 
@@ -307,16 +300,21 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
 
        ServerCommand* scmd = Utils->Creator->CmdManager.GetHandler(command);
        CommandBase* cmdbase = scmd;
-       Command* cmd;
+       Command* cmd = NULL;
        if (!scmd)
        {
                // Not a special server-to-server command
                cmd = ServerInstance->Parser->GetHandler(command);
                if (!cmd)
                {
-                       irc::stringjoiner pmlist(params);
+                       if (command == "ERROR")
+                       {
+                               this->Error(params);
+                               return;
+                       }
+
                        ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, "Unrecognised S2S command :%s %s %s",
-                               who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
+                               who->uuid.c_str(), command.c_str(), irc::stringjoiner(params).c_str());
                        SendError("Unrecognised command '" + command + "' -- possibly loaded mismatched modules");
                        return;
                }
@@ -325,9 +323,8 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
 
        if (params.size() < cmdbase->min_params)
        {
-               irc::stringjoiner pmlist(params);
                ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, "Insufficient parameters for S2S command :%s %s %s",
-                       who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
+                       who->uuid.c_str(), command.c_str(), irc::stringjoiner(params).c_str());
                SendError("Insufficient parameters for command '" + command + "'");
                return;
        }
@@ -348,9 +345,8 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
 
        if (res == CMD_INVALID)
        {
-               irc::stringjoiner pmlist(params);
                ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, "Error handling S2S command :%s %s %s",
-                       who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
+                       who->uuid.c_str(), command.c_str(), irc::stringjoiner(params).c_str());
                SendError("Error handling '" + command + "' -- possibly loaded mismatched modules");
        }
        else if (res == CMD_SUCCESS)