X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreesocket2.cpp;h=8d939d22a20eefb040b4a3d37d79a065d72fde8f;hb=c8f92d97c2cd92a07bbb76b96a67cd089c7e3407;hp=e3f355ac6db282caa40cacb80242fa47d4f9977e;hpb=29694ce3d2c57ebefa9b14b6816679bf44799921;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index e3f355ac6..8d939d22a 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -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; } @@ -314,23 +307,19 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, cmd = ServerInstance->Parser->GetHandler(command); if (!cmd) { - irc::stringjoiner pmlist(params); - ServerInstance->Logs->Log(MODNAME, LOG_SPARSE, "Unrecognised S2S command :%s %s %s", - who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str()); - SendError("Unrecognised command '" + command + "' -- possibly loaded mismatched modules"); - return; + if (command == "ERROR") + { + this->Error(params); + return; + } + + throw ProtocolException("Unknown command"); } cmdbase = cmd; } 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()); - SendError("Insufficient parameters for command '" + command + "'"); - return; - } + throw ProtocolException("Insufficient parameters"); if ((!params.empty()) && (params.back().empty()) && (!cmdbase->allow_empty_last_param)) { @@ -344,16 +333,13 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, if (scmd) res = scmd->Handle(who, params); else - res = cmd->Handle(params, who); - - 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()); - SendError("Error handling '" + command + "' -- possibly loaded mismatched modules"); + res = cmd->Handle(params, who); + if (res == CMD_INVALID) + throw ProtocolException("Error in command handler"); } - else if (res == CMD_SUCCESS) + + if (res == CMD_SUCCESS) Utils->RouteCommand(route_back_again, cmdbase, params, who); }