]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Document OnUserInit properly and add OnUserPostInit.
authorPeter Powell <petpow@saberuk.com>
Wed, 3 Apr 2019 14:25:00 +0000 (15:25 +0100)
committerPeter Powell <petpow@saberuk.com>
Thu, 4 Apr 2019 11:27:56 +0000 (12:27 +0100)
include/modules.h
src/modules.cpp
src/usermanager.cpp

index de418a785777971b74063b16a6aba5875a0a411a..ebb3c63b44ea6aa13110f41f817ed7ac278fa677 100644 (file)
@@ -216,7 +216,7 @@ enum Implementation
        I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper,
        I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick,
        I_OnUserPostMessage, I_OnUserMessageBlocked, I_OnMode,
-       I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit,
+       I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit, I_OnUserPostInit,
        I_OnChangeHost, I_OnChangeRealName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
        I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule,
        I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
@@ -722,11 +722,20 @@ class CoreExport Module : public classbase, public usecountbase
         */
        virtual void OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, bool loop);
 
-       /** Called when a user is first connecting, prior to starting DNS lookups, checking initial
-        * connect class, or accepting any commands.
+       /** Called after a user object is initialised and added to the user list.
+        * When this is called the user has not their I/O hooks checked or had their initial
+        * connect class assigned and may not yet have a serialiser. You probably want to use
+        * the OnUserPostInit or OnUserSetIP hooks instead of this one.
+        * @param user The connecting user.
         */
        virtual void OnUserInit(LocalUser* user);
 
+       /** Called after a user object has had their I/O hooks checked, their initial connection
+        * class assigned, and had a serialiser set.
+        * @param user The connecting user.
+        */
+       virtual void OnUserPostInit(LocalUser* user);
+
        /** 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
         * state until all modules return true. For example a module which implements ident
index 66f424dcbdebc3f43a63630844b51b9d7113c6b6..690ff0feb5b4548e648ed8e503ed8649961bbff8 100644 (file)
@@ -102,6 +102,7 @@ void                Module::OnBackgroundTimer(time_t) { DetachEvent(I_OnBackgroundTimer); }
 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, bool) { DetachEvent(I_OnPostCommand); }
 void           Module::OnUserInit(LocalUser*) { DetachEvent(I_OnUserInit); }
+void           Module::OnUserPostInit(LocalUser*) { DetachEvent(I_OnUserPostInit); }
 ModResult      Module::OnCheckReady(LocalUser*) { DetachEvent(I_OnCheckReady); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnUserRegister(LocalUser*) { DetachEvent(I_OnUserRegister); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnUserPreKick(User*, Membership*, const std::string&) { DetachEvent(I_OnUserPreKick); return MOD_RES_PASSTHRU; }
index 40e0096a26a285f74a638315381e61c073aeccb6..fafeffb42bce7e55355ea2d59f1b7d0914c43561 100644 (file)
@@ -210,8 +210,8 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
                New->WriteNotice("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
 
        FOREACH_MOD(OnSetUserIP, (New));
-       if (New->quitting)
-               return;
+       if (!New->quitting)
+               FOREACH_MOD(OnUserPostInit, (New));
 }
 
 void UserManager::QuitUser(User* user, const std::string& quitreason, const std::string* operreason)