From cf01291da809290781aa2c5ae657bf86d87ac5e7 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 24 Aug 2024 16:26:58 +0100 Subject: Fix broadcasting server information to remote v3 servers. --- src/modules/m_spanningtree/compat.cpp | 33 +++++++++++++++++++++++++++++++ src/modules/m_spanningtree/netburst.cpp | 9 --------- src/modules/m_spanningtree/treeserver.cpp | 2 ++ 3 files changed, 35 insertions(+), 9 deletions(-) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 145d3667e..679159352 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -51,8 +51,10 @@ void TreeSocket::WriteLine(const std::string& original_line) cmdstart++; } + size_t sidstart = std::string::npos; if (line[cmdstart] == ':') // Skip the prefix. { + sidstart = cmdstart + 1; cmdstart = NextToken(line, cmdstart); if (cmdstart != std::string::npos) cmdstart++; @@ -109,6 +111,37 @@ void TreeSocket::WriteLine(const std::string& original_line) } } } + else if (irc::equals(command, "SINFO")) + { + // : SINFO : + auto keyend = NextToken(line, cmdend); + if (keyend != std::string::npos && sidstart != std::string::npos) + { + auto skey = line.substr(cmdend + 1, keyend - cmdend - 1); + if (irc::equals(skey, "customversion")) + return; + else if (irc::equals(skey, "rawbranch")) + { + // InspIRCd-4. testnet.inspircd.org :Test + auto* sid = Utils->FindServerID(line.substr(sidstart, cmdstart - sidstart - 1)); + if (sid) + { + line.replace(cmdend + 1, keyend - cmdend - 1, "version"); + line.append(INSP_FORMAT(". {} :{}", sid->GetPublicName(), sid->GetDesc())); + } + } + else if (irc::equals(skey, "rawversion")) + { + // InspIRCd-4.0.0-a10. sadie.testnet.inspircd.org :[597] Test + auto* sid = Utils->FindServerID(line.substr(sidstart, cmdstart - sidstart - 1)); + if (sid) + { + line.replace(cmdend + 1, keyend - cmdend - 1, "fullversion"); + line.append(INSP_FORMAT(". {} :[{}] {}", sid->GetName(), sid->GetId(), sid->GetDesc())); + } + } + } + } else if (irc::equals(command, "SQUERY")) { // SQUERY was introduced in PROTO_INSPIRCD_4; convert to PRIVMSG. diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 48ce55176..f1b622853 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -119,15 +119,6 @@ void TreeSocket::SendServerInfo(TreeServer* from) this->WriteLine(CommandSInfo::Builder(from, "customversion", from->customversion)); this->WriteLine(CommandSInfo::Builder(from, "rawbranch", from->rawbranch)); this->WriteLine(CommandSInfo::Builder(from, "rawversion", from->rawversion)); - - if (proto_version < PROTO_INSPIRCD_4) - { - this->WriteLine(CommandSInfo::Builder(from, "version", INSP_FORMAT("{}. {} :{}", from->rawbranch, - from->GetPublicName(), from->customversion))); - - this->WriteLine(CommandSInfo::Builder(from, "fullversion", INSP_FORMAT("{}. {} :[{}] {}", from->rawversion, - from->GetName(), from->GetId(), from->customversion))); - } } /** Recursively send the server tree. diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index a15d3fd2a..d8b9167aa 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -61,6 +61,8 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s , pingtimer(this) , ServerUser(new FakeUser(id, this)) , age(ServerInstance->Time()) + , rawbranch("unknown") + , rawversion("unknown") , Hidden(Hide) { ServerInstance->Logs.Debug(MODNAME, "New server {} behind_bursting {}", GetName(), behind_bursting); -- cgit v1.3.1-10-gc9f91