]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ssl_openssl.cpp
Change this to use our md5 provider rather than MD5() in the query
[user/henk/code/inspircd.git] / src / modules / extra / m_ssl_openssl.cpp
index 06708ff5483f2c5b7ed88128a6f75adad39779a6..f46f04988c96da37e7c5849356cbeb1588287b8b 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #include <string>
 #include <vector>
 
 #include "hashcomp.h"
 #include "inspircd.h"
 
-#include "ssl.h"
+#include "transport.h"
 
 /* $ModDesc: Provides SSL support for clients */
 /* $CompileFlags: `perl extra/openssl_config.pl compile` */
 /* $LinkerFlags: `perl extra/openssl_config.pl link` */
-/* $ModDep: ssl.h */
-
+/* $ModDep: transport.h */
 
 enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_OPEN };
 enum issl_io_status { ISSL_WRITE, ISSL_READ };
@@ -121,10 +133,10 @@ class ModuleSSLOpenSSL : public Module
                SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);
 
                // Needs the flag as it ignores a plain /rehash
-               OnRehash("ssl");
+               OnRehash(NULL,"ssl");
        }
        
-       virtual void OnRehash(const std::string &param)
+       virtual void OnRehash(userrec* user, const std::string &param)
        {
                if (param != "ssl")
                        return;
@@ -152,6 +164,9 @@ class ModuleSSLOpenSSL : public Module
                                        if (ServerInstance->Config->AddIOHook(portno, this))
                                        {
                                                listenports.push_back(portno);
+                                               for (unsigned int i = 0; i < ServerInstance->stats->BoundPortCount; i++)
+                                                       if (ServerInstance->Config->ports[i] == portno)
+                                                               ServerInstance->Config->openSockfd[i]->SetDescription("ssl");
                                                ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", portno);
                                        }
                                        else
@@ -278,7 +293,13 @@ class ModuleSSLOpenSSL : public Module
                        ServerInstance->Log(DEBUG, "m_ssl_openssl.so: Killed %d users for unload of OpenSSL SSL module", numusers);
                        
                        for(unsigned int i = 0; i < listenports.size(); i++)
+                       {
                                ServerInstance->Config->DelIOHook(listenports[i]);
+                               for (unsigned int j = 0; j < ServerInstance->stats->BoundPortCount; j++)
+                                       if (ServerInstance->Config->ports[j] == listenports[i])
+                                               if (ServerInstance->Config->openSockfd[j])
+                                                       ServerInstance->Config->openSockfd[j]->SetDescription("plaintext");
+                       }
                }
        }
        
@@ -303,14 +324,37 @@ class ModuleSSLOpenSSL : public Module
                }
                else if (strcmp("IS_HOOK", request->GetId()) == 0)
                {
-                       ServerInstance->Log(DEBUG, "Hooking socket %08x", ISR->Sock);
-                       return ServerInstance->Config->AddIOHook((Module*)this, (InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+                       char* ret = "OK";
+                       try
+                       {
+                               ret = ServerInstance->Config->AddIOHook((Module*)this, (InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+                       }
+                       catch (ModuleException &e)
+                       {
+                               return NULL;
+                       }
+
+                       return ret;
                }
                else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
                {
                        ServerInstance->Log(DEBUG, "Unhooking socket %08x", ISR->Sock);
                        return ServerInstance->Config->DelIOHook((InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
                }
+               else if (strcmp("IS_HSDONE", request->GetId()) == 0)
+               {
+                       issl_session* session = &sessions[ISR->Sock->GetFd()];
+                       return (session->status == ISSL_HANDSHAKING) ? NULL : (char*)"OK";
+               }
+               else if (strcmp("IS_ATTACH", request->GetId()) == 0)
+               {
+                       issl_session* session = &sessions[ISR->Sock->GetFd()];
+                       if (session)
+                       {
+                               VerifyCertificate(session, (InspSocket*)ISR->Sock);
+                               return "OK";
+                       }
+               }
                return NULL;
        }