diff --git a/include/server.h b/include/server.h index d1c99448b..d2c75fac7 100644 --- a/include/server.h +++ b/include/server.h @@ -84,4 +84,17 @@ public: * @return True if this server is a silent service, false otherwise. */ bool IsSilentService() const { return silentservice; } + + /** Send metadata related to this server to the target server. + * @param key The name of the metadata (e.g. foo-bar). + * @param data The network representation of the metadata. + */ + virtual void SendMetadata(const std::string& key, const std::string& data) const; + + /** Send metadata related to an extensible to the target server. + * @param ext The extensible to send metadata for. + * @param key The name of the metadata (e.g. foo-bar). + * @param data The network representation of the metadata. + */ + virtual void SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) const; }; diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index b36c913d7..3a87f2016 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -291,3 +291,15 @@ void TreeServer::RemoveHash() Utils->sidlist.erase(GetId()); Utils->serverlist.erase(GetName()); } + +void TreeServer::SendMetadata(const std::string& key, const std::string& data) const +{ + if (!GetRoute()) + GetRoute()->GetSocket()->WriteLine(CommandMetadata::Builder(key, data)); +} + +void TreeServer::SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) const +{ + if (!GetRoute()) + GetRoute()->GetSocket()->WriteLine(CommandMetadata::Builder(ext, key, data)); +} diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index ef8b1e7c7..69647f3b8 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -97,6 +97,10 @@ public: */ TreeServer(); + void SendMetadata(const std::string& key, const std::string& data) const override; + + void SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) const override; + /** When we create a new server, we call this constructor to initialize it. * This constructor initializes the server's Route and Parent, and sets up * its ping counters so that it will be pinged one minute from now. diff --git a/src/server.cpp b/src/server.cpp index 805fc9c16..2d469bcd5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -161,3 +161,13 @@ const std::string& Server::GetPublicName() const return ServerInstance->Config->HideServer; return GetName(); } + +void Server::SendMetadata(const std::string& key, const std::string& data) const +{ + // Do nothing for the local server. +} + +void Server::SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) const +{ + // Do nothing for the local server. +}