diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-03-24 15:13:17 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-03-24 15:13:17 +0000 |
commit | 343f12b9b2d4e519b09877f76a00f6a0714509f2 (patch) | |
tree | b51aee0ca78a19fd356cdc2788cab4530c7928c1 /src/modules/extra | |
parent | 638381c529a2f19c699718234d689e54ad459c97 (diff) |
Add stuff so that modules can hook users by altering a pointer in the User class. Note that ssl modules still bind by port, but the idea of doing this change is so we can remove that logic next
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9187 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra')
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 27 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 15 |
2 files changed, 29 insertions, 13 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 78d9c785a..f3af386ae 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -78,15 +78,9 @@ class CommandStartTLS : public Command if (!user->GetExt("tls")) return CMD_FAILURE; - for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++) - { - if (ServerInstance->Config->ports[i]->GetDescription() == "ssl") - { - Caller->OnRawSocketAccept(user->GetFd(), user->GetIPString(), ServerInstance->Config->ports[i]->GetPort()); - user->SetSockAddr(user->GetProtocolFamily(), user->GetIPString(), ServerInstance->Config->ports[i]->GetPort()); - break; - } - } + user->io = Caller; + Caller->OnRawSocketAccept(user->GetFd(), user->GetIPString(), ServerInstance->Config->ports[i]->GetPort()); + return CMD_FAILURE; } }; @@ -142,8 +136,8 @@ class ModuleSSLGnuTLS : public Module // Void return, guess we assume success gnutls_certificate_set_dh_params(x509_cred, dh_params); Implementation eventlist[] = { I_On005Numeric, I_OnRawSocketConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup, - I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect, I_OnEvent }; - ServerInstance->Modules->Attach(eventlist, this, 16); + I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect, I_OnEvent, I_OnHookUserIO }; + ServerInstance->Modules->Attach(eventlist, this, 17); starttls = new CommandStartTLS(ServerInstance, this); ServerInstance->AddCommand(starttls); @@ -303,6 +297,8 @@ class ModuleSSLGnuTLS : public Module delete tofree; user->Shrink("ssl_cert"); } + + user->io = NULL; } } @@ -331,6 +327,15 @@ class ModuleSSLGnuTLS : public Module output.append(" SSL=" + sslports); } + virtual void OnHookUserIO(User* user) + { + if (!user->io && isin(user->GetPort(), listenports)) + { + /* Hook the user with our module */ + user->io = this; + } + } + virtual const char* OnRequest(Request* request) { ISHRequest* ISR = (ISHRequest*)request; diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 610565002..ba32c4013 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -150,8 +150,17 @@ class ModuleSSLOpenSSL : public Module // Needs the flag as it ignores a plain /rehash OnRehash(NULL,"ssl"); Implementation eventlist[] = { I_OnRawSocketConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup, I_On005Numeric, - I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect }; - ServerInstance->Modules->Attach(eventlist, this, 15); + I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect, I_OnHookUserIO }; + ServerInstance->Modules->Attach(eventlist, this, 16); + } + + virtual void OnHookUserIO(User* user) + { + if (!user->io && isin(user->GetPort(), listenports)) + { + /* Hook the user with our module */ + user->io = this; + } } virtual void OnRehash(User* user, const std::string ¶m) @@ -320,6 +329,8 @@ class ModuleSSLOpenSSL : public Module delete tofree; user->Shrink("ssl_cert"); } + + user->io = NULL; } } |