]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ssl_openssl.cpp
Misc removal of pointless Extend strings
[user/henk/code/inspircd.git] / src / modules / extra / m_ssl_openssl.cpp
index 6aaf8ab1f8245cb2f731e281bc34b61cebcf9c14..55b7d841620a2367ffdcf947132f55ab0ed0c82a 100644 (file)
@@ -157,9 +157,9 @@ class ModuleSSLOpenSSL : public Module
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       virtual void OnHookUserIO(User* user, const std::string &targetip)
+       virtual void OnHookUserIO(User* user)
        {
-               if (!user->GetIOHook() && isin(targetip,user->GetPort(), listenports))
+               if (!user->GetIOHook() && isin(user->GetServerIP(),user->GetServerPort(), listenports))
                {
                        /* Hook the user with our module */
                        user->AddIOHook(this);
@@ -424,7 +424,7 @@ class ModuleSSLOpenSSL : public Module
        }
 
 
-       virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
+       virtual void OnRawSocketAccept(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
        {
                /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
                if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
@@ -748,8 +748,7 @@ class ModuleSSLOpenSSL : public Module
                        EventHandler *u = ServerInstance->SE->GetRef(session->fd);
                        if (u)
                        {
-                               if (!u->GetExt("ssl", dummy))
-                                       u->Extend("ssl", "ON");
+                               u->Extend("ssl");
                        }
 
                        session->status = ISSL_OPEN;
@@ -773,12 +772,13 @@ class ModuleSSLOpenSSL : public Module
                // protocol module has propagated the NICK message.
                if ((user->GetIOHook() == this) && (IS_LOCAL(user)))
                {
-                       // Tell whatever protocol module we're using that we need to inform other servers of this metadata NOW.
-                       ServerInstance->PI->SendMetaData(user, TYPE_USER, "ssl", "on");
-
-                       VerifyCertificate(&sessions[user->GetFd()], user);
+                       ssl_cert* certdata = VerifyCertificate(&sessions[user->GetFd()], user);
                        if (sessions[user->GetFd()].sess)
                                user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick.c_str(), SSL_get_cipher(sessions[user->GetFd()].sess));
+
+                       ServerInstance->PI->SendMetaData(user, "ssl", "ON");
+                       if (certdata)
+                               ServerInstance->PI->SendMetaData(user, "ssl_cert", certdata->GetMetaLine().c_str());
                }
        }
 
@@ -822,10 +822,10 @@ class ModuleSSLOpenSSL : public Module
                errno = EIO;
        }
 
-       void VerifyCertificate(issl_session* session, Extensible* user)
+       ssl_cert* VerifyCertificate(issl_session* session, Extensible* user)
        {
                if (!session->sess || !user)
-                       return;
+                       return NULL;
 
                X509* cert;
                ssl_cert* certinfo = new ssl_cert;
@@ -840,7 +840,7 @@ class ModuleSSLOpenSSL : public Module
                if (!cert)
                {
                        certinfo->error = "Could not get peer certificate: "+std::string(get_error());
-                       return;
+                       return certinfo;
                }
 
                certinfo->invalid = (SSL_get_verify_result(session->sess) != X509_V_OK);
@@ -874,6 +874,7 @@ class ModuleSSLOpenSSL : public Module
                }
 
                X509_free(cert);
+               return certinfo;
        }
 
        void Prioritize()