diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-19 05:08:14 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-19 05:08:14 +0000 |
commit | 80abf1ed3ef868b1cad85785b2386f5cbd818ba4 (patch) | |
tree | b1a5ef2563d5c520aa8a34fb2a28b91a524b6bd7 /src | |
parent | aeded4708c515bcc255b2947e67f076855fead14 (diff) |
Remove overrides for ADMIN, STATS, TIME
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12302 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/cmd_admin.cpp | 30 | ||||
-rw-r--r-- | src/commands/cmd_stats.cpp | 26 | ||||
-rw-r--r-- | src/commands/cmd_time.cpp | 25 | ||||
-rw-r--r-- | src/modules/m_spanningtree/admin.cpp | 58 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 12 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_admin.cpp | 50 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_stats.cpp | 31 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_time.cpp | 50 | ||||
-rw-r--r-- | src/modules/m_spanningtree/precommand.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_spanningtree/stats.cpp | 62 | ||||
-rw-r--r-- | src/modules/m_spanningtree/time.cpp | 74 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 14 |
13 files changed, 40 insertions, 413 deletions
diff --git a/src/commands/cmd_admin.cpp b/src/commands/cmd_admin.cpp index 16e2c0ddd..7141ca14e 100644 --- a/src/commands/cmd_admin.cpp +++ b/src/commands/cmd_admin.cpp @@ -13,12 +13,6 @@ #include "inspircd.h" -#ifndef __CMD_ADMIN_H__ -#define __CMD_ADMIN_H__ - -#include "users.h" -#include "channels.h" - /** Handle /ADMIN. These command handlers can be reloaded by the core, * and handle basic RFC1459 commands. Commands within modules work * the same way, however, they can be fully unloaded, where these @@ -37,21 +31,29 @@ class CommandAdmin : public Command * @return A value from CmdResult to indicate command success or failure. */ CmdResult Handle(const std::vector<std::string>& parameters, User *user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) + { + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; + } }; -#endif - - - /** Handle /ADMIN */ CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User *user) { - user->WriteNumeric(RPL_ADMINME, "%s :Administrative info for %s",user->nick.c_str(),ServerInstance->Config->ServerName.c_str()); + if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + return CMD_SUCCESS; + user->SendText(":%s %03d %s :Administrative info for %s", ServerInstance->Config->ServerName.c_str(), + RPL_ADMINME, user->nick.c_str(),ServerInstance->Config->ServerName.c_str()); if (!ServerInstance->Config->AdminName.empty()) - user->WriteNumeric(RPL_ADMINLOC1, "%s :Name - %s",user->nick.c_str(),ServerInstance->Config->AdminName.c_str()); - user->WriteNumeric(RPL_ADMINLOC2, "%s :Nickname - %s",user->nick.c_str(),ServerInstance->Config->AdminNick.c_str()); - user->WriteNumeric(RPL_ADMINEMAIL, "%s :E-Mail - %s",user->nick.c_str(),ServerInstance->Config->AdminEmail.c_str()); + user->SendText(":%s %03d %s :Name - %s", ServerInstance->Config->ServerName.c_str(), + RPL_ADMINLOC1, user->nick.c_str(), ServerInstance->Config->AdminName.c_str()); + user->SendText(":%s %03d %s :Nickname - %s", ServerInstance->Config->ServerName.c_str(), + RPL_ADMINLOC2, user->nick.c_str(), ServerInstance->Config->AdminNick.c_str()); + user->SendText(":%s %03d %s :E-Mail - %s", ServerInstance->Config->ServerName.c_str(), + RPL_ADMINEMAIL, user->nick.c_str(), ServerInstance->Config->AdminEmail.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 6180709a7..55279627c 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -44,23 +44,23 @@ class CommandStats : public Command * @return A value from CmdResult to indicate command success or failure. */ CmdResult Handle(const std::vector<std::string>& parameters, User *user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) + { + if (parameters.size() > 1) + return ROUTE_UNICAST(parameters[1]); + return ROUTE_LOCALONLY; + } }; CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user) { - if (IS_LOCAL(user)) - { - string_list values; - if (parameters[0].empty()) - { - user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s STATS :Not enough parameters.", user->nick.c_str()); - return CMD_FAILURE; - } - char search = parameters[0][0]; - ServerInstance->DoStats(search, user, values); - for (size_t i = 0; i < values.size(); i++) - user->Write(":%s", values[i].c_str()); - } + if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName) + return CMD_SUCCESS; + string_list values; + char search = parameters[0][0]; + ServerInstance->DoStats(search, user, values); + for (size_t i = 0; i < values.size(); i++) + user->SendText(":%s", values[i].c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp index 43f4b6bd1..01b9b28a1 100644 --- a/src/commands/cmd_time.cpp +++ b/src/commands/cmd_time.cpp @@ -13,14 +13,6 @@ #include "inspircd.h" -#ifndef __CMD_TIME_H__ -#define __CMD_TIME_H__ - -// include the common header files - -#include "users.h" -#include "channels.h" - /** Handle /TIME. These command handlers can be reloaded by the core, * and handle basic RFC1459 commands. Commands within modules work * the same way, however, they can be fully unloaded, where these @@ -39,15 +31,18 @@ class CommandTime : public Command * @return A value from CmdResult to indicate command success or failure. */ CmdResult Handle(const std::vector<std::string>& parameters, User *user); + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) + { + if (parameters.size() > 0) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; + } }; -#endif - - - - -CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user) +CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User *user) { + if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + return CMD_SUCCESS; struct tm* timeinfo; time_t local = ServerInstance->Time(); @@ -57,7 +52,7 @@ CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user) snprintf(tms,26,"%s",asctime(timeinfo)); tms[24] = 0; - user->WriteNumeric(RPL_TIME, "%s %s :%s",user->nick.c_str(),ServerInstance->Config->ServerName.c_str(),tms); + user->SendText(":%s %03d %s %s :%s", ServerInstance->Config->ServerName.c_str(), RPL_TIME, user->nick.c_str(),ServerInstance->Config->ServerName.c_str(),tms); return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree/admin.cpp b/src/modules/m_spanningtree/admin.cpp deleted file mode 100644 index 56416fdc3..000000000 --- a/src/modules/m_spanningtree/admin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "xline.h" - -#include "treesocket.h" -#include "treeserver.h" -#include "utils.h" - -/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ - -/** remote ADMIN. leet, huh? */ -bool TreeSocket::Admin(const std::string &prefix, parameterlist ¶ms) -{ - if (params.size() > 0) - { - if (InspIRCd::Match(ServerInstance->Config->ServerName, params[0])) - { - /* It's for our server */ - string_list results; - User* source = ServerInstance->FindNick(prefix); - if (source) - { - parameterlist par; - par.push_back(prefix); - par.push_back(""); - par[1] = std::string("::")+ServerInstance->Config->ServerName+" 256 "+source->nick+" :Administrative info for "+ServerInstance->Config->ServerName; - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server); - par[1] = std::string("::")+ServerInstance->Config->ServerName+" 257 "+source->nick+" :Name - "+ServerInstance->Config->AdminName; - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server); - par[1] = std::string("::")+ServerInstance->Config->ServerName+" 258 "+source->nick+" :Nickname - "+ServerInstance->Config->AdminNick; - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server); - par[1] = std::string("::")+ServerInstance->Config->ServerName+" 258 "+source->nick+" :E-Mail - "+ServerInstance->Config->AdminEmail; - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server); - } - } - else - { - /* Pass it on */ - User* source = ServerInstance->FindNick(prefix); - if (source) - Utils->DoOneToOne(prefix, "ADMIN", params, params[0]); - } - } - return true; -} - diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 4467b243f..ce7709189 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -75,14 +75,6 @@ class ModuleSpanningTree : public Module */ void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats); - /** Handle remote ADMIN - */ - ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user); - - /** Handle remote STATS - */ - ModResult HandleStats(const std::vector<std::string>& parameters, User* user); - /** Handle MAP command */ bool HandleMap(const std::vector<std::string>& parameters, User* user); @@ -91,10 +83,6 @@ class ModuleSpanningTree : public Module */ ModResult HandleSquit(const std::vector<std::string>& parameters, User* user); - /** Handle TIME - */ - ModResult HandleTime(const std::vector<std::string>& parameters, User* user); - /** Handle remote WHOIS */ ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user); diff --git a/src/modules/m_spanningtree/override_admin.cpp b/src/modules/m_spanningtree/override_admin.cpp deleted file mode 100644 index c319b834a..000000000 --- a/src/modules/m_spanningtree/override_admin.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -/* $ModDesc: Provides a spanning tree server link protocol */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "treesocket.h" - -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ - -ModResult ModuleSpanningTree::HandleAdmin(const std::vector<std::string>& parameters, User* user) -{ - if (parameters.size() > 0) - { - if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0])) - return MOD_RES_PASSTHRU; - - /* Remote ADMIN, the server is within the 1st parameter */ - parameterlist params; - params.push_back(parameters[0]); - /* Send it out remotely, generate no reply yet */ - TreeServer* s = Utils->FindServerMask(parameters[0]); - if (s) - { - params[0] = s->GetName(); - Utils->DoOneToOne(user->uuid, "ADMIN", params, s->GetName()); - } - else - user->WriteNumeric(ERR_NOSUCHSERVER, "%s %s :No such server", user->nick.c_str(), parameters[0].c_str()); - return MOD_RES_DENY; - } - return MOD_RES_PASSTHRU; -} - diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp index 0a1f18d04..3355c9775 100644 --- a/src/modules/m_spanningtree/override_stats.cpp +++ b/src/modules/m_spanningtree/override_stats.cpp @@ -15,7 +15,6 @@ #include "inspircd.h" #include "socket.h" -#include "xline.h" #include "main.h" #include "utils.h" @@ -23,36 +22,6 @@ #include "link.h" #include "treesocket.h" -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */ - -ModResult ModuleSpanningTree::HandleStats(const std::vector<std::string>& parameters, User* user) -{ - if (parameters.size() > 1) - { - if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[1])) - return MOD_RES_PASSTHRU; - - /* Remote STATS, the server is within the 2nd parameter */ - parameterlist params; - params.push_back(parameters[0]); - params.push_back(parameters[1]); - /* Send it out remotely, generate no reply yet */ - - TreeServer* s = Utils->FindServerMask(parameters[1]); - if (s) - { - params[1] = s->GetName(); - Utils->DoOneToOne(user->uuid, "STATS", params, s->GetName()); - } - else - { - user->WriteServ( "402 %s %s :No such server", user->nick.c_str(), parameters[1].c_str()); - } - return MOD_RES_DENY; - } - return MOD_RES_PASSTHRU; -} - ModResult ModuleSpanningTree::OnStats(char statschar, User* user, string_list &results) { if ((statschar == 'c') || (statschar == 'n')) diff --git a/src/modules/m_spanningtree/override_time.cpp b/src/modules/m_spanningtree/override_time.cpp deleted file mode 100644 index 4cb0cc527..000000000 --- a/src/modules/m_spanningtree/override_time.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -/* $ModDesc: Provides a spanning tree server link protocol */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "treesocket.h" - -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ - -ModResult ModuleSpanningTree::HandleTime(const std::vector<std::string>& parameters, User* user) -{ - if ((IS_LOCAL(user)) && (parameters.size() > 0)) - { - TreeServer* found = Utils->FindServerMask(parameters[0].c_str()); - if (found) - { - // we dont' override for local server - if (found == Utils->TreeRoot) - return MOD_RES_PASSTHRU; - - parameterlist params; - params.push_back(found->GetName()); - params.push_back(user->uuid); - Utils->DoOneToOne(ServerInstance->Config->GetSID(),"TIME",params,found->GetName()); - } - else - { - user->WriteNumeric(ERR_NOSUCHSERVER, "%s %s :No such server",user->nick.c_str(),parameters[0].c_str()); - } - } - return MOD_RES_DENY; -} - diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp index 15456f276..806246056 100644 --- a/src/modules/m_spanningtree/precommand.cpp +++ b/src/modules/m_spanningtree/precommand.cpp @@ -34,14 +34,6 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std { return this->HandleConnect(parameters,user); } - else if (command == "STATS") - { - return this->HandleStats(parameters,user); - } - else if (command == "ADMIN") - { - return this->HandleAdmin(parameters,user); - } else if (command == "SQUIT") { return this->HandleSquit(parameters,user); @@ -50,10 +42,6 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std { return this->HandleMap(parameters,user) ? MOD_RES_DENY : MOD_RES_PASSTHRU; } - else if ((command == "TIME") && (parameters.size() > 0)) - { - return this->HandleTime(parameters,user); - } else if (command == "LINKS") { this->HandleLinks(parameters,user); diff --git a/src/modules/m_spanningtree/stats.cpp b/src/modules/m_spanningtree/stats.cpp deleted file mode 100644 index a30bb8118..000000000 --- a/src/modules/m_spanningtree/stats.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" -#include "socketengine.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "link.h" -#include "treesocket.h" - -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */ - -bool TreeSocket::Stats(const std::string &prefix, parameterlist ¶ms) -{ - /* Get the reply to a STATS query if it matches this servername, - * and send it back as a load of PUSH queries - */ - if (params.size() > 1) - { - if (InspIRCd::Match(ServerInstance->Config->ServerName, params[1])) - { - /* It's for our server */ - string_list results; - User* source = ServerInstance->FindNick(prefix); - if (source) - { - parameterlist par; - par.push_back(prefix); - par.push_back(""); - ServerInstance->DoStats(params[0][0], source, results); - for (size_t i = 0; i < results.size(); i++) - { - par[1] = "::" + results[i]; - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server); - } - } - } - else - { - /* Pass it on */ - User* source = ServerInstance->FindNick(prefix); - if (source) - Utils->DoOneToOne(source->uuid, "STATS", params, params[1]); - } - } - return true; -} - diff --git a/src/modules/m_spanningtree/time.cpp b/src/modules/m_spanningtree/time.cpp deleted file mode 100644 index 4f4373498..000000000 --- a/src/modules/m_spanningtree/time.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" -#include "socketengine.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "treesocket.h" - -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ - -bool TreeSocket::Time(const std::string &prefix, parameterlist ¶ms) -{ - // :source.server TIME remote.server sendernick - // :remote.server TIME source.server sendernick TS - if (params.size() == 2) - { - // someone querying our time? - if (ServerInstance->Config->ServerName == params[0] || ServerInstance->Config->GetSID() == params[0]) - { - User* u = ServerInstance->FindNick(params[1]); - if (u) - { - params.push_back(ConvToStr(ServerInstance->Time())); - params[0] = prefix; - Utils->DoOneToOne(ServerInstance->Config->GetSID(),"TIME",params,params[0]); - } - } - else - { - // not us, pass it on - User* u = ServerInstance->FindNick(params[1]); - if (u) - Utils->DoOneToOne(prefix,"TIME",params,params[0]); - } - } - else if (params.size() == 3) - { - // a response to a previous TIME - User* u = ServerInstance->FindNick(params[1]); - if ((u) && (IS_LOCAL(u))) - { - std::string sourceserv = Utils->FindServer(prefix)->GetName(); - time_t rawtime = atol(params[2].c_str()); - struct tm * timeinfo; - timeinfo = localtime(&rawtime); - char tms[26]; - snprintf(tms,26,"%s",asctime(timeinfo)); - tms[24] = 0; - u->WriteNumeric(RPL_TIME, "%s %s :%s",u->nick.c_str(),sourceserv.c_str(),tms); - } - else - { - if (u) - Utils->DoOneToOne(prefix,"TIME",params,u->server); - } - } - return true; -} - diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index a329f0ec0..1bd02762d 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -251,11 +251,6 @@ class TreeSocket : public BufferedSocket /** Handle ERROR command */ void Error(parameterlist ¶ms); - /** remote ADMIN. */ - bool Admin(const std::string &prefix, parameterlist ¶ms); - - bool Stats(const std::string &prefix, parameterlist ¶ms); - /** Remote AWAY */ bool Away(const std::string &prefix, parameterlist ¶ms); @@ -298,10 +293,6 @@ class TreeSocket : public BufferedSocket */ bool Push(const std::string &prefix, parameterlist ¶ms); - /** TIME - */ - bool Time(const std::string &prefix, parameterlist ¶ms); - /** PING */ bool LocalPing(const std::string &prefix, parameterlist ¶ms); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index d10ec612c..3f63da03d 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -290,15 +290,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, command = "MODE"; // TODO move all this into Commands - if (command == "STATS") - { - this->Stats(prefix, params); - } - else if (command == "ADMIN") - { - this->Admin(prefix, params); - } - else if (command == "MAP") + if (command == "MAP") { Utils->Creator->HandleMap(params, who); } @@ -356,10 +348,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, { this->Push(prefix,params); } - else if (command == "TIME") - { - this->Time(prefix,params); - } else if (command == "SQUIT") { if (params.size() == 2) |