]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ssl_gnutls.cpp
Increment serverstats::Collisions when a collision is handled, not when a module...
[user/henk/code/inspircd.git] / src / modules / extra / m_ssl_gnutls.cpp
index 2add962fd05d1157e4a93ed2b6469a8c07f2f51f..a2c58cf86c9ac402b72963cc6c4a4b4adbfe0cad 100644 (file)
@@ -25,7 +25,6 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 #include "modules/ssl.h"
-#include "modules/cap.h"
 #include <memory>
 
 #if ((GNUTLS_VERSION_MAJOR > 2) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR > 9) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR == 9 && GNUTLS_VERSION_PATCH >= 8))
@@ -81,7 +80,6 @@ typedef gnutls_retr_st cert_cb_last_param_type;
 class RandGen : public HandlerBase2<void, char*, size_t>
 {
  public:
-       RandGen() {}
        void Call(char* buffer, size_t len)
        {
 #ifdef GNUTLS_HAS_RND
@@ -589,13 +587,13 @@ class GnuTLSIOHook : public SSLIOHook
                                {
                                        // gnutls_handshake() wants to read() again.
                                        this->status = ISSL_HANDSHAKING_READ;
-                                       ServerInstance->SE->ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
+                                       SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
                                }
                                else
                                {
                                        // gnutls_handshake() wants to write() again.
                                        this->status = ISSL_HANDSHAKING_WRITE;
-                                       ServerInstance->SE->ChangeEventMask(user, FD_WANT_NO_READ | FD_WANT_SINGLE_WRITE);
+                                       SocketEngine::ChangeEventMask(user, FD_WANT_NO_READ | FD_WANT_SINGLE_WRITE);
                                }
                        }
                        else
@@ -615,7 +613,7 @@ class GnuTLSIOHook : public SSLIOHook
                        VerifyCertificate();
 
                        // Finish writing, if any left
-                       ServerInstance->SE->ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE | FD_ADD_TRIAL_WRITE);
+                       SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE | FD_ADD_TRIAL_WRITE);
 
                        return true;
                }
@@ -735,7 +733,7 @@ info_done_dealloc:
                        return -1;
                }
 
-               int rv = ServerInstance->SE->Recv(sock, reinterpret_cast<char *>(buffer), size, 0);
+               int rv = SocketEngine::Recv(sock, reinterpret_cast<char *>(buffer), size, 0);
 
 #ifdef _WIN32
                if (rv < 0)
@@ -750,7 +748,7 @@ info_done_dealloc:
 #endif
 
                if (rv < (int)size)
-                       ServerInstance->SE->ChangeEventMask(sock, FD_READ_WILL_BLOCK);
+                       SocketEngine::ChangeEventMask(sock, FD_READ_WILL_BLOCK);
                return rv;
        }
 
@@ -771,7 +769,7 @@ info_done_dealloc:
                        return -1;
                }
 
-               int rv = ServerInstance->SE->Send(sock, reinterpret_cast<const char *>(buffer), size, 0);
+               int rv = SocketEngine::Send(sock, reinterpret_cast<const char *>(buffer), size, 0);
 
 #ifdef _WIN32
                if (rv < 0)
@@ -786,7 +784,7 @@ info_done_dealloc:
 #endif
 
                if (rv < (int)size)
-                       ServerInstance->SE->ChangeEventMask(sock, FD_WRITE_WILL_BLOCK);
+                       SocketEngine::ChangeEventMask(sock, FD_WRITE_WILL_BLOCK);
                return rv;
        }
 
@@ -889,18 +887,18 @@ info_done_dealloc:
 
                        if (ret == (int)sendq.length())
                        {
-                               ServerInstance->SE->ChangeEventMask(user, FD_WANT_NO_WRITE);
+                               SocketEngine::ChangeEventMask(user, FD_WANT_NO_WRITE);
                                return 1;
                        }
                        else if (ret > 0)
                        {
                                sendq = sendq.substr(ret);
-                               ServerInstance->SE->ChangeEventMask(user, FD_WANT_SINGLE_WRITE);
+                               SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE);
                                return 0;
                        }
                        else if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED || ret == 0)
                        {
-                               ServerInstance->SE->ChangeEventMask(user, FD_WANT_SINGLE_WRITE);
+                               SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE);
                                return 0;
                        }
                        else // (ret < 0)
@@ -987,9 +985,6 @@ class ModuleSSLGnuTLS : public Module
 
        // First member of the class, gets constructed first and destructed last
        GnuTLS::Init libinit;
-
-       std::string sslports;
-
        RandGen randhandler;
        ProfileList profiles;
 
@@ -1064,45 +1059,6 @@ class ModuleSSLGnuTLS : public Module
                ServerInstance->GenRandom = &randhandler;
        }
 
-       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
-       {
-               sslports.clear();
-
-               ConfigTag* Conf = ServerInstance->Config->ConfValue("gnutls");
-
-               if (Conf->getBool("showports", true))
-               {
-                       sslports = Conf->getString("advertisedports");
-                       if (!sslports.empty())
-                               return;
-
-                       for (size_t i = 0; i < ServerInstance->ports.size(); i++)
-                       {
-                               ListenSocket* port = ServerInstance->ports[i];
-                               if (port->bind_tag->getString("ssl") != "gnutls")
-                                       continue;
-
-                               const std::string& portid = port->bind_desc;
-                               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Enabling SSL for port %s", portid.c_str());
-
-                               if (port->bind_tag->getString("type", "clients") == "clients" && port->bind_addr != "127.0.0.1")
-                               {
-                                       /*
-                                        * Found an SSL port for clients that is not bound to 127.0.0.1 and handled by us, display
-                                        * the IP:port in ISUPPORT.
-                                        *
-                                        * We used to advertise all ports seperated by a ';' char that matched the above criteria,
-                                        * but this resulted in too long ISUPPORT lines if there were lots of ports to be displayed.
-                                        * To solve this by default we now only display the first IP:port found and let the user
-                                        * configure the exact value for the 005 token, if necessary.
-                                        */
-                                       sslports = portid;
-                                       break;
-                               }
-                       }
-               }
-       }
-
        void OnModuleRehash(User* user, const std::string &param) CXX11_OVERRIDE
        {
                if(param != "ssl")
@@ -1143,12 +1099,6 @@ class ModuleSSLGnuTLS : public Module
                return Version("Provides SSL support for clients", VF_VENDOR);
        }
 
-       void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
-       {
-               if (!sslports.empty())
-                       tokens["SSL"] = sslports;
-       }
-
        void OnUserConnect(LocalUser* user) CXX11_OVERRIDE
        {
                IOHook* hook = user->eh.GetIOHook();