From 9ee588b23fd915255d2cea0c537e6938297dbe5b Mon Sep 17 00:00:00 2001 From: danieldg Date: Mon, 18 Jan 2010 17:35:55 +0000 Subject: PreCommand/PostCommand are local-only hooks git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12291 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 8 +++----- src/modules.cpp | 4 ++-- src/modules/m_abbreviation.cpp | 2 +- src/modules/m_alias.cpp | 2 +- src/modules/m_antibear.cpp | 2 +- src/modules/m_antibottler.cpp | 2 +- src/modules/m_blockamsg.cpp | 2 +- src/modules/m_conn_waitpong.cpp | 2 +- src/modules/m_filter.cpp | 4 ++-- src/modules/m_maphide.cpp | 2 +- src/modules/m_namesx.cpp | 2 +- src/modules/m_operlog.cpp | 2 +- src/modules/m_securelist.cpp | 2 +- src/modules/m_shun.cpp | 2 +- src/modules/m_spanningtree/main.h | 4 ++-- src/modules/m_spanningtree/postcommand.cpp | 2 +- src/modules/m_spanningtree/precommand.cpp | 2 +- src/modules/m_spanningtree/rconnect.cpp | 4 +--- src/modules/m_sqllog.cpp | 2 +- src/modules/m_sqloper.cpp | 2 +- src/modules/m_sslinfo.cpp | 2 +- src/modules/m_swhois.cpp | 2 +- src/modules/m_uhnames.cpp | 2 +- 23 files changed, 28 insertions(+), 32 deletions(-) (limited to 'src') 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 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&, User *, bool, const std::string&) { return MOD_RES_PASSTHRU; } -void Module::OnPostCommand(const std::string&, const std::vector&, User *, CmdResult, const std::string&) { } +ModResult Module::OnPreCommand(std::string&, std::vector&, LocalUser*, bool, const std::string&) { return MOD_RES_PASSTHRU; } +void Module::OnPostCommand(const std::string&, const std::vector&, 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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) { std::multimap::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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User* user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line); + ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) +ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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& parameters, User* user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector& 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& parameters, User *user, bool validated, const std::string &original_line); - void OnPostCommand(const std::string &command, const std::vector& parameters, User *user, CmdResult result, const std::string &original_line); + ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser *user, bool validated, const std::string &original_line); + void OnPostCommand(const std::string &command, const std::vector& 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& parameters, User *user, CmdResult result, const std::string &original_line) +void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector& 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& parameters, User *user, bool validated, const std::string &original_line) +ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector& 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& 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 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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector ¶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 ¶ms, User *user, CmdResult result, const std::string &original_line) + void OnPostCommand(const std::string &command, const std::vector ¶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 ¶meters, User *user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector ¶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, -- cgit v1.2.3