1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $ModDesc: Provides a spanning tree server link protocol */
17 #include "commands/cmd_whois.h"
18 #include "commands/cmd_stats.h"
22 #include "transport.h"
24 #include "m_spanningtree/main.h"
25 #include "m_spanningtree/utils.h"
26 #include "m_spanningtree/treeserver.h"
27 #include "m_spanningtree/treesocket.h"
29 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
31 void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line)
33 if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, parameters.size(), user)))
35 /* Safe, we know its non-null because IsValidModuleCommand returned true */
36 Command* thiscmd = ServerInstance->Parser->GetHandler(command);
37 // this bit of code cleverly routes all module commands
38 // to all remote severs *automatically* so that modules
39 // can just handle commands locally, without having
40 // to have any special provision in place for remote
41 // commands and linking protocols.
42 std::deque<std::string> params;
44 unsigned int n_translate = thiscmd->translation.size();
45 TranslateType translate_to;
47 /* To make sure that parameters with spaces, or empty
48 * parameters, etc, are always sent properly, *always*
49 * prefix the last parameter with a :. This also removes
50 * an extra strchr() */
51 for (unsigned int j = 0; j < parameters.size(); j++)
55 /* Map all items to UUIDs where neccessary */
58 /* We have a translation mapping for this index */
59 translate_to = thiscmd->translation[j] != TR_END ? thiscmd->translation[j] : TR_TEXT;
62 translate_to = TR_TEXT;
64 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"TRANSLATION: %s - type is %d", parameters[j].c_str(), translate_to);
65 if (translate_to == TR_CUSTOM)
67 target = parameters[j];
68 thiscmd->EncodeParameter(target, j);
72 ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target);
75 if (j == (parameters.size() - 1))
76 params.push_back(":" + target);
78 params.push_back(target);
80 Utils->DoOneToMany(user->uuid, command, params);