void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, parameterlist& params)
{
User* who = ServerInstance->FindUUID(prefix);
- std::string direction;
if (!who)
{
}
}
- // 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:
* 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;
}
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);
- 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))
{
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);
}