]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change OnHookUserIO to OnHookIO, making it usable for more than User* and less picky...
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:48:23 +0000 (00:48 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:48:23 +0000 (00:48 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11628 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
include/usermanager.h
src/listensocket.cpp
src/modules.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/usermanager.cpp

index 3f36f23dad90d8ae7402957c54b0c52e281a7ef3..f4a9b0fb6f2cacd308ac5d39c855e0df789d659d 100644 (file)
@@ -461,7 +461,7 @@ enum Implementation
        I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
        I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnUserList, I_OnPostCommand, I_OnPostJoin,
        I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
-       I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookUserIO,
+       I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
        I_OnHostCycle, I_OnPreRehash, I_OnModuleRehash,
        I_END
 };
@@ -1313,7 +1313,11 @@ class CoreExport Module : public Extensible
         */
        virtual int OnDelBan(User* source, Channel* channel,const std::string &banmask);
 
-       virtual void OnHookUserIO(User* user);
+       /** Called to install an I/O hook on an event handler
+        * @param user The item to possibly install the I/O hook on
+        * @param via The port that <user> connected on
+        */
+       virtual void OnHookIO(EventHandler* user, ListenSocketBase* via);
 
        /** Called immediately after any  connection is accepted. This is intended for raw socket
         * processing (e.g. modules which wrap the tcp connection within another library) and provides
index 56a5453534839ce7da7b25488175af226426da81..72b10b224dc538bfc4de3f2fee1cfca18b4f90ab 100644 (file)
@@ -75,12 +75,12 @@ class CoreExport UserManager : public Extensible
         * initialize it as not yet registered, and add it to the socket engine.
         * @param Instance a pointer to the server instance
         * @param socket The socket id (file descriptor) this user is on
-        * @param iscached This variable is reserved for future use
+        * @param via The socket that this user connected using
         * @param client The IP address and client port of the user
         * @param server The server IP address and port used by the user
         * @return This function has no return value, but a call to AddClient may remove the user.
         */
-       void AddUser(InspIRCd* Instance, int socket, bool iscached, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
+       void AddUser(InspIRCd* Instance, int socket, ClientListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
 
        /** Disconnect a user gracefully
         * @param user The user to remove
index ed99c2787926039df2b1e49cd2881f135e9e7816..663f912e63ec2b86fd14dd841668d5e83d88203f 100644 (file)
@@ -148,5 +148,5 @@ void ListenSocketBase::HandleEvent(EventType e, int err)
 
 void ClientListenSocket::OnAcceptReady(int nfd)
 {
-       ServerInstance->Users->AddUser(ServerInstance, nfd, false, &client, &server);
+       ServerInstance->Users->AddUser(ServerInstance, nfd, this, &client, &server);
 }
index ad7efdb06d70f1f670c9e4b47bdf6867d3862f98..701b76ae26975b578761cbd46e1190bbf4ca8107 100644 (file)
@@ -196,7 +196,7 @@ void                Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
 void           Module::OnRunTestSuite() { }
 void           Module::OnNamesListItem(User*, User*, Channel*, std::string&, std::string&) { }
 int            Module::OnNumeric(User*, unsigned int, const std::string&) { return 0; }
-void           Module::OnHookUserIO(User*) { }
+void           Module::OnHookIO(EventHandler*, ListenSocketBase*) { }
 bool           Module::OnHostCycle(User* user) { return false; }
 
 ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
index 1c90428b23434c861ea6cef8b4a1414701a0e3c1..7e3b62671cb462a34c936bfe108dd38692ec3aa6 100644 (file)
@@ -132,7 +132,7 @@ class ModuleSSLGnuTLS : public Module
                Implementation eventlist[] = { I_On005Numeric, I_OnRawSocketConnect, I_OnRawSocketAccept,
                        I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup,
                        I_OnBufferFlushed, I_OnRequest, I_OnUnloadModule, I_OnRehash, I_OnModuleRehash,
-                       I_OnPostConnect, I_OnEvent, I_OnHookUserIO };
+                       I_OnPostConnect, I_OnEvent, I_OnHookIO };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
                ServerInstance->AddCommand(&starttls);
@@ -346,9 +346,9 @@ class ModuleSSLGnuTLS : public Module
                output.append(" STARTTLS");
        }
 
-       virtual void OnHookUserIO(User* user)
+       virtual void OnHookIO(EventHandler* user, ListenSocketBase* lsb)
        {
-               if (!user->GetIOHook() && isin(user->GetServerIP(),user->GetServerPort(),listenports))
+               if (!user->GetIOHook() && isin(lsb->GetIP(),lsb->GetPort(),listenports))
                {
                        /* Hook the user with our module */
                        user->AddIOHook(this);
index 55b7d841620a2367ffdcf947132f55ab0ed0c82a..fc0de61f4a8d55e7bcd9869b1c49b6c4b9be90b3 100644 (file)
@@ -153,13 +153,13 @@ class ModuleSSLOpenSSL : public Module
                Implementation eventlist[] = { I_OnRawSocketConnect, I_OnRawSocketAccept,
                        I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup, I_On005Numeric,
                        I_OnBufferFlushed, I_OnRequest, I_OnUnloadModule, I_OnRehash, I_OnModuleRehash,
-                       I_OnPostConnect, I_OnHookUserIO };
+                       I_OnPostConnect, I_OnHookIO };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       virtual void OnHookUserIO(User* user)
+       virtual void OnHookIO(EventHandler* user, ListenSocketBase* lsb)
        {
-               if (!user->GetIOHook() && isin(user->GetServerIP(),user->GetServerPort(), listenports))
+               if (!user->GetIOHook() && isin(lsb->GetIP(),lsb->GetPort(),listenports))
                {
                        /* Hook the user with our module */
                        user->AddIOHook(this);
index f62daf8928beacddb38ac7c8871196fd073bf79a..a31ac086e8e728c260078dc4b8082a732fe2cbce 100644 (file)
@@ -18,7 +18,7 @@
 #include "bancache.h"
 
 /* add a client connection to the sockets list */
-void UserManager::AddUser(InspIRCd* Instance, int socket, bool iscached, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
+void UserManager::AddUser(InspIRCd* Instance, int socket, ClientListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
 {
        /* NOTE: Calling this one parameter constructor for User automatically
         * allocates a new UUID and places it in the hash_map.
@@ -40,7 +40,7 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, bool iscached, irc::so
        memcpy(&New->server_sa, server, sizeof(irc::sockets::sockaddrs));
 
        /* Give each of the modules an attempt to hook the user for I/O */
-       FOREACH_MOD_I(Instance, I_OnHookUserIO, OnHookUserIO(New));
+       FOREACH_MOD_I(Instance, I_OnHookIO, OnHookIO(New, via));
 
        if (New->GetIOHook())
        {