summaryrefslogtreecommitdiff
path: root/src/modules/m_sslinfo.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-06-27 21:03:46 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-06-27 21:03:46 +0000
commit5af5707b6dc5d216e9bef043f9a37ae640e46a3e (patch)
tree63dc23ed08059da04548dde40dec70e652198c9e /src/modules/m_sslinfo.cpp
parent5374c1696128bf8908e3cfad547213e2893edf01 (diff)
m_sslinfo does not depend on external libraries, it should not be in extra
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11418 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_sslinfo.cpp')
-rw-r--r--src/modules/m_sslinfo.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
new file mode 100644
index 000000000..fb1a00666
--- /dev/null
+++ b/src/modules/m_sslinfo.cpp
@@ -0,0 +1,90 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "transport.h"
+
+/* $ModDesc: Provides /sslinfo command used to test who a mask matches */
+/* $ModDep: transport.h */
+
+/** Handle /SSLINFO
+ */
+class CommandSSLInfo : public Command
+{
+ public:
+ CommandSSLInfo (InspIRCd* Instance) : Command(Instance,"SSLINFO", 0, 1)
+ {
+ this->source = "m_sslinfo.so";
+ this->syntax = "<nick>";
+ }
+
+ CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+ {
+ User* target = ServerInstance->FindNick(parameters[0]);
+ ssl_cert* cert;
+
+ if (target)
+ {
+ if (target->GetExt("ssl_cert", cert))
+ {
+ if (cert->GetError().length())
+ {
+ user->WriteServ("NOTICE %s :*** No SSL certificate information for this user (%s).", user->nick.c_str(), cert->GetError().c_str());
+ }
+ else
+ {
+ user->WriteServ("NOTICE %s :*** Distinguised Name: %s", user->nick.c_str(), cert->GetDN().c_str());
+ user->WriteServ("NOTICE %s :*** Issuer: %s", user->nick.c_str(), cert->GetIssuer().c_str());
+ user->WriteServ("NOTICE %s :*** Key Fingerprint: %s", user->nick.c_str(), cert->GetFingerprint().c_str());
+ }
+ return CMD_LOCALONLY;
+ }
+ else
+ {
+ user->WriteServ("NOTICE %s :*** No SSL certificate information for this user.", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+ }
+ else
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nickname", user->nick.c_str(), parameters[0].c_str());
+
+ return CMD_FAILURE;
+ }
+};
+
+class ModuleSSLInfo : public Module
+{
+ CommandSSLInfo* newcommand;
+ public:
+ ModuleSSLInfo(InspIRCd* Me)
+ : Module(Me)
+ {
+
+ newcommand = new CommandSSLInfo(ServerInstance);
+ ServerInstance->AddCommand(newcommand);
+
+ }
+
+
+ virtual ~ModuleSSLInfo()
+ {
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version("$Id$", VF_VENDOR, API_VERSION);
+ }
+};
+
+MODULE_INIT(ModuleSSLInfo)
+