summaryrefslogtreecommitdiff
path: root/src/modules/m_cloaking.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
commit7e843c22e16c81054bad18073d24fe1a07026431 (patch)
tree44ca0213c7d7a80270b993fec1fbed275ec56424 /src/modules/m_cloaking.cpp
parentc440038736f749a56dbac1badee5b2f099286117 (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_cloaking.cpp')
-rw-r--r--src/modules/m_cloaking.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index f8743d94c..ade4339b8 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -133,7 +133,6 @@ class CloakUser : public ModeHandler
{
unsigned int iv[] = { key1, key2, key3, key4 };
irc::sepstream seps(ip, '.');
- std::string ra[4];;
std::string octet[4];
int i[4];
@@ -148,17 +147,19 @@ class CloakUser : public ModeHandler
octet[1] = octet[0] + "." + octet[1];
/* Reset the Hash module and send it our IV */
- HashResetRequest(creator, HashProvider).Send();
- HashKeyRequest(creator, HashProvider, iv).Send();
+
+ std::string rv;
/* Send the Hash module a different hex table for each octet group's Hash sum */
for (int k = 0; k < 4; k++)
{
- HashHexRequest(creator, HashProvider, xtab[(iv[k]+i[k]) % 4]).Send();
- ra[k] = std::string(HashSumRequest(creator, HashProvider, octet[k]).Send()).substr(0,6);
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(iv[k]+i[k]) % 4], octet[k]);
+ rv.append(hash.result.substr(0,6));
+ if (k < 3)
+ rv.append(".");
}
/* Stick them all together */
- return std::string().append(ra[0]).append(".").append(ra[1]).append(".").append(ra[2]).append(".").append(ra[3]);
+ return rv;
}
std::string Cloak6(const char* ip)
@@ -169,27 +170,22 @@ class CloakUser : public ModeHandler
int rounds = 0;
/* Reset the Hash module and send it our IV */
- HashResetRequest(creator, HashProvider).Send();
- HashKeyRequest(creator, HashProvider, iv).Send();
for (const char* input = ip; *input; input++)
{
item += *input;
if (item.length() > 7)
{
- /* Send the Hash module a different hex table for each octet group's Hash sum */
- HashHexRequest(creator, HashProvider, xtab[(key1+rounds) % 4]).Send();
- hashies.push_back(std::string(HashSumRequest(creator, HashProvider, item).Send()).substr(0,8));
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(key1+rounds) % 4], item);
+ hashies.push_back(hash.result.substr(0,8));
item.clear();
}
rounds++;
}
if (!item.empty())
{
- /* Send the Hash module a different hex table for each octet group's Hash sum */
- HashHexRequest(creator, HashProvider, xtab[(key1+rounds) % 4]).Send();
- hashies.push_back(std::string(HashSumRequest(creator, HashProvider, item).Send()).substr(0,8));
- item.clear();
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(key1+rounds) % 4], item);
+ hashies.push_back(hash.result.substr(0,8));
}
/* Stick them all together */
return irc::stringjoiner(":", hashies, 0, hashies.size() - 1).GetJoined();
@@ -370,12 +366,10 @@ class ModuleCloaking : public Module
if (!cu->ipalways)
{
/** Reset the Hash module, and send it our IV and hex table */
- HashResetRequest(this, cu->HashProvider).Send();
- HashKeyRequest(this, cu->HashProvider, iv).Send();
- HashHexRequest(this, cu->HashProvider, cu->xtab[(dest->host[0]) % 4]);
+ HashRequestIV hash(this, cu->HashProvider, iv, cu->xtab[(dest->host[0]) % 4], dest->host);
/* Generate a cloak using specialized Hash */
- std::string hostcloak = cu->prefix + "-" + std::string(HashSumRequest(this, cu->HashProvider, dest->host.c_str()).Send()).substr(0,8) + a;
+ std::string hostcloak = cu->prefix + "-" + hash.result.substr(0,8) + a;
/* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
* according to the DNS RFC) then tough titty, they get cloaked as an IP.