diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-18 17:35:55 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-18 17:35:55 +0000 |
commit | 9ee588b23fd915255d2cea0c537e6938297dbe5b (patch) | |
tree | 4148f2f9b48a557fd7464b2b0d54887f62cd6bf3 | |
parent | 9b213d701dd4780762c64b14b8ebb92f3c5a0975 (diff) |
PreCommand/PostCommand are local-only hooks
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12291 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/command_parse.h | 10 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/command_parse.cpp | 8 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_abbreviation.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_antibear.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_antibottler.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_blockamsg.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_conn_waitpong.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_maphide.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_securelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/precommand.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/rconnect.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_sqllog.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sqloper.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sslinfo.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_uhnames.cpp | 2 |
25 files changed, 32 insertions, 42 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index 2b03ec9bd..bd778c3d2 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -41,7 +41,7 @@ class CoreExport CommandParser * @param user The user to parse the command for * @param cmd The command string to process */ - bool ProcessCommand(User *user, std::string &cmd); + bool ProcessCommand(LocalUser *user, std::string &cmd); @@ -111,13 +111,7 @@ class CoreExport CommandParser * @param buffer The buffer line to process * @param user The user to whom this line belongs */ - bool ProcessBuffer(std::string &buffer,User *user); - - /** Process lines in a users sendq. - * @param current The user to process - * @param one_only if one_only is set only one command is processed from the sendq. - */ - void DoLines(User* current, bool one_only = false); + bool ProcessBuffer(std::string &buffer,LocalUser *user); /** Add a new command to the commands hash * @param f The new Command to add to the list diff --git a/include/modules.h b/include/modules.h index 582e74275..6ec1a8ad4 100644 --- a/include/modules.h +++ b/include/modules.h @@ -946,7 +946,7 @@ class CoreExport Module : public classbase, public usecountbase * @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, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *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, @@ -960,7 +960,7 @@ class CoreExport Module : public classbase, public usecountbase * @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 std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line); + virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *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/command_parse.cpp b/src/command_parse.cpp index 8d5bcbee4..61c23bf62 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -179,7 +179,7 @@ CmdResult CommandParser::CallHandler(const std::string &commandname, const std:: return CMD_INVALID; } -bool CommandParser::ProcessCommand(User *user, std::string &cmd) +bool CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) { std::vector<std::string> command_p; irc::tokenstream tokens(cmd); @@ -282,9 +282,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) return true; /* activity resets the ping pending timer */ - LocalUser* luser = IS_LOCAL(user); - if (luser) - luser->nping = ServerInstance->Time() + luser->MyClass->GetPingTime(); + user->nping = ServerInstance->Time() + user->MyClass->GetPingTime(); if (cm->second->flags_needed) { @@ -362,7 +360,7 @@ Command::~Command() ServerInstance->Parser->RemoveCommand(this); } -bool CommandParser::ProcessBuffer(std::string &buffer,User *user) +bool CommandParser::ProcessBuffer(std::string &buffer,LocalUser *user) { if (!user || buffer.empty()) return true; diff --git a/src/modules.cpp b/src/modules.cpp index 22628ff0f..fab9e2955 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -99,8 +99,8 @@ ModResult Module::OnKill(User*, User*, const std::string&) { return MOD_RES_PASS void Module::OnLoadModule(Module*) { } void Module::OnUnloadModule(Module*) { } void Module::OnBackgroundTimer(time_t) { } -ModResult Module::OnPreCommand(std::string&, std::vector<std::string>&, User *, bool, const std::string&) { return MOD_RES_PASSTHRU; } -void Module::OnPostCommand(const std::string&, const std::vector<std::string>&, User *, CmdResult, const std::string&) { } +ModResult Module::OnPreCommand(std::string&, std::vector<std::string>&, LocalUser*, bool, const std::string&) { return MOD_RES_PASSTHRU; } +void Module::OnPostCommand(const std::string&, const std::vector<std::string>&, LocalUser*, CmdResult, const std::string&) { } ModResult Module::OnCheckReady(LocalUser*) { return MOD_RES_PASSTHRU; } ModResult Module::OnUserRegister(LocalUser*) { return MOD_RES_PASSTHRU; } ModResult Module::OnUserPreKick(User*, Membership*, const std::string&) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index 7234b5bfc..f0086ddcb 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -32,7 +32,7 @@ class ModuleAbbreviation : public Module return Version("Provides the ability to abbreviate commands a-la BBC BASIC keywords.",VF_VENDOR); } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { /* 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 3bd6153ea..c7f0da690 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -135,7 +135,7 @@ class ModuleAlias : public Module return word; } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { std::multimap<irc::string, Alias>::iterator i, upperbound; diff --git a/src/modules/m_antibear.cpp b/src/modules/m_antibear.cpp index b9e439d7a..4288c6bfc 100644 --- a/src/modules/m_antibear.cpp +++ b/src/modules/m_antibear.cpp @@ -36,7 +36,7 @@ class ModuleAntiBear : public Module return Version("Sends a numeric on connect which cripples a common type of trojan/spambot",VF_VENDOR); } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { if (command == "NOTICE" && !validated && parameters.size() > 1 && bearExt.get(user)) { diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index 28a8f9974..4f6451ccc 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -36,7 +36,7 @@ class ModuleAntiBottler : public Module return Version("Changes the ident of connecting bottler clients to 'bottler'",VF_VENDOR); } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { char data[MAXBUF]; strlcpy(data,original_line.c_str(),MAXBUF); diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index 600a8ac1d..281c991e3 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -86,7 +86,7 @@ class ModuleBlockAmsg : public Module action = IBLOCK_KILLOPERS; } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *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_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index cf2787a2e..1b9301de5 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -68,7 +68,7 @@ class ModuleWaitPong : public Module return MOD_RES_PASSTHRU; } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User* user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser* user, bool validated, const std::string &original_line) { if (command == "PONG") { diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 35aca6262..69117ae55 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -155,7 +155,7 @@ class ModuleFilter : public Module void OnSyncNetwork(Module* proto, void* opaque); void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata); ModResult OnStats(char symbol, User* user, string_list &results); - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line); + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line); bool AppliesToMe(User* user, FilterResult* filter, int flags); void ReadFilters(ConfigReader &MyConf); }; @@ -339,7 +339,7 @@ ModResult ModuleFilter::OnUserPreNotice(User* user,void* dest,int target_type, s return MOD_RES_PASSTHRU; } -ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) +ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { flags = 0; if (validated && IS_LOCAL(user)) diff --git a/src/modules/m_maphide.cpp b/src/modules/m_maphide.cpp index 4a7e1da7f..299db381f 100644 --- a/src/modules/m_maphide.cpp +++ b/src/modules/m_maphide.cpp @@ -32,7 +32,7 @@ class ModuleMapHide : public Module url = MyConf.ReadValue("security", "maphide", 0); } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { if (!IS_OPER(user) && !url.empty() && (command == "MAP" || command == "LINKS")) { diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 2dcf5b3d6..ec117e095 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -41,7 +41,7 @@ class ModuleNamesX : public Module output.append(" NAMESX"); } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *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 b7f84af3c..252042ba0 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -36,7 +36,7 @@ class ModuleOperLog : public Module } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *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 60cf9d450..69cb8e58f 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. */ - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *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_shun.cpp b/src/modules/m_shun.cpp index e07c2cd8d..8dc482ccf 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -251,7 +251,7 @@ class ModuleShun : public Module } } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string &original_line) { if (validated) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index a47b37622..3997c148c 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -154,8 +154,8 @@ class ModuleSpanningTree : public Module ** *** MODULE EVENTS *** **/ - ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); - void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line); + ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line); + void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line); void OnGetServerDescription(const std::string &servername,std::string &description); void OnUserConnect(LocalUser* source); void OnUserInvite(User* source,User* dest,Channel* channel, time_t); diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index d8cb5081d..04bc6898b 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -24,7 +24,7 @@ /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ -void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line) +void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line) { 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 25fab76fc..dbef35cb7 100644 --- a/src/modules/m_spanningtree/precommand.cpp +++ b/src/modules/m_spanningtree/precommand.cpp @@ -24,7 +24,7 @@ /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ -ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line) +ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *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/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 460f85674..3def610ca 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -49,9 +49,7 @@ CmdResult CommandRConnect::Handle (const std::vector<std::string>& parameters, U ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick.c_str(),parameters[0].c_str(),parameters[1].c_str()); std::vector<std::string> para; para.push_back(parameters[1]); - std::string cmd("CONNECT"); - std::string original_command = cmd + " " + parameters[1]; - creator->OnPreCommand(cmd, para, user, true, original_command); + ((ModuleSpanningTree*)(Module*)creator)->HandleConnect(para, user); } return CMD_SUCCESS; } diff --git a/src/modules/m_sqllog.cpp b/src/modules/m_sqllog.cpp index bf8e1a21b..30f0c6b10 100644 --- a/src/modules/m_sqllog.cpp +++ b/src/modules/m_sqllog.cpp @@ -232,7 +232,7 @@ class ModuleSQLLog : public Module return MOD_RES_PASSTHRU; } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { if ((command == "GLINE" || command == "KLINE" || command == "ELINE" || command == "ZLINE") && validated) { diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 6421f3dd4..b4cdc760a 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -67,7 +67,7 @@ public: hashtype = Conf.ReadValue("sqloper", "hash", 0); } - virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { if ((validated) && (command == "OPER")) { diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 3138fcdc5..0fddd8bf2 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -158,7 +158,7 @@ class ModuleSSLInfo : public Module return false; } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { irc::string pcmd = command.c_str(); diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index db8bb32a9..80c530d3b 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -100,7 +100,7 @@ class ModuleSWhois : public Module return MOD_RES_PASSTHRU; } - void OnPostCommand(const std::string &command, const std::vector<std::string> ¶ms, User *user, CmdResult result, const std::string &original_line) + void OnPostCommand(const std::string &command, const std::vector<std::string> ¶ms, LocalUser *user, CmdResult result, const std::string &original_line) { if ((command != "OPER") || (result != CMD_SUCCESS)) return; diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp index c1bdb684c..30508fab2 100644 --- a/src/modules/m_uhnames.cpp +++ b/src/modules/m_uhnames.cpp @@ -41,7 +41,7 @@ class ModuleUHNames : public Module output.append(" UHNAMES"); } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *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, |