diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-04 19:21:31 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-04 19:21:31 +0000 |
commit | 3d367b4213723f52b473130de5b018f4b11dffb5 (patch) | |
tree | 0e7f998ec460171f0f03235496547a038844bbf6 /src/modules/m_cloaking.cpp | |
parent | b436d286f2c5c91acacec16f91abb373dedd7771 (diff) |
Fix the new ipv4 cloaks to not change wildly if one octet changes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5844 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_cloaking.cpp')
-rw-r--r-- | src/modules/m_cloaking.cpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 9d0cda71f..bbc534f95 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -14,23 +14,6 @@ * --------------------------------------------------- */ -// Hostname cloaking (+x mode) module for inspircd. -// version 1.0.0.1 by brain (C. J. Edwards) Mar 2004. -// -// When loaded this module will automatically set the -// +x mode on all connecting clients. -// -// Setting +x on a client causes the module to change the -// dhost entry (displayed host) for each user who has the -// mode, cloaking their host. Unlike unreal, the algorithm -// is non-reversible as uncloaked hosts are passed along -// the server->server link, and all encoding of hosts is -// done locally on the server by this module. - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> #include "inspircd_config.h" #ifdef HAS_STDINT #include <stdint.h> @@ -43,8 +26,6 @@ /* $ModDesc: Provides masking of user hostnames */ - - /* The four core functions - F1 is optimized somewhat */ #define F1(x, y, z) (z ^ (x & (y ^ z))) @@ -351,15 +332,22 @@ class CloakUser : public ModeHandler /* 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+atoi(octet3.c_str())) % 4); - this->GenHash(octet2.c_str(),ra2, (key2+atoi(octet1.c_str())) % 4); - this->GenHash(octet3.c_str(),ra3, (key3+atoi(octet4.c_str())) % 4); - this->GenHash(octet4.c_str(),ra4, (key4+atoi(octet2.c_str())) % 4); + 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; |