diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-07-27 18:56:12 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-07-27 18:56:12 +0200 |
commit | 6c37b451cd2bb948d562cb00354bdc7a7dc400da (patch) | |
tree | e5cc65e65d70a3bf0927f67c466472f5d36d25ef | |
parent | 984004505b8b5eea2467b703411fccac831ee780 (diff) |
m_spanningtree Parse additional information present in SERVER messages
Format: <key>[=<value>]
-rw-r--r-- | src/modules/m_spanningtree/commands.h | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index a5fc1164e..c26d5d7ae 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -305,12 +305,18 @@ class CommandSave : public ServerCommand class CommandServer : public ServerOnlyServerCommand<CommandServer> { + static void HandleExtra(TreeServer* newserver, const std::vector<std::string>& params); + public: CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 3) { } CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters); class Builder : public CmdBuilder { + void push_property(const char* key, const std::string& val) + { + push(key).push_raw('=').push_raw(val); + } public: Builder(TreeServer* server); }; diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 5da000f20..e7868090d 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -64,11 +64,29 @@ CmdResult CommandServer::HandleServer(TreeServer* ParentOfThis, std::vector<std: TreeServer* Node = new TreeServer(servername, description, sid, ParentOfThis, ParentOfThis->GetSocket(), lnk ? lnk->Hidden : false); Node->BeginBurst(); + HandleExtra(Node, params); ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+ParentOfThis->GetName()+"\002 introduced server \002"+servername+"\002 ("+description+")"); return CMD_SUCCESS; } +void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::string>& params) +{ + for (std::vector<std::string>::const_iterator i = params.begin() + 2; i != params.end() - 1; ++i) + { + const std::string& prop = *i; + std::string::size_type p = prop.find('='); + + std::string key = prop; + std::string val; + if (p != std::string::npos) + { + key.erase(p); + val = prop.substr(p+1); + } + } +} + Link* TreeSocket::AuthRemote(const parameterlist& params) { if (params.size() < 5) |