]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ssl_openssl.cpp
Thanks dz, forgot uppercase equivalent of AEIOU in the strchr
[user/henk/code/inspircd.git] / src / modules / extra / m_ssl_openssl.cpp
index 1f5a71b10e61af9ee0da851708ef58c810e0d2f0..8e8b03b85014bc2d241e1858ab2622cc0928c532 100644 (file)
@@ -74,7 +74,7 @@ public:
        issl_io_status wstat;
 
        unsigned int inbufoffset;
-       char* inbuf;                    // Buffer OpenSSL reads into.
+       char* inbuf;                    // Buffer OpenSSL reads into.
        std::string outbuf;     // Buffer for outgoing data that OpenSSL will not take.
        int fd;
        bool outbound;
@@ -103,9 +103,6 @@ static int OnVerify(int preverify_ok, X509_STORE_CTX *ctx)
 
 class ModuleSSLOpenSSL : public Module
 {
-
-       ConfigReader* Conf;
-
        std::vector<int> listenports;
 
        int inbufsize;
@@ -131,9 +128,9 @@ class ModuleSSLOpenSSL : public Module
        InspIRCd* PublicInstance;
 
        ModuleSSLOpenSSL(InspIRCd* Me)
-               : Module(Me), PublicInstance(Me)
+       : Module(Me), PublicInstance(Me)
        {
-               ServerInstance->PublishInterface("InspSocketHook", this);
+               ServerInstance->Modules->PublishInterface("InspSocketHook", this);
 
                // Not rehashable...because I cba to reduce all the sizes of existing buffers.
                inbufsize = ServerInstance->Config->NetBufferSize;
@@ -160,7 +157,7 @@ class ModuleSSLOpenSSL : public Module
                if (param != "ssl")
                        return;
 
-               Conf = new ConfigReader(ServerInstance);
+               ConfigReader Conf(ServerInstance);
 
                for (unsigned int i = 0; i < listenports.size(); i++)
                {
@@ -171,14 +168,14 @@ class ModuleSSLOpenSSL : public Module
                clientactive = 0;
                sslports.clear();
 
-               for (int i = 0; i < Conf->Enumerate("bind"); i++)
+               for (int i = 0; i < Conf.Enumerate("bind"); i++)
                {
                        // For each <bind> tag
-                       std::string x = Conf->ReadValue("bind", "type", i);
-                       if (((x.empty()) || (x == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "openssl"))
+                       std::string x = Conf.ReadValue("bind", "type", i);
+                       if (((x.empty()) || (x == "clients")) && (Conf.ReadValue("bind", "ssl", i) == "openssl"))
                        {
                                // Get the port we're meant to be listening on with SSL
-                               std::string port = Conf->ReadValue("bind", "port", i);
+                               std::string port = Conf.ReadValue("bind", "port", i);
                                irc::portparser portrange(port, false);
                                long portno = -1;
                                while ((portno = portrange.GetToken()))
@@ -215,10 +212,10 @@ class ModuleSSLOpenSSL : public Module
                // +1 so we the path ends with a /
                confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
 
-               cafile   = Conf->ReadValue("openssl", "cafile", 0);
-               certfile = Conf->ReadValue("openssl", "certfile", 0);
-               keyfile  = Conf->ReadValue("openssl", "keyfile", 0);
-               dhfile   = Conf->ReadValue("openssl", "dhfile", 0);
+               cafile   = Conf.ReadValue("openssl", "cafile", 0);
+               certfile = Conf.ReadValue("openssl", "certfile", 0);
+               keyfile  = Conf.ReadValue("openssl", "keyfile", 0);
+               dhfile   = Conf.ReadValue("openssl", "dhfile", 0);
 
                // Set all the default values needed.
                if (cafile.empty())
@@ -287,8 +284,6 @@ class ModuleSSLOpenSSL : public Module
                }
 
                fclose(dhpfile);
-
-               DELETE(Conf);
        }
 
        virtual void On005Numeric(std::string &output)
@@ -549,6 +544,7 @@ class ModuleSSLOpenSSL : public Module
                }
 
                session->outbuf.append(buffer, count);
+               MakePollWrite(session);
 
                if (session->status == ISSL_HANDSHAKING)
                {
@@ -594,7 +590,6 @@ class ModuleSSLOpenSSL : public Module
                        if (err == SSL_ERROR_WANT_WRITE)
                        {
                                session->wstat = ISSL_WRITE;
-                               MakePollWrite(session);
                                return -1;
                        }
                        else if (err == SSL_ERROR_WANT_READ)
@@ -798,14 +793,14 @@ class ModuleSSLOpenSSL : public Module
                        ServerInstance->SE->WantWrite(eh);
        }
 
-virtual void OnBufferFlushed(userrec* user)
-{
-       if (user->GetExt("ssl"))
+       virtual void OnBufferFlushed(userrec* user)
        {
-               ServerInstance->Log(DEBUG,"OnBufferFlushed for ssl user");
-               issl_session* session = &sessions[user->GetFd()];
-               if (session && session->outbuf.size())
-                       OnRawSocketWrite(user->GetFd(), NULL, 0);
+               if (user->GetExt("ssl"))
+               {
+                       ServerInstance->Log(DEBUG,"OnBufferFlushed for ssl user");
+                       issl_session* session = &sessions[user->GetFd()];
+                       if (session && session->outbuf.size())
+                               OnRawSocketWrite(user->GetFd(), NULL, 0);
                }
        }
 
@@ -891,4 +886,3 @@ static int error_callback(const char *str, size_t len, void *u)
 }
 
 MODULE_INIT(ModuleSSLOpenSSL);
-