]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sslinfo.cpp
Fix STATUSMSG tag messages not including the status in the target.
[user/henk/code/inspircd.git] / src / modules / m_sslinfo.cpp
index 21857b3d955455e5b2150c60dc25a6bbd49a954c..7f58da46a4a21e7ae309dea8f781e9d1db5001a5 100644 (file)
@@ -1,7 +1,16 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
+ *   Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2013 Christopher 'm4z' Holm <them4z@gmail.com>
+ *   Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2010 Adam <Adam@anope.org>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006-2007, 2009-2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -21,6 +30,7 @@
 #include "modules/ssl.h"
 #include "modules/webirc.h"
 #include "modules/whois.h"
+#include "modules/who.h"
 
 enum
 {
@@ -57,12 +67,12 @@ class SSLCertExt : public ExtensionItem
                free(container, unset_raw(container));
        }
 
-       std::string serialize(SerializeFormat format, const Extensible* container, void* item) const CXX11_OVERRIDE
+       std::string ToNetwork(const Extensible* container, void* item) const CXX11_OVERRIDE
        {
                return static_cast<ssl_cert*>(item)->GetMetaLine();
        }
 
-       void unserialize(SerializeFormat format, Extensible* container, const std::string& value) CXX11_OVERRIDE
+       void FromNetwork(Extensible* container, const std::string& value) CXX11_OVERRIDE
        {
                ssl_cert* cert = new ssl_cert;
                set(container, cert);
@@ -184,6 +194,7 @@ class ModuleSSLInfo
        : public Module
        , public WebIRC::EventListener
        , public Whois::EventListener
+       , public Who::EventListener
 {
  private:
        CommandSSLInfo cmd;
@@ -197,6 +208,7 @@ class ModuleSSLInfo
        ModuleSSLInfo()
                : WebIRC::EventListener(this)
                , Whois::EventListener(this)
+               , Who::EventListener(this)
                , cmd(this)
        {
        }
@@ -218,6 +230,19 @@ class ModuleSSLInfo
                }
        }
 
+       ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
+       {
+               size_t flag_index;
+               if (!request.GetFieldIndex('f', flag_index))
+                       return MOD_RES_PASSTHRU;
+
+               ssl_cert* cert = cmd.sslapi.GetCertificate(user);
+               if (cert)
+                       numeric.GetParams()[flag_index].push_back('s');
+
+               return MOD_RES_PASSTHRU;
+       }
+
        ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
        {
                if ((command == "OPER") && (validated))
@@ -287,7 +312,7 @@ class ModuleSSLInfo
 
        ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass) CXX11_OVERRIDE
        {
-               ssl_cert* cert = SSLClientCert::GetCertificate(&user->eh);
+               ssl_cert* cert = cmd.sslapi.GetCertificate(user);
                bool ok = true;
                if (myclass->config->getString("requiressl") == "trusted")
                {
@@ -297,7 +322,7 @@ class ModuleSSLInfo
                else if (myclass->config->getBool("requiressl"))
                {
                        ok = (cert != NULL);
-                       ServerInstance->Logs->Log("CONNECTCLASS", LOG_DEBUG, "Class requires any SSL cert. Client %s one.", (ok ? "has" : "does not have"));
+                       ServerInstance->Logs->Log("CONNECTCLASS", LOG_DEBUG, "Class requires SSL. Client %s using SSL.", (ok ? "is" : "is not"));
                }
 
                if (!ok)