diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 21 | ||||
-rw-r--r-- | src/modules.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 22 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a946abbbb..2e300df95 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1560,6 +1560,27 @@ void handle_version(char **parameters, int pcnt, userrec *user) } +bool is_valid_cmd(const char* commandname, int pcnt, userrec * user) +{ + for (unsigned int i = 0; i < cmdlist.size(); i++) + { + if (!strcasecmp(cmdlist[i].command,commandname)) + { + if (cmdlist[i].handler_function) + { + if (pcnt>=cmdlist[i].min_params) + { + if (strchr(user->modes,cmdlist[i].flags_needed)) + { + return true; + } + } + } + } + } + return false; +} + // calls a handler function for a command void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user) diff --git a/src/modules.cpp b/src/modules.cpp index 2dda2daf5..e199bcbcc 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -464,6 +464,11 @@ void Server::CallCommandHandler(std::string commandname, char** parameters, int call_handler(commandname.c_str(),parameters,pcnt,user); } +bool Server::IsValidModuleCommand(std::string commandname, int pcnt, userrec* user) +{ + return is_valid_cmd(commandname, pcnt, user) +} + void Server::Log(int level, std::string s) { log(level,"%s",s.c_str()); diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index bb2231306..fbdc6f1f5 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1418,6 +1418,28 @@ class ModuleSpanningTree : public Module this->HandleLinks(parameters,pcnt,user); return 1; } + else if (Srv->IsValidModuleCommand(command, pcnt, user)) + { + // 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. + std::deque<std::string> params; + params.clear(); + for (int j = 0; j < pcnt; j++) + { + if (strchr(parameters[j],' ')) + { + params.push_back(":" + std::string(parameters[j])); + } + else + { + params.push_back(std::string(parameters[j])); + } + } + DoOneToMany(user->nick,command,params); + } return 0; } |