- if (Utils->MasterTime)
- {
- std::deque<std::string> params;
- params.push_back(ConvToStr(ServerInstance->Time(false)));
- params.push_back("FORCE");
- Utils->DoOneToMany(ServerInstance->Config->GetSID(), "TIMESET", params);
- }
-}
-
-int ModuleSpanningTree::OnStats(char statschar, userrec* user, string_list &results)
-{
- if ((statschar == 'c') || (statschar == 'n'))
- {
- for (unsigned int i = 0; i < Utils->LinkBlocks.size(); i++)
- {
- results.push_back(std::string(ServerInstance->Config->ServerName)+" 213 "+user->nick+" "+statschar+" *@"+(Utils->LinkBlocks[i].HiddenFromStats ? "<hidden>" : Utils->LinkBlocks[i].IPAddr)+" * "+Utils->LinkBlocks[i].Name.c_str()+" "+ConvToStr(Utils->LinkBlocks[i].Port)+" "+(Utils->LinkBlocks[i].Hook.empty() ? "plaintext" : Utils->LinkBlocks[i].Hook)+" "+(Utils->LinkBlocks[i].AutoConnect ? 'a' : '-')+'s');
- if (statschar == 'c')
- results.push_back(std::string(ServerInstance->Config->ServerName)+" 244 "+user->nick+" H * * "+Utils->LinkBlocks[i].Name.c_str());
- }
- results.push_back(std::string(ServerInstance->Config->ServerName)+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
- ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
- return 1;
- }
-
- if (statschar == 'p')
- {
- /* show all server ports, after showing client ports. -- w00t */
-
- for (unsigned int i = 0; i < Utils->Bindings.size(); i++)
- {
- std::string ip = Utils->Bindings[i]->IP;
- if (ip.empty())
- ip = "*";
-
- std::string transport("plaintext");
- if (Utils->Bindings[i]->GetHook())
- transport = InspSocketNameRequest(this, Utils->Bindings[i]->GetHook()).Send();
-
- results.push_back(ConvToStr(ServerInstance->Config->ServerName) + " 249 "+user->nick+" :" + ip + ":" + ConvToStr(Utils->Bindings[i]->port)+
- " (server, " + transport + ")");
- }
- }
- return 0;
-}
-
-int ModuleSpanningTree::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
-{
- /* If the command doesnt appear to be valid, we dont want to mess with it. */
- if (!validated)
- return 0;
-
- if (command == "CONNECT")
- {
- return this->HandleConnect(parameters,pcnt,user);
- }
- else if (command == "STATS")
- {
- return this->HandleStats(parameters,pcnt,user);
- }
- else if (command == "MOTD")
- {
- return this->HandleMotd(parameters,pcnt,user);
- }
- else if (command == "ADMIN")
- {
- return this->HandleAdmin(parameters,pcnt,user);
- }
- else if (command == "SQUIT")
- {
- return this->HandleSquit(parameters,pcnt,user);
- }
- else if (command == "MAP")
- {
- this->HandleMap(parameters,pcnt,user);
- return 1;
- }
- else if ((command == "TIME") && (pcnt > 0))
- {
- return this->HandleTime(parameters,pcnt,user);
- }
- else if (command == "LUSERS")
- {
- this->HandleLusers(parameters,pcnt,user);
- return 1;
- }
- else if (command == "LINKS")
- {
- this->HandleLinks(parameters,pcnt,user);
- return 1;
- }
- else if (command == "WHOIS")
- {
- if (pcnt > 1)
- {
- // remote whois
- return this->HandleRemoteWhois(parameters,pcnt,user);
- }
- }
- else if ((command == "VERSION") && (pcnt > 0))
- {
- this->HandleVersion(parameters,pcnt,user);
- return 1;
- }
- else if ((command == "MODULES") && (pcnt > 0))
- {
- return this->HandleModules(parameters,pcnt,user);
- }
- return 0;
-}
-
-void ModuleSpanningTree::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line)
-{
- if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, pcnt, user)))
- {
- /* Safe, we know its non-null because IsValidModuleCommand returned true */
- command_t* thiscmd = ServerInstance->Parser->GetHandler(command);
- // 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();
- int n_translate = thiscmd->translation.size();
- TranslateType translate_to;
-
- for (int j = 0; j < pcnt; j++)
- {
- std::string target;
-
- /* 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;
-
- ServerInstance->Log(DEBUG,"TRANSLATION: %s - type is %d", parameters[j], translate_to);
- ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target);
-
- if (strchr(parameters[j],' '))
- params.push_back(":" + target);
- else
- params.push_back(target);
- }
- Utils->DoOneToMany(user->uuid, command, params);
- }