diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-17 13:48:50 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-17 13:48:50 +0200 |
commit | 7b0f3072986ae8e6d356afd18e17e90deeb204bd (patch) | |
tree | e59c6a54abc3fe1402a51416a807f9420cd2247d /src/modules | |
parent | 782c8303d7dbf379e1cd807b59ec6a0ba701ca7d (diff) |
m_spanningtree Share server description updates via SINFO desc
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/sinfo.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 644193679..9a924fea9 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -649,6 +649,16 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter) void ModuleSpanningTree::ReadConfig(ConfigStatus& status) { + // Did this rehash change the description of this server? + const std::string& newdesc = ServerInstance->Config->ServerDesc; + if (newdesc != Utils->TreeRoot->GetDesc()) + { + // Broadcast a SINFO desc message to let the network know about the new description. This is the description + // string that is sent in the SERVER message initially and shown for example in WHOIS. + // We don't need to update the field itself in the Server object - the core does that. + CommandSInfo::Builder(Utils->TreeRoot, "desc", newdesc).Broadcast(); + } + // Re-read config stuff try { diff --git a/src/modules/m_spanningtree/sinfo.cpp b/src/modules/m_spanningtree/sinfo.cpp index 76697a496..0989ea9a5 100644 --- a/src/modules/m_spanningtree/sinfo.cpp +++ b/src/modules/m_spanningtree/sinfo.cpp @@ -34,6 +34,12 @@ CmdResult CommandSInfo::HandleServer(TreeServer* server, std::vector<std::string { server->SetVersion(value); } + else if (key == "desc") + { + // Only sent when the description of a server changes because of a rehash; not sent on burst + ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Server description of " + server->GetName() + " changed: " + value); + server->SetDesc(value); + } return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 9218c02ce..6bd1a4f7c 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -157,6 +157,12 @@ class TreeServer : public Server */ void SetFullVersion(const std::string& verstr) { fullversion = verstr; } + /** Sets the description of this server. Called when the description of a remote server changes + * and we are notified about it. + * @param descstr The description to set + */ + void SetDesc(const std::string& descstr) { description = descstr; } + /** Return all child servers */ const ChildServers& GetChildren() const { return Children; } |