diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-17 14:01:53 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-17 14:01:53 +0000 |
commit | 3a7dd5b129450b94e0a87b8ad5009da70905b8e5 (patch) | |
tree | ba05bf4834f03c4c1450ec83bd5b238d055b3d5f | |
parent | e166642755b17a56053d57dbd597e2fa38bb96c6 (diff) |
Add const std::string &original_command to OnPreCommand and OnPostCommand, which gives the entire untouched command string and params in all its colon-ny glory
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5265 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 6 | ||||
-rw-r--r-- | src/cmd_kill.cpp | 3 | ||||
-rw-r--r-- | src/cmd_quit.cpp | 18 | ||||
-rw-r--r-- | src/command_parse.cpp | 6 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_sqllog.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_sqloper.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_oper_cert.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_blockamsg.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_conn_lusers.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_conn_waitpong.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_namesx.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operlog.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_safelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_securelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 7 |
18 files changed, 40 insertions, 28 deletions
diff --git a/include/modules.h b/include/modules.h index c497155ad..95dbd764e 100644 --- a/include/modules.h +++ b/include/modules.h @@ -997,9 +997,10 @@ class Module : public Extensible * @param pcnt The nuimber of parameters passed to the command * @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. + * @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 int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated); + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line); /** Called after any command has been executed. * This event occurs for all registered commands, wether they are registered in the core, @@ -1011,8 +1012,9 @@ class Module : public Extensible * @param pcnt The nuimber of parameters passed to 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(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result); + virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line); /** Called to check if a user who is connecting can now be allowed to register * If any modules return false for this function, the user is held in the waiting diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp index 4d1a6d4ff..6f42c1b38 100644 --- a/src/cmd_kill.cpp +++ b/src/cmd_kill.cpp @@ -68,7 +68,8 @@ CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) if (u == user) { - FOREACH_MOD(I_OnPostCommand,OnPostCommand("KILL", parameters, pcnt, user, CMD_SUCCESS)); + std::string original_command = std::string("KILL ") + u->nick + " :"+parameters[1]; + FOREACH_MOD(I_OnPostCommand,OnPostCommand("KILL", parameters, pcnt, user, CMD_SUCCESS,original_command)); return CMD_USER_DELETED; } DELETE(u); diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index 41cc48c8e..26502c385 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -31,6 +31,7 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) { user_hash::iterator iter = ServerInstance->clientlist.find(user->nick); char reason[MAXBUF]; + std::string quitmsg = "Client exited"; if (user->registered == REG_ALL) { @@ -47,9 +48,11 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) */ if (IS_LOCAL(user)) { - user->Write("ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]); - ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]); - user->WriteCommonExcept("QUIT :%s%s",ServerInstance->Config->PrefixQuit,parameters[0]); + quitmsg = ServerInstance->Config->PrefixQuit; + quitmsg.append(parameters[0]); + user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,quitmsg.c_str()); + ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,quitmsg.c_str()); + user->WriteCommonExcept("QUIT :%s", quitmsg.c_str()); } else { @@ -63,7 +66,7 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) { if (IS_LOCAL(user)) { - user->Write("ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host); + user->Write("ERROR :Closing link (%s@%s) []",user->ident,user->host); ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host); } else @@ -100,7 +103,12 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) user->PurgeEmptyChannels(); } - FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS)); + if (IS_LOCAL(user)) + { + std::string original_command = "QUIT :" + quitmsg; + FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS, original_command)); + } + DELETE(user); return CMD_USER_DELETED; } diff --git a/src/command_parse.cpp b/src/command_parse.cpp index a158ff6a3..881e1abc7 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -327,7 +327,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) std::transform(command.begin(), command.end(), command.begin(), ::toupper); int MOD_RESULT = 0; - FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false)); + FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false,cmd)); if (MOD_RESULT == 1) { return; } @@ -374,7 +374,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) cm->second->total_bytes += cmd.length(); int MOD_RESULT = 0; - FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true)); + FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd)); if (MOD_RESULT == 1) return; @@ -387,7 +387,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) if (result != CMD_USER_DELETED) { - FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result)); + FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd)); } return; } diff --git a/src/modules.cpp b/src/modules.cpp index f5e83c093..db5a976c5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -131,8 +131,8 @@ int Module::OnKill(userrec* source, userrec* dest, const std::string &reason) { void Module::OnLoadModule(Module* mod,const std::string &name) { }; void Module::OnUnloadModule(Module* mod,const std::string &name) { }; void Module::OnBackgroundTimer(time_t curtime) { }; -int Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) { return 0; }; -void Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result) { }; +int Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { return 0; }; +void Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { }; bool Module::OnCheckReady(userrec* user) { return true; }; void Module::OnUserRegister(userrec* user) { }; int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; }; diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 62d4baeeb..c3130079c 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -353,7 +353,7 @@ class ModuleSQLLog : public Module return 0; } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { if ((command == "GLINE") || (command == "KLINE") || (command == "ELINE") || (command == "ZLINE")) { diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp index 867dab8a9..e36e97cae 100644 --- a/src/modules/extra/m_sqloper.cpp +++ b/src/modules/extra/m_sqloper.cpp @@ -65,7 +65,7 @@ public: List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1; } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { if (validated && (command == "OPER")) { diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp index 1f11e9b68..e441755fb 100644 --- a/src/modules/extra/m_ssl_oper_cert.cpp +++ b/src/modules/extra/m_ssl_oper_cert.cpp @@ -113,7 +113,7 @@ class ModuleOperSSLCert : public Module } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { irc::string cmd = command.c_str(); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index fd3dedff2..6a4eaf795 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -92,7 +92,7 @@ class ModuleAlias : public Module return Version(1,0,0,1,VF_VENDOR); } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { userrec *u = NULL; irc::string c = command.c_str(); diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index c0fb7651e..55f3d3829 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -95,7 +95,7 @@ public: DELETE(Conf); } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { // Don't do anything with unregistered users, or remote ones. if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user)) diff --git a/src/modules/m_conn_lusers.cpp b/src/modules/m_conn_lusers.cpp index bd444338e..2c4f8da41 100644 --- a/src/modules/m_conn_lusers.cpp +++ b/src/modules/m_conn_lusers.cpp @@ -66,7 +66,7 @@ class ModuleConnLUSERS : public Module Module* Proto = ServerInstance->FindModule("m_spanningtree.so"); if (Proto) { - Proto->OnPreCommand("LUSERS", NULL, 0, user, true); + Proto->OnPreCommand("LUSERS", NULL, 0, user, true, "LUSERS"); } else { diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index 937577c5e..346555a1d 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -79,7 +79,7 @@ class ModuleWaitPong : public Module user->Extend("waitpong_pingstr", pingrpl); } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec* user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec* user, bool validated, const std::string &original_line) { if(command == "PONG") { diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index e55e436ce..27bef92f5 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -53,7 +53,7 @@ class ModuleNamesX : public Module output.append(" NAMESX"); } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { irc::string c = command.c_str(); /* We don't actually create a proper command handler class for PROTOCTL, diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp index 062e81979..9b3028bd3 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -48,7 +48,7 @@ class ModuleOperLog : public Module List[I_OnPreCommand] = List[I_On005Numeric] = 1; } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int 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) diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index bb5121771..026b2798d 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -68,7 +68,7 @@ class ModuleOverride : public Module List[I_OnRehash] = List[I_OnAccessCheck] = List[I_On005Numeric] = List[I_OnUserPreJoin] = List[I_OnUserPreKick] = List[I_OnPostCommand] = 1; } - virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result) + virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { if ((NoisyOverride) && (OverriddenMode) && (irc::string(command.c_str()) == "MODE") && (result == CMD_SUCCESS)) { diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index ac7225b5e..28d4ebd85 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -169,7 +169,7 @@ class ModuleSafeList : public Module * OnPreCommand() * Intercept the LIST command. */ - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int 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) diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 14eb2aecf..f059c1038 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -53,7 +53,7 @@ class ModuleSecureList : public Module * OnPreCommand() * Intercept the LIST command. */ - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int 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) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 7555a027e..5b62697d7 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -601,7 +601,8 @@ class cmd_rconnect : public command_t ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]); const char* para[1]; para[0] = parameters[1]; - Creator->OnPreCommand("CONNECT", para, 1, user, true); + std::string original_command = std::string("CONNECT ") + parameters[1]; + Creator->OnPreCommand("CONNECT", para, 1, user, true, original_command); return CMD_SUCCESS; } @@ -4224,7 +4225,7 @@ class ModuleSpanningTree : public Module return 0; } - virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) + virtual int 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) @@ -4286,7 +4287,7 @@ class ModuleSpanningTree : public Module return 0; } - virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result) + virtual void 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))) { |