diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-08 23:29:21 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-08 23:29:21 +0000 |
commit | 7e843c22e16c81054bad18073d24fe1a07026431 (patch) | |
tree | 44ca0213c7d7a80270b993fec1fbed275ec56424 /src/modules/m_md5.cpp | |
parent | c440038736f749a56dbac1badee5b2f099286117 (diff) |
Update Event and Request APIs
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11808 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_md5.cpp')
-rw-r--r-- | src/modules/m_md5.cpp | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index 911f6d926..00d3fb1e9 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -259,17 +259,11 @@ class ModuleMD5 : public Module *dest++ = 0; } - unsigned int *key; - char* chars; - public: ModuleMD5() - : key(NULL), chars(NULL) { ServerInstance->Modules->PublishInterface("HashRequest", this); - Implementation eventlist[] = { I_OnRequest }; - ServerInstance->Modules->Attach(eventlist, this, 1); } virtual ~ModuleMD5() @@ -278,37 +272,29 @@ class ModuleMD5 : public Module } - virtual const char* OnRequest(Request* request) + void OnRequest(Request& request) { - HashRequest* MD5 = (HashRequest*)request; - - if (strcmp("KEY", request->GetId()) == 0) - { - this->key = (unsigned int*)MD5->GetKeyData(); - } - else if (strcmp("HEX", request->GetId()) == 0) - { - this->chars = (char*)MD5->GetOutputs(); - } - else if (strcmp("SUM", request->GetId()) == 0) + if (strcmp("HASH", request.id) == 0) { - static char data[MAXBUF]; - GenHash(MD5->GetHashData().data(), data, chars ? chars : "0123456789abcdef", key, MD5->GetHashData().length()); - return data; + char res[33]; + HashRequest& req = static_cast<HashRequest&>(request); + GenHash(req.data.data(), res, "0123456789abcdef", NULL, req.data.length()); + req.result = res; } - else if (strcmp("NAME", request->GetId()) == 0) + else if (strcmp("HASH-IV", request.id) == 0) { - return "md5"; + char res[33]; + HashRequestIV& req = static_cast<HashRequestIV&>(request); + GenHash(req.data.data(), res, req.map, req.iv, req.data.length()); + req.result = res; } - else if (strcmp("RESET", request->GetId()) == 0) + else if (strcmp("NAME", request.id) == 0) { - this->chars = NULL; - this->key = NULL; + static_cast<HashNameRequest&>(request).response = "md5"; } - return NULL; } - virtual Version GetVersion() + Version GetVersion() { return Version("Allows for MD5 encrypted oper passwords",VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION); } |