diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:44:50 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:44:50 +0000 |
commit | 8cebe2878f3878afce6f643d93668155cb26801d (patch) | |
tree | e9e806e3ffb200801c4b627530c5b5005ec4c099 /src/modules | |
parent | 5d67a5fff127bf95bca69b436ef7f645f2fe3281 (diff) |
Include explicit routing information in Command, will replace CMD_LOCALONLY return value
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11601 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 719ff0046..428079c23 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -29,63 +29,35 @@ void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line) { - if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, parameters.size(), user))) - { - /* Safe, we know its non-null because IsValidModuleCommand returned true */ - Command* thiscmd = ServerInstance->Parser->GetHandler(command); + if (result != CMD_SUCCESS) + return; + if (!ServerInstance->IsValidModuleCommand(command, parameters.size(), user)) + return; - Module* srcmodule = ServerInstance->Modules->Find(thiscmd->source); + /* We know it's non-null because IsValidModuleCommand returned true */ + Command* thiscmd = ServerInstance->Parser->GetHandler(command); - if (srcmodule && !(srcmodule->GetVersion().Flags & VF_COMMON)) { - ServerInstance->Logs->Log("m_spanningtree",ERROR,"Routed command %s from non-VF_COMMON module %s", - command.c_str(), thiscmd->source.c_str()); - return; - } + RouteDescriptor routing = thiscmd->GetRouting(user, parameters); - // this bit of code cleverly routes all module commands - // to all remote severs *automatically* so that modules - // can just handle commands locally, without having - // to have any special provision in place for remote - // commands and linking protocols. - parameterlist params; - params.clear(); - unsigned int n_translate = thiscmd->translation.size(); - TranslateType translate_to; + if (routing.type == ROUTE_TYPE_LOCALONLY) + return; - /* To make sure that parameters with spaces, or empty - * parameters, etc, are always sent properly, *always* - * prefix the last parameter with a :. This also removes - * an extra strchr() */ - for (unsigned int j = 0; j < parameters.size(); j++) - { - std::string target; + Module* srcmodule = ServerInstance->Modules->Find(thiscmd->source); - /* Map all items to UUIDs where neccessary */ - if (j < n_translate) - { - /* We have a translation mapping for this index */ - translate_to = thiscmd->translation[j] != TR_END ? thiscmd->translation[j] : TR_TEXT; - } - else - translate_to = TR_TEXT; + if (srcmodule && !(srcmodule->GetVersion().Flags & VF_COMMON)) { + ServerInstance->Logs->Log("m_spanningtree",ERROR,"Routed command %s from non-VF_COMMON module %s", + command.c_str(), thiscmd->source.c_str()); + return; + } + + std::string output_text; + ServerInstance->Parser->TranslateUIDs(thiscmd->translation, parameters, output_text, true, thiscmd); - ServerInstance->Logs->Log("m_spanningtree",DEBUG,"TRANSLATION: %s - type is %d", parameters[j].c_str(), translate_to); - if (translate_to == TR_CUSTOM) - { - target = parameters[j]; - thiscmd->EncodeParameter(target, j); - } - else - { - ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target); - } + parameterlist params; + params.push_back(output_text); - if (j == (parameters.size() - 1)) - params.push_back(":" + target); - else - params.push_back(target); - } + if (routing.type == ROUTE_TYPE_BROADCAST) Utils->DoOneToMany(user->uuid, command, params); - } + else + Utils->DoOneToOne(user->uuid, command, params, routing.serverdest); } - |