]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
PreCommand/PostCommand are local-only hooks
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 18 Jan 2010 17:35:55 +0000 (17:35 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 18 Jan 2010 17:35:55 +0000 (17:35 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12291 e03df62e-2008-0410-955e-edbf42e46eb7

25 files changed:
include/command_parse.h
include/modules.h
src/command_parse.cpp
src/modules.cpp
src/modules/m_abbreviation.cpp
src/modules/m_alias.cpp
src/modules/m_antibear.cpp
src/modules/m_antibottler.cpp
src/modules/m_blockamsg.cpp
src/modules/m_conn_waitpong.cpp
src/modules/m_filter.cpp
src/modules/m_maphide.cpp
src/modules/m_namesx.cpp
src/modules/m_operlog.cpp
src/modules/m_securelist.cpp
src/modules/m_shun.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/postcommand.cpp
src/modules/m_spanningtree/precommand.cpp
src/modules/m_spanningtree/rconnect.cpp
src/modules/m_sqllog.cpp
src/modules/m_sqloper.cpp
src/modules/m_sslinfo.cpp
src/modules/m_swhois.cpp
src/modules/m_uhnames.cpp

index 2b03ec9bd22be3b564351616faabe31bbd2e3bd4..bd778c3d2cd6f811af0d75ad698add77f2f3c1a1 100644 (file)
@@ -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
index 582e74275940a8f35b193c5f4280bd8e64fd198f..6ec1a8ad44e5f7009dd147a0449afb986c7d6577 100644 (file)
@@ -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
index 8d5bcbee41d59a8cdaf7dc861141d4e07d1de55d..61c23bf62533fed7c41690254899617c943c7a0f 100644 (file)
@@ -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;
index 22628ff0f1c5edc144527e3abcb203961d1e1e78..fab9e2955a50fa7d76c62e06580e92ba8aad2236 100644 (file)
@@ -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; }
index 7234b5bfc39740800e51810058046be967bf8f78..f0086ddcbc2c5736639f226626010239387fe9f4 100644 (file)
@@ -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> &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)
        {
                /* Command is already validated, has a length of 0, or last character is not a . */
                if (validated || command.empty() || *command.rbegin() != '.')
index 3bd6153eac8a2fdba77edcc44a72e28faa4ca999..c7f0da690ed8b9eb80cae4378f3b0afc51c91163 100644 (file)
@@ -135,7 +135,7 @@ class ModuleAlias : public Module
                return word;
        }
 
-       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)
        {
                std::multimap<irc::string, Alias>::iterator i, upperbound;
 
index b9e439d7a6a4c875431682cb4aaa07ff0b49fe3e..4288c6bfc0b3bf4cd9f889809d032c21bdeacaf7 100644 (file)
@@ -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> &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 (command == "NOTICE" && !validated && parameters.size() > 1 && bearExt.get(user))
                {
index 28a8f99745a69b69d9c5f8c8431c2fafe5670766..4f6451cccfeacfd67cbaa06441e0f73b8971f78e 100644 (file)
@@ -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> &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)
        {
                char data[MAXBUF];
                strlcpy(data,original_line.c_str(),MAXBUF);
index 600a8ac1d981705434bdca5f834a1793f8501798..281c991e3a2b9c6a7d271fc5539ff717817b5cdb 100644 (file)
@@ -86,7 +86,7 @@ class ModuleBlockAmsg : public Module
                        action = IBLOCK_KILLOPERS;
        }
 
-       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)
        {
                // Don't do anything with unregistered users, or remote ones.
                if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
index cf2787a2e916302c50d13e33fc66f977ca37a868..1b9301de5114c48b990bd7160c26bdc52c480fc0 100644 (file)
@@ -68,7 +68,7 @@ class ModuleWaitPong : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User* user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser* user, bool validated, const std::string &original_line)
        {
                if (command == "PONG")
                {
index 35aca62620ecfd7f41b65536518c2fdde3fa8380..69117ae5556b6f5c527a0aff935410988b1fb5e5 100644 (file)
@@ -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> &parameters, User *user, bool validated, const std::string &original_line);
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, 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> &parameters, User *user, bool validated, const std::string &original_line)
+ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
 {
        flags = 0;
        if (validated && IS_LOCAL(user))
index 4a7e1da7f16dc5988d40d984c06bd1e4d39023ef..299db381fe1079928cb8c819e9e633d25108cc6f 100644 (file)
@@ -32,7 +32,7 @@ class ModuleMapHide : public Module
                url = MyConf.ReadValue("security", "maphide", 0);
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
        {
                if (!IS_OPER(user) && !url.empty() && (command == "MAP" || command == "LINKS"))
                {
index 2dcf5b3d6aacd4ddecabfc98e5dbff5696b26d23..ec117e095d8265886d9df9f42fcc6e7459804da7 100644 (file)
@@ -41,7 +41,7 @@ class ModuleNamesX : public Module
                output.append(" NAMESX");
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, 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,
index b7f84af3cfd821b82dbcf3a8e922badfb27c609b..252042ba010ef39d25945b87cd4dbdb830c61b76 100644 (file)
@@ -36,7 +36,7 @@ class ModuleOperLog : 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 the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
index 60cf9d4507d1ce998994ca008ed9c15740af9435..69cb8e58ff50b690bb6eb32d74192c35488c9bd2 100644 (file)
@@ -52,7 +52,7 @@ class ModuleSecureList : public Module
         * OnPreCommand()
         *   Intercept the LIST command.
         */
-       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 the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
index e07c2cd8d541961ff0b89d2127c273380bcf795e..8dc482ccfd2076f0e3329c70758ae696f0db0637 100644 (file)
@@ -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;
index a47b3762232ad3937540b7e0c040b1501b1d096b..3997c148c082c86dbce2514f8d33934e0bd1d60d 100644 (file)
@@ -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);
index d8cb5081dc55bc2a4cf22e7740ea09ffe263ba18..04bc6898b0fc48fc3974891f835d79de07e39ee9 100644 (file)
@@ -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);
index 25fab76fc10ee0eb0cdb55c6e26d1fb868a6acf8..dbef35cb7a40ac25173d720bfb3eeb2de69be4ca 100644 (file)
@@ -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)
index 460f8567420c815ad9d19dfc8beba431c57b5f3d..3def610cae7ebc88ac2f3d152bd9bf54861f78f9 100644 (file)
@@ -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;
 }
index bf8e1a21b39641f0c1609c2c3007481d2f7caa43..30f0c6b1039c1f1208f9ffbcf1cb8ba67584c62c 100644 (file)
@@ -232,7 +232,7 @@ class ModuleSQLLog : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       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 ((command == "GLINE" || command == "KLINE" || command == "ELINE" || command == "ZLINE") && validated)
                {
index 6421f3dd4bbcac92c0489c954c66a6ca9a3f82eb..b4cdc760a2345a8ab5d4fa2f4df49da75bd4223c 100644 (file)
@@ -67,7 +67,7 @@ public:
                hashtype = Conf.ReadValue("sqloper", "hash", 0);
        }
 
-       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) && (command == "OPER"))
                {
index 3138fcdc55e07f929fd929cda111151a09470959..0fddd8bf2329cea1d1d4929ad0c8340a7bc7ebeb 100644 (file)
@@ -158,7 +158,7 @@ class ModuleSSLInfo : public Module
                return false;
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
        {
                irc::string pcmd = command.c_str();
 
index db8bb32a9265890807d249e881a813eb951dd6f5..80c530d3b93ab29d679ead2aa752982367711848 100644 (file)
@@ -100,7 +100,7 @@ class ModuleSWhois : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       void OnPostCommand(const std::string &command, const std::vector<std::string> &params, User *user, CmdResult result, const std::string &original_line)
+       void OnPostCommand(const std::string &command, const std::vector<std::string> &params, LocalUser *user, CmdResult result, const std::string &original_line)
        {
                if ((command != "OPER") || (result != CMD_SUCCESS))
                        return;
index c1bdb684cc5f0bc1fc6b75845358949b52e8c602..30508fab23787acd845e074625b4206277f6b2e8 100644 (file)
@@ -41,7 +41,7 @@ class ModuleUHNames : public Module
                output.append(" UHNAMES");
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, 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,