1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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"
21 #include "../transport.h"
25 #include "treeserver.h"
26 #include "treesocket.h"
28 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
30 void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line)
32 if (result != CMD_SUCCESS)
34 if (!ServerInstance->IsValidModuleCommand(command, parameters.size(), user))
37 /* We know it's non-null because IsValidModuleCommand returned true */
38 Command* thiscmd = ServerInstance->Parser->GetHandler(command);
40 RouteDescriptor routing = thiscmd->GetRouting(user, parameters);
42 std::string sent_cmd = command;
45 if (routing.type == ROUTE_TYPE_LOCALONLY)
49 else if (routing.type == ROUTE_TYPE_OPT_BCAST)
51 params.push_back("*");
52 params.push_back(command);
55 else if (routing.type == ROUTE_TYPE_OPT_UCAST)
57 params.push_back(routing.serverdest);
58 params.push_back(command);
63 Module* srcmodule = thiscmd->creator;
65 if (srcmodule && !(srcmodule->GetVersion().Flags & VF_COMMON)) {
66 ServerInstance->Logs->Log("m_spanningtree",ERROR,"Routed command %s from non-VF_COMMON module %s",
67 command.c_str(), srcmodule->ModuleSourceFile.c_str());
72 std::string output_text;
73 ServerInstance->Parser->TranslateUIDs(thiscmd->translation, parameters, output_text, true, thiscmd);
75 params.push_back(output_text);
77 if (routing.type == ROUTE_TYPE_BROADCAST || routing.type == ROUTE_TYPE_OPT_BCAST)
78 Utils->DoOneToMany(user->uuid, sent_cmd, params);
80 Utils->DoOneToOne(user->uuid, sent_cmd, params, routing.serverdest);