1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 /* $ModDesc: Allows for MD5 encrypted oper passwords */
18 /* $ModDep: m_md5.h */
22 #include "inspircd_config.h"
32 class cmd_mkpasswd : public command_t
37 cmd_mkpasswd (InspIRCd* Instance, Module* Sender, Module* MD5) : command_t(Instance,"MKPASSWD", 'o', 1), MD5Provider(MD5)
39 this->source = "m_opermd5.so";
40 syntax = "<any-text>";
43 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
45 MD5ResetRequest(Sender, MD5Provider).Send();
46 user->WriteServ("NOTICE %s :MD5 hashed password for %s is %s",user->nick,parameters[0], MD5SumRequest(Sender, MD5Provider, parameters[0]).Send() );
51 class ModuleOperMD5 : public Module
54 cmd_mkpasswd* mycommand;
59 ModuleOperMD5(InspIRCd* Me)
62 MD5Provider = ServerInstance->FindModule("m_md5.so");
64 throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_opermd5.so.");
66 mycommand = new cmd_mkpasswd(ServerInstance, this, MD5Provider);
67 ServerInstance->AddCommand(mycommand);
70 virtual ~ModuleOperMD5()
74 void Implements(char* List)
76 List[I_OnOperCompare] = 1;
79 virtual int OnOperCompare(const std::string &data, const std::string &input)
81 MD5ResetRequest(this, MD5Provider).Send();
82 if (data.length() == 32) // if its 32 chars long, try it as an md5
84 if (!strcasecmp(data.c_str(), MD5SumRequest(this, MD5Provider, input.c_str()).Send()))
93 virtual Version GetVersion()
95 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
100 class ModuleOperMD5Factory : public ModuleFactory
103 ModuleOperMD5Factory()
107 ~ModuleOperMD5Factory()
111 virtual Module * CreateModule(InspIRCd* Me)
113 return new ModuleOperMD5(Me);
119 extern "C" void * init_module( void )
121 return new ModuleOperMD5Factory;