X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreesocket2.cpp;h=f2ea0808f7f9a821955732c58b428844aa77d853;hb=e950f568d0f571e9475aa38177486468714de4d3;hp=cd9afac419fafa1775fc369eb2c23137e7273202;hpb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index cd9afac41..f2ea0808f 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -80,7 +80,7 @@ void TreeSocket::ProcessLine(std::string &line) std::string command; parameterlist params; - ServerInstance->Logs->Log("m_spanningtree", LOG_RAWIO, "S[%d] I %s", this->GetFd(), line.c_str()); + ServerInstance->Logs->Log(MODNAME, LOG_RAWIO, "S[%d] I %s", this->GetFd(), line.c_str()); Split(line, prefix, command, params); @@ -160,9 +160,21 @@ void TreeSocket::ProcessLine(std::string &line) ServerInstance->SNO->WriteGlobalSno('l',"\2WARNING\2: Your clocks are out by %d seconds. Please consider synching your clocks.", abs((long)delta)); } } + + // Check for duplicate server name/sid again, it's possible that a new + // server was introduced while we were waiting for them to send BURST. + // (we do not reserve their server name/sid when they send SERVER, we do it now) + if (!CheckDuplicate(capab->name, capab->sid)) + return; + this->LinkState = CONNECTED; Utils->timeoutlist.erase(this); + linkID = capab->name; + + MyRoot = new TreeServer(capab->name, capab->description, capab->sid, Utils->TreeRoot, this, capab->hidden); + Utils->TreeRoot->AddChild(MyRoot); + MyRoot->bursting = true; this->DoBurst(MyRoot); @@ -241,7 +253,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, * crossing the users QUIT further upstream from the server. Thanks jilles! */ - if ((prefix.length() == UUID_LENGTH-1) && (isdigit(prefix[0])) && + if ((prefix.length() == UIDGenerator::UUID_LENGTH) && (isdigit(prefix[0])) && ((command == "FMODE") || (command == "MODE") || (command == "KICK") || (command == "TOPIC") || (command == "KILL") || (command == "ADDLINE") || (command == "DELLINE"))) { /* Special case, we cannot drop these commands as they've been committed already on a @@ -255,7 +267,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, } else { - ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "Command '%s' from unknown prefix '%s'! Dropping entire command.", + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Command '%s' from unknown prefix '%s'! Dropping entire command.", command.c_str(), prefix.c_str()); return; } @@ -286,17 +298,17 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, if ((!route_back_again) || (route_back_again->GetSocket() != this)) { if (route_back_again) - ServerInstance->Logs->Log("m_spanningtree",LOG_DEBUG,"Protocol violation: Fake direction '%s' from connection '%s'", + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'", prefix.c_str(),linkID.c_str()); return; } - /* - * First up, check for any malformed commands (e.g. MODE without a timestamp) - * and rewrite commands where necessary (SVSMODE -> MODE for services). -- w - */ - if (command == "SVSMODE") // This isn't in an "else if" so we still force FMODE for changes on channels. - command = "MODE"; + // Translate commands coming from servers using an older protocol + if (proto_version < ProtocolVersion) + { + if (!PreProcessOldProtocolMessage(who, command, params)) + return; + } // TODO move all this into Commands if (command == "MAP") @@ -445,8 +457,8 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, return; } } - who->ForceNickChange(params[0].c_str()); - Utils->RouteCommand(route_back_again, command, params, who); + who->ForceNickChange(params[0]); + Utils->DoOneToAllButSender(prefix, command, params, prefix); } else { @@ -454,8 +466,8 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, if (!cmd) { - irc::stringjoiner pmlist(" ", params, 0, params.size() - 1); - ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Unrecognised S2S command :%s %s %s", + 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; @@ -463,8 +475,8 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, if (params.size() < cmd->min_params) { - irc::stringjoiner pmlist(" ", params, 0, params.size() - 1); - ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Insufficient parameters for S2S command :%s %s %s", + 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; @@ -482,13 +494,13 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, if (res == CMD_INVALID) { - irc::stringjoiner pmlist(" ", params, 0, params.size() - 1); - ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Error handling S2S command :%s %s %s", + 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"); } else if (res == CMD_SUCCESS) - Utils->RouteCommand(route_back_again, command, params, who); + Utils->RouteCommand(route_back_again, cmd, params, who); } }