diff options
-rw-r--r-- | src/coremods/core_info/cmd_admin.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_info.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_modules.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_motd.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_time.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_info/core_info.cpp | 8 | ||||
-rw-r--r-- | src/coremods/core_info/core_info.h | 28 | ||||
-rw-r--r-- | src/coremods/core_stats.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_opermotd.cpp | 2 |
10 files changed, 34 insertions, 53 deletions
diff --git a/src/coremods/core_info/cmd_admin.cpp b/src/coremods/core_info/cmd_admin.cpp index 19037406b..f79ebc036 100644 --- a/src/coremods/core_info/cmd_admin.cpp +++ b/src/coremods/core_info/cmd_admin.cpp @@ -22,7 +22,7 @@ #include "core_info.h" CommandAdmin::CommandAdmin(Module* parent) - : Command(parent, "ADMIN", 0, 0) + : ServerTargetCommand(parent, "ADMIN") { Penalty = 2; syntax = "[<servername>]"; @@ -41,10 +41,3 @@ CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User user->WriteRemoteNumeric(RPL_ADMINEMAIL, InspIRCd::Format("E-Mail - %s", AdminEmail.c_str())); return CMD_SUCCESS; } - -RouteDescriptor CommandAdmin::GetRouting(User* user, const std::vector<std::string>& parameters) -{ - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; -} diff --git a/src/coremods/core_info/cmd_info.cpp b/src/coremods/core_info/cmd_info.cpp index e014fa4f2..3bf9db893 100644 --- a/src/coremods/core_info/cmd_info.cpp +++ b/src/coremods/core_info/cmd_info.cpp @@ -24,7 +24,7 @@ #include "core_info.h" CommandInfo::CommandInfo(Module* parent) - : Command(parent, "INFO") + : ServerTargetCommand(parent, "INFO") { Penalty = 4; syntax = "[<servername>]"; @@ -88,10 +88,3 @@ CmdResult CommandInfo::Handle (const std::vector<std::string>& parameters, User user->WriteRemoteNumeric(RPL_ENDOFINFO, "End of /INFO list"); return CMD_SUCCESS; } - -RouteDescriptor CommandInfo::GetRouting(User* user, const std::vector<std::string>& parameters) -{ - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; -} diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 16931e685..5f02d071f 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -23,7 +23,7 @@ #include "core_info.h" CommandModules::CommandModules(Module* parent) - : Command(parent, "MODULES", 0, 0) + : ServerTargetCommand(parent, "MODULES") { Penalty = 4; syntax = "[<servername>]"; @@ -80,10 +80,3 @@ CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, Us return CMD_SUCCESS; } - -RouteDescriptor CommandModules::GetRouting(User* user, const std::vector<std::string>& parameters) -{ - if (parameters.size() >= 1) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; -} diff --git a/src/coremods/core_info/cmd_motd.cpp b/src/coremods/core_info/cmd_motd.cpp index 4772f8d2c..cfb083eed 100644 --- a/src/coremods/core_info/cmd_motd.cpp +++ b/src/coremods/core_info/cmd_motd.cpp @@ -22,7 +22,7 @@ #include "core_info.h" CommandMotd::CommandMotd(Module* parent) - : Command(parent, "MOTD", 0, 1) + : ServerTargetCommand(parent, "MOTD") { syntax = "[<servername>]"; } @@ -61,10 +61,3 @@ CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } - -RouteDescriptor CommandMotd::GetRouting(User* user, const std::vector<std::string>& parameters) -{ - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; -} diff --git a/src/coremods/core_info/cmd_time.cpp b/src/coremods/core_info/cmd_time.cpp index a0b58efcc..6755e5837 100644 --- a/src/coremods/core_info/cmd_time.cpp +++ b/src/coremods/core_info/cmd_time.cpp @@ -22,7 +22,7 @@ #include "core_info.h" CommandTime::CommandTime(Module* parent) - : Command(parent, "TIME", 0, 0) + : ServerTargetCommand(parent, "TIME") { syntax = "[<servername>]"; } @@ -36,10 +36,3 @@ CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } - -RouteDescriptor CommandTime::GetRouting(User* user, const std::vector<std::string>& parameters) -{ - if (parameters.size() > 0) - return ROUTE_UNICAST(parameters[0]); - return ROUTE_LOCALONLY; -} diff --git a/src/coremods/core_info/core_info.cpp b/src/coremods/core_info/core_info.cpp index 56c3c956d..bd519076d 100644 --- a/src/coremods/core_info/core_info.cpp +++ b/src/coremods/core_info/core_info.cpp @@ -20,6 +20,14 @@ #include "inspircd.h" #include "core_info.h" +RouteDescriptor ServerTargetCommand::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + // Parameter must be a server name, not a nickname or uuid + if ((!parameters.empty()) && (parameters[0].find('.') != std::string::npos)) + return ROUTE_UNICAST(parameters[0]); + return ROUTE_LOCALONLY; +} + class CoreModInfo : public Module { CommandAdmin cmdadmin; diff --git a/src/coremods/core_info/core_info.h b/src/coremods/core_info/core_info.h index f5dd9e648..ecfeb4f36 100644 --- a/src/coremods/core_info/core_info.h +++ b/src/coremods/core_info/core_info.h @@ -21,9 +21,22 @@ #include "inspircd.h" +/** These commands require no parameters, but if there is a parameter it is a server name where the command will be routed to. + */ +class ServerTargetCommand : public Command +{ + public: + ServerTargetCommand(Module* mod, const std::string& Name) + : Command(mod, Name) + { + } + + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + /** Handle /ADMIN. */ -class CommandAdmin : public Command +class CommandAdmin : public ServerTargetCommand { public: /** Holds the admin's name, for output in @@ -51,7 +64,6 @@ 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); }; /** Handle /COMMANDS. @@ -73,7 +85,7 @@ class CommandCommands : public Command /** Handle /INFO. */ -class CommandInfo : public Command +class CommandInfo : public ServerTargetCommand { public: /** Constructor for info. @@ -86,12 +98,11 @@ class CommandInfo : 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); }; /** Handle /MODULES. */ -class CommandModules : public Command +class CommandModules : public ServerTargetCommand { public: /** Constructor for modules. @@ -104,12 +115,11 @@ class CommandModules : 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); }; /** Handle /MOTD. */ -class CommandMotd : public Command +class CommandMotd : public ServerTargetCommand { public: /** Constructor for motd. @@ -122,12 +132,11 @@ class CommandMotd : 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); }; /** Handle /TIME. */ -class CommandTime : public Command +class CommandTime : public ServerTargetCommand { public: /** Constructor for time. @@ -140,7 +149,6 @@ 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); }; /** Handle /VERSION. diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 69f1f3cf8..d890d19ea 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -44,7 +44,7 @@ class CommandStats : public Command CmdResult Handle(const std::vector<std::string>& parameters, User *user); RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { - if (parameters.size() > 1) + if ((parameters.size() > 1) && (parameters[1].find('.') != std::string::npos)) return ROUTE_UNICAST(parameters[1]); return ROUTE_LOCALONLY; } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index ef9507aa1..17eb9d9c5 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -301,7 +301,7 @@ class CommandCheck : public Command RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { - if (parameters.size() > 1) + if ((parameters.size() > 1) && (parameters[1].find('.') != std::string::npos)) return ROUTE_OPT_UCAST(parameters[1]); return ROUTE_LOCALONLY; } diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 010f4ae58..f6cb5853c 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -43,7 +43,7 @@ class CommandOpermotd : public Command RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { - if (!parameters.empty()) + if ((!parameters.empty()) && (parameters[0].find('.') != std::string::npos)) return ROUTE_OPT_UCAST(parameters[0]); return ROUTE_LOCALONLY; } |