From 8754ef149a6747af6553cbf084678cdfb16681e4 Mon Sep 17 00:00:00 2001 From: om Date: Mon, 23 Jan 2006 14:50:07 +0000 Subject: Adding ability to unload module git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2858 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_ssl_gnutls.cpp | 42 +++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/modules/extra') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index b496b5706..f665af0d0 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -27,6 +27,15 @@ enum issl_status { ISSL_NONE, ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, ISSL_HANDSHAKEN, ISSL_CLOSING, ISSL_CLOSED }; +bool isin(int port, std::vector portlist) +{ + for(unsigned int i = 0; i < portlist.size(); i++) + if(portlist[i] == port) + return true; + + return false; +} + class issl_session { public: @@ -44,6 +53,8 @@ class ModuleSSL : public Module ServerConfig* SrvConf; ConfigReader* Conf; + CullList culllist; + std::vector listenports; int inbufsize; @@ -179,15 +190,40 @@ class ModuleSSL : public Module gnutls_global_deinit(); } + virtual void OnCleanup(int target_type, void* item) + { + if(target_type == TYPE_USER) + { + userrec* user = (userrec*)item; + + if(user->GetExt("ssl") && isin(user->port, listenports)) + { + // User is using SSL, and they're using one of *our* SSL ports. + // Potentially there could be multiple SSL modules loaded at once on different ports. + culllist.AddItem(user, "SSL module unloading"); + } + } + } + + virtual void OnUnloadModule(Module* mod, std::string name) + { + if(mod == this) + { + // We're being unloaded, kill all the users added to the cull list in OnCleanup + int numusers = culllist.Apply(); + log(DEBUG, "m_ssl_gnutls.so: Killed %d users for unload of GnuTLS SSL module", numusers); + } + } + virtual Version GetVersion() { - return Version(1, 0, 0, 0, VF_STATIC | VF_VENDOR); + return Version(1, 0, 0, 0, VF_VENDOR); } void Implements(char* List) { - List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = 1; - List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUserQuit] = List[I_OnRehash] = List[I_OnWhois] = 1; + List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1; + List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = 1; } virtual void OnRawSocketAccept(int fd, std::string ip, int localport) -- cgit v1.2.3