aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_spanningtree/main.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-05-10 15:13:47 +0100
committerGravatar Sadie Powell2021-05-10 15:15:51 +0100
commitaf023bead14b3306c0f7223848f9fd76dd83aae4 (patch)
tree8dc7ec7f1d035a2a4a4403a380d270552b893021 /src/modules/m_spanningtree/main.cpp
parentFix the to_string implementation of ConvToStr. (diff)
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.
Diffstat (limited to 'src/modules/m_spanningtree/main.cpp')
-rw-r--r--src/modules/m_spanningtree/main.cpp45
1 files changed, 35 insertions, 10 deletions
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