summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-08-09 20:44:43 +0100
committerPeter Powell <petpow@saberuk.com>2018-08-10 13:55:32 +0100
commit213e4d9680e427bc16b94c0c1b627919cacb171b (patch)
tree16f4f36d2c7e7e227af5c10a2d1b054bb7488f6e
parent626003a7dcbb00d4344e3554a2e265792dbcc952 (diff)
Remove the original line parameter of On{Pre,Post}Command.
In the brave new world of message tags and alternate wire formats this is no longer something that is appropriate to expose. In reality it was only ever used by m_alias which now reconstitutes the command name and parameters into a RFC 1459-style message for whatever it needs to do.
-rw-r--r--include/modules.h6
-rw-r--r--src/command_parse.cpp10
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/m_abbreviation.cpp2
-rw-r--r--src/modules/m_alias.cpp17
-rw-r--r--src/modules/m_blockamsg.cpp2
-rw-r--r--src/modules/m_conn_waitpong.cpp2
-rw-r--r--src/modules/m_filter.cpp4
-rw-r--r--src/modules/m_ldapoper.cpp2
-rw-r--r--src/modules/m_maphide.cpp2
-rw-r--r--src/modules/m_namesx.cpp2
-rw-r--r--src/modules/m_operlog.cpp2
-rw-r--r--src/modules/m_securelist.cpp2
-rw-r--r--src/modules/m_shun.cpp2
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_spanningtree/precommand.cpp2
-rw-r--r--src/modules/m_sqloper.cpp4
-rw-r--r--src/modules/m_sslinfo.cpp2
-rw-r--r--src/modules/m_uhnames.cpp2
-rw-r--r--src/users.cpp4
21 files changed, 46 insertions, 33 deletions
diff --git a/include/modules.h b/include/modules.h
index 44cda7d19..773e3b49f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -717,10 +717,9 @@ class CoreExport Module : public classbase, public usecountbase
* @param user the user issuing the command
* @param validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc.
* You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs).
- * @param original_line The entire original line as passed to the parser from the user
* @return 1 to block the command, 0 to allow
*/
- virtual ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line);
+ virtual ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated);
/** Called after any command has been executed.
* This event occurs for all registered commands, wether they are registered in the core,
@@ -731,9 +730,8 @@ class CoreExport Module : public classbase, public usecountbase
* @param parameters An array of array of characters containing the parameters for the command
* @param user the user issuing the command
* @param result The return code given by the command handler, one of CMD_SUCCESS or CMD_FAILURE
- * @param original_line The entire original line as passed to the parser from the user
*/
- virtual void OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, const std::string& original_line);
+ virtual void OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result);
/** Called when a user is first connecting, prior to starting DNS lookups, checking initial
* connect class, or accepting any commands.
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 1ead005c4..97980112e 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -99,7 +99,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const CommandBase::Pa
// Run the OnPostCommand hook with the last parameter (original line) being empty
// to indicate that the command had more targets in its original form.
item.clear();
- FOREACH_MOD(OnPostCommand, (handler, new_parameters, localuser, result, item));
+ FOREACH_MOD(OnPostCommand, (handler, new_parameters, localuser, result));
}
}
}
@@ -202,7 +202,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
if (!handler)
{
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false, cmd));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false));
if (MOD_RESULT == MOD_RES_DENY)
return;
@@ -256,7 +256,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
* truncate to max_params if necessary. -- w00t
*/
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false, cmd));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false));
if (MOD_RESULT == MOD_RES_DENY)
return;
@@ -322,7 +322,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
handler->use_count++;
/* module calls too */
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, true, cmd));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, true));
if (MOD_RESULT == MOD_RES_DENY)
return;
@@ -331,7 +331,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
*/
CmdResult result = handler->Handle(user, command_p);
- FOREACH_MOD(OnPostCommand, (handler, command_p, user, result, cmd));
+ FOREACH_MOD(OnPostCommand, (handler, command_p, user, result));
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 8b348d416..56ed3c828 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -94,8 +94,8 @@ ModResult Module::OnKill(User*, User*, const std::string&) { DetachEvent(I_OnKil
void Module::OnLoadModule(Module*) { DetachEvent(I_OnLoadModule); }
void Module::OnUnloadModule(Module*) { DetachEvent(I_OnUnloadModule); }
void Module::OnBackgroundTimer(time_t) { DetachEvent(I_OnBackgroundTimer); }
-ModResult Module::OnPreCommand(std::string&, CommandBase::Params&, LocalUser*, bool, const std::string&) { DetachEvent(I_OnPreCommand); return MOD_RES_PASSTHRU; }
-void Module::OnPostCommand(Command*, const CommandBase::Params&, LocalUser*, CmdResult, const std::string&) { DetachEvent(I_OnPostCommand); }
+ModResult Module::OnPreCommand(std::string&, CommandBase::Params&, LocalUser*, bool) { DetachEvent(I_OnPreCommand); return MOD_RES_PASSTHRU; }
+void Module::OnPostCommand(Command*, const CommandBase::Params&, LocalUser*, CmdResult) { DetachEvent(I_OnPostCommand); }
void Module::OnUserInit(LocalUser*) { DetachEvent(I_OnUserInit); }
ModResult Module::OnCheckReady(LocalUser*) { DetachEvent(I_OnCheckReady); return MOD_RES_PASSTHRU; }
ModResult Module::OnUserRegister(LocalUser*) { DetachEvent(I_OnUserRegister); return MOD_RES_PASSTHRU; }
diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp
index 22baa916b..f5065c73f 100644
--- a/src/modules/m_abbreviation.cpp
+++ b/src/modules/m_abbreviation.cpp
@@ -38,7 +38,7 @@ class ModuleAbbreviation : public Module
return Version("Provides the ability to abbreviate commands a-la BBC BASIC keywords.",VF_VENDOR);
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* Command is already validated, has a length of 0, or last character is not a . */
if (validated || command.empty() || *command.rbegin() != '.')
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index a8e39cb47..433397123 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -129,7 +129,21 @@ class ModuleAlias : public Module
return word;
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ std::string CreateRFCMessage(const std::string& command, Command::Params& parameters)
+ {
+ std::string message(command);
+ for (CommandBase::Params::const_iterator iter = parameters.begin(); iter != parameters.end();)
+ {
+ const std::string& parameter = *++iter;
+ message.push_back(' ');
+ if (iter == parameters.end())
+ message.push_back(':');
+ message.append(parameter);
+ }
+ return message;
+ }
+
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* If theyre not registered yet, we dont want
* to know.
@@ -143,6 +157,7 @@ class ModuleAlias : public Module
return MOD_RES_PASSTHRU;
/* The parameters for the command in their original form, with the command stripped off */
+ std::string original_line = CreateRFCMessage(command, parameters);
std::string compare(original_line, command.length());
while (*(compare.c_str()) == ' ')
compare.erase(compare.begin());
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 3c8fcd1b5..c4af2fd7f 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -81,7 +81,7 @@ class ModuleBlockAmsg : public Module
action = IBLOCK_KILLOPERS;
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
// Don't do anything with unregistered users
if (user->registered != REG_ALL)
diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp
index f9e9262a7..b4441c88c 100644
--- a/src/modules/m_conn_waitpong.cpp
+++ b/src/modules/m_conn_waitpong.cpp
@@ -56,7 +56,7 @@ class ModuleWaitPong : public Module
return MOD_RES_PASSTHRU;
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if (command == "PONG")
{
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 343a62a8d..c039c0455 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -196,7 +196,7 @@ class ModuleFilter : public Module, public ServerEventListener, public Stats::Ev
void OnSyncNetwork(ProtocolInterface::Server& server) CXX11_OVERRIDE;
void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata) CXX11_OVERRIDE;
ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE;
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE;
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE;
void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
bool AppliesToMe(User* user, FilterResult* filter, int flags);
void ReadFilters();
@@ -413,7 +413,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
return MOD_RES_PASSTHRU;
}
-ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line)
+ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated)
{
if (validated)
{
diff --git a/src/modules/m_ldapoper.cpp b/src/modules/m_ldapoper.cpp
index 104c3bb21..094b37744 100644
--- a/src/modules/m_ldapoper.cpp
+++ b/src/modules/m_ldapoper.cpp
@@ -201,7 +201,7 @@ class ModuleLDAPAuth : public Module
attribute = tag->getString("attribute");
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if (validated && command == "OPER" && parameters.size() >= 2)
{
diff --git a/src/modules/m_maphide.cpp b/src/modules/m_maphide.cpp
index 7c5f6b97b..7a1ee39e1 100644
--- a/src/modules/m_maphide.cpp
+++ b/src/modules/m_maphide.cpp
@@ -28,7 +28,7 @@ class ModuleMapHide : public Module
url = ServerInstance->Config->ConfValue("security")->getString("maphide");
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if (validated && !user->IsOper() && !url.empty() && (command == "MAP" || command == "LINKS"))
{
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index 98fac8872..708b98e56 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -41,7 +41,7 @@ class ModuleNamesX : public Module
tokens["NAMESX"];
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* We don't actually create a proper command handler class for PROTOCTL,
* because other modules might want to have PROTOCTL hooks too.
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index 53bc247be..b64e18870 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -41,7 +41,7 @@ class ModuleOperLog : public Module
tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false);
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp
index b1aeeb9d4..aa14707b1 100644
--- a/src/modules/m_securelist.cpp
+++ b/src/modules/m_securelist.cpp
@@ -52,7 +52,7 @@ class ModuleSecureList : public Module
* OnPreCommand()
* Intercept the LIST command.
*/
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 267e15ad7..da090e4f8 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -198,7 +198,7 @@ class ModuleShun : public Module, public Stats::EventListener
affectopers = tag->getBool("affectopers", false);
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if (validated)
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 4479b0700..34b657720 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -142,8 +142,8 @@ class ModuleSpanningTree : public Module, public Stats::EventListener
** *** MODULE EVENTS ***
**/
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE;
- void OnPostCommand(Command*, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE;
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE;
+ void OnPostCommand(Command*, const CommandBase::Params& parameters, LocalUser* user, CmdResult result) CXX11_OVERRIDE;
void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE;
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index b50b5e852..c6bc04fc2 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -24,7 +24,7 @@
#include "treeserver.h"
#include "commandbuilder.h"
-void ModuleSpanningTree::OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, const std::string& original_line)
+void ModuleSpanningTree::OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result)
{
if (result == CMD_SUCCESS)
Utils->RouteCommand(NULL, command, parameters, user);
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index 0d5268493..5db8aafe3 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -22,7 +22,7 @@
#include "main.h"
-ModResult ModuleSpanningTree::OnPreCommand(std::string &command, CommandBase::Params& parameters, LocalUser *user, bool validated, const std::string &original_line)
+ModResult ModuleSpanningTree::OnPreCommand(std::string &command, CommandBase::Params& parameters, LocalUser *user, bool validated)
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index e126e584e..2b298f662 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -138,7 +138,7 @@ class OperQuery : public SQL::Query
ModResult MOD_RESULT;
std::string origin = "OPER";
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (origin, params, localuser, true, origin));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (origin, params, localuser, true));
if (MOD_RESULT == MOD_RES_DENY)
return;
@@ -195,7 +195,7 @@ public:
}
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
// If we are not in the middle of an existing /OPER and someone is trying to oper-up
if (validated && command == "OPER" && parameters.size() >= 2 && !active)
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 7b73740db..6f679a871 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -179,7 +179,7 @@ class ModuleSSLInfo : public Module, public Whois::EventListener
}
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if ((command == "OPER") && (validated))
{
diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp
index 4165519fc..a8814b343 100644
--- a/src/modules/m_uhnames.cpp
+++ b/src/modules/m_uhnames.cpp
@@ -41,7 +41,7 @@ class ModuleUHNames : public Module
tokens["UHNAMES"];
}
- ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
/* We don't actually create a proper command handler class for PROTOCTL,
* because other modules might want to have PROTOCTL hooks too.
diff --git a/src/users.cpp b/src/users.cpp
index 5310c7c96..52e1f3e95 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -562,13 +562,13 @@ void LocalUser::FullConnect()
ModResult MOD_RESULT;
std::string command("LUSERS");
CommandBase::Params parameters;
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
if (!MOD_RESULT)
ServerInstance->Parser.CallHandler(command, parameters, this);
MOD_RESULT = MOD_RES_PASSTHRU;
command = "MOTD";
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
if (!MOD_RESULT)
ServerInstance->Parser.CallHandler(command, parameters, this);