diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-04 19:25:33 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-04 19:25:33 +0000 |
commit | 1bbaa4664b2531a66029187aa1ef5a0ff62c061d (patch) | |
tree | a173137f0c5ed80003450438c72251172d05659b /src | |
parent | 3d367b4213723f52b473130de5b018f4b11dffb5 (diff) |
Move ipv4 cloaking to cloak4
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5845 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_cloaking.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index bbc534f95..bddf65eea 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -330,28 +330,7 @@ class CloakUser : public ModeHandler if (b.find(':') == std::string::npos) { /* IP4 ip */ - irc::sepstream seps(dest->host, '.'); - char ra1[64], ra2[64], ra3[64], ra4[64]; - int i1, i2, i3, i4; - std::string octet1 = seps.GetToken(); - std::string octet2 = seps.GetToken(); - std::string octet3 = seps.GetToken(); - std::string octet4 = seps.GetToken(); - i1 = atoi(octet1.c_str()); - i2 = atoi(octet2.c_str()); - i3 = atoi(octet3.c_str()); - i4 = atoi(octet4.c_str()); - octet1.append(".").append(octet2).append(".").append(octet3); - octet2.append(".").append(octet3); - ServerInstance->Log(DEBUG,"oct1=%s, oct2=%s, oct3=%s, oct4=%s", octet1.c_str(), octet2.c_str(), octet3.c_str(), octet4.c_str()); - this->GenHash(octet1.c_str(),ra1, (key1+i1) % 4); - this->GenHash(octet2.c_str(),ra2, (key2+i2) % 4); - this->GenHash(octet3.c_str(),ra3, (key3+i3) % 4); - this->GenHash(octet4.c_str(),ra4, (key4+i4) % 4); - ServerInstance->Log(DEBUG,"ra1=%s, ra2=%s, ra3=%s, ra4=%s", ra1, ra2, ra3, ra4); - /* This is safe as we know the length generated by our genhash is always 16 */ - ra1[8] = ra2[8] = ra3[8] = ra4[8] = 0; - b.append(ra1).append(".").append(ra2).append(".").append(ra3).append(".").append(ra4); + b = Cloak4(dest->host); } else { @@ -383,6 +362,34 @@ class CloakUser : public ModeHandler return MODEACTION_DENY; } + + std::string Cloak4(const char* ip) + { + std::string b; + irc::sepstream seps(ip, '.'); + char ra1[64], ra2[64], ra3[64], ra4[64]; + int i1, i2, i3, i4; + std::string octet1 = seps.GetToken(); + std::string octet2 = seps.GetToken(); + std::string octet3 = seps.GetToken(); + std::string octet4 = seps.GetToken(); + i1 = atoi(octet1.c_str()); + i2 = atoi(octet2.c_str()); + i3 = atoi(octet3.c_str()); + i4 = atoi(octet4.c_str()); + octet1.append(".").append(octet2).append(".").append(octet3); + octet2.append(".").append(octet3); + ServerInstance->Log(DEBUG,"oct1=%s, oct2=%s, oct3=%s, oct4=%s", octet1.c_str(), octet2.c_str(), octet3.c_str(), octet4.c_str()); + this->GenHash(octet1.c_str(),ra1, (key1+i1) % 4); + this->GenHash(octet2.c_str(),ra2, (key2+i2) % 4); + this->GenHash(octet3.c_str(),ra3, (key3+i3) % 4); + this->GenHash(octet4.c_str(),ra4, (key4+i4) % 4); + ServerInstance->Log(DEBUG,"ra1=%s, ra2=%s, ra3=%s, ra4=%s", ra1, ra2, ra3, ra4); + /* This is safe as we know the length generated by our genhash is always 16 */ + ra1[8] = ra2[8] = ra3[8] = ra4[8] = 0; + b.append(ra1).append(".").append(ra2).append(".").append(ra3).append(".").append(ra4); + return b; + } void DoRehash() { |