From af023bead14b3306c0f7223848f9fd76dd83aae4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 10 May 2021 15:13:47 +0100 Subject: Use the contents of the link data map when using the 1206 protocol. Still to do: - Extract URL encoding to inspstring. - Use CompareLinkData when using the 1206 protocol. - Show friendlier messages when a link compatibility is encountered. --- src/modules/m_spanningtree/main.cpp | 45 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'src/modules/m_spanningtree/main.cpp') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 19a0fc332..e8012fc55 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -678,26 +678,51 @@ void ModuleSpanningTree::ReadConfig(ConfigStatus& status) } } -void ModuleSpanningTree::OnLoadModule(Module* mod) +namespace { - std::stringstream buffer; - buffer << '+' << mod->ModuleSourceFile; + void BroadcastModuleState(Module* mod, bool loading) + { + std::stringstream buffer; + buffer << (loading ? '+' : '-') << ModuleManager::ShrinkModName(mod->ModuleSourceFile); + + std::stringstream compatbuffer; + compatbuffer << (loading ? '+' : '-') << mod->ModuleSourceFile; + + if (loading) + { + const std::string linkstring = Utils->BuildLinkString(PROTO_INSPIRCD_40_A1, mod); + if (!linkstring.empty()) + buffer << '=' << linkstring; + + const std::string compatlinkstring = Utils->BuildLinkString(PROTO_INSPIRCD_30, mod); + if (!linkstring.empty()) + compatbuffer << '=' << compatlinkstring; + } - Module::LinkData data; - std::string compatdata; - mod->GetLinkData(data, compatdata); - if (!compatdata.empty()) - buffer << '=' << compatdata; + for (const auto& child : Utils->TreeRoot->GetChildren()) + { + if (!child->GetSocket()) + continue; // Should never happen? + + if (child->GetSocket()->proto_version <= PROTO_INSPIRCD_30) + CommandMetadata::Builder("modules", buffer.str()).Forward(child); + else + CommandMetadata::Builder("modules", compatbuffer.str()).Forward(child); + } + } +} - ServerInstance->PI->SendMetaData("modules", buffer.str()); +void ModuleSpanningTree::OnLoadModule(Module* mod) +{ + BroadcastModuleState(mod, true); } void ModuleSpanningTree::OnUnloadModule(Module* mod) { if (!Utils) return; - ServerInstance->PI->SendMetaData("modules", "-" + mod->ModuleSourceFile); + BroadcastModuleState(mod, false); if (mod == this) { // We are being unloaded, inform modules about all servers splitting which cannot be done later when the servers are actually disconnected -- cgit v1.3.1-10-gc9f91