]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sslinfo.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / modules / m_sslinfo.cpp
index f861f123654d86fb53c9bef7724632002fc8e846..ac02908c4e5d887e3bb7907a0da4700dc138beee 100644 (file)
@@ -95,7 +95,7 @@ class CommandSSLInfo : public Command
 
                if ((!target) || (target->registered != REG_ALL))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nickname", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
                bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly");
@@ -139,14 +139,16 @@ class UserCertificateAPIImpl : public UserCertificateAPIBase
        }
 };
 
-class ModuleSSLInfo : public Module
+class ModuleSSLInfo : public Module, public Whois::EventListener
 {
        CommandSSLInfo cmd;
        UserCertificateAPIImpl APIImpl;
 
  public:
        ModuleSSLInfo()
-               : cmd(this), APIImpl(this, cmd.CertExt)
+               : Whois::EventListener(this)
+               , cmd(this)
+               , APIImpl(this, cmd.CertExt)
        {
        }
 
@@ -155,16 +157,15 @@ class ModuleSSLInfo : public Module
                return Version("SSL Certificate Utilities", VF_VENDOR);
        }
 
-       void OnWhois(User* source, User* dest) CXX11_OVERRIDE
+       void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
        {
-               ssl_cert* cert = cmd.CertExt.get(dest);
+               ssl_cert* cert = cmd.CertExt.get(whois.GetTarget());
                if (cert)
                {
-                       ServerInstance->SendWhoisLine(source, dest, 671, "%s :is using a secure connection", dest->nick.c_str());
+                       whois.SendLine(671, ":is using a secure connection");
                        bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly");
-                       if ((!operonlyfp || source == dest || source->IsOper()) && !cert->fingerprint.empty())
-                               ServerInstance->SendWhoisLine(source, dest, 276, "%s :has client certificate fingerprint %s",
-                                       dest->nick.c_str(), cert->fingerprint.c_str());
+                       if ((!operonlyfp || whois.IsSelfWhois() || whois.GetSource()->IsOper()) && !cert->fingerprint.empty())
+                               whois.SendLine(276, ":has client certificate fingerprint %s", cert->fingerprint.c_str());
                }
        }
 
@@ -180,7 +181,7 @@ class ModuleSSLInfo : public Module
 
                                if (ifo->oper_block->getBool("sslonly") && !cert)
                                {
-                                       user->WriteNumeric(491, ":This oper login requires an SSL connection.");
+                                       user->WriteNumeric(491, "This oper login requires an SSL connection.");
                                        user->CommandFloodPenalty += 10000;
                                        return MOD_RES_DENY;
                                }
@@ -188,7 +189,7 @@ class ModuleSSLInfo : public Module
                                std::string fingerprint;
                                if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint))
                                {
-                                       user->WriteNumeric(491, ":This oper login requires a matching SSL certificate fingerprint.");
+                                       user->WriteNumeric(491, "This oper login requires a matching SSL certificate fingerprint.");
                                        user->CommandFloodPenalty += 10000;
                                        return MOD_RES_DENY;
                                }