diff options
author | Peter Powell <petpow@saberuk.com> | 2017-10-12 15:07:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-12 15:07:45 +0100 |
commit | 1522ba9800db574bf19504fa3b1bfa86112f96b2 (patch) | |
tree | e1f726cd5fc9b220313787e56daf768146e5af57 | |
parent | 9de9231380d42955a13f07d7843897c77af704e4 (diff) | |
parent | aa5bd1eafe987e7c73200aa04e3023dffcb4a307 (diff) |
Merge pull request #1353 from SISheogorath/master+domainpart-cloaking
Make domainparts in m_cloaking configureable.
-rw-r--r-- | docs/conf/modules.conf.example | 10 | ||||
-rw-r--r-- | src/modules/m_cloaking.cpp | 18 |
2 files changed, 22 insertions, 6 deletions
diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 4a3c6bf16..383c6a173 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -481,9 +481,12 @@ # # # There are two methods of cloaking: # # # -# half Cloak only the "unique" portion of a host; show # -# the last 2 parts of the domain, /16 subnet of IPv4 # -# or /48 subnet of the IPv6 address. # +# half Cloak only the "unique" portion of a host; by # +# default show the last 2 parts of the domain, # +# /16 subnet of IPv4 or /48 subnet of the IPv6 # +# address. # +# To change the number of shown parts, modify the # +# domainparts option. # # # # full Cloak the users completely, using three slices for # # common CIDR bans (IPv4: /16, /24; IPv6: /48, /64). # @@ -494,6 +497,7 @@ # #<cloak mode="half" # key="secret" +# domainparts="3" # prefix="net-"> #-#-#-#-#-#-#-#-#-#-#-#- CLOSE MODULE #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index cb3fdac1a..7e9c78b31 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -143,6 +143,7 @@ class ModuleCloaking : public Module std::string prefix; std::string suffix; std::string key; + unsigned int domainparts; dynamic_reference<HashProvider> Hash; ModuleCloaking() : cu(this), mode(MODE_OPAQUE), ck(this), Hash(this, "hash/md5") @@ -160,7 +161,7 @@ class ModuleCloaking : public Module */ std::string LastTwoDomainParts(const std::string &host) { - int dots = 0; + unsigned int dots = 0; std::string::size_type splitdot = host.length(); for (std::string::size_type x = host.length() - 1; x; --x) @@ -170,7 +171,7 @@ class ModuleCloaking : public Module splitdot = x; dots++; } - if (dots >= 3) + if (dots >= domainparts) break; } @@ -314,7 +315,15 @@ class ModuleCloaking : public Module switch (mode) { case MODE_HALF_CLOAK: - testcloak = prefix + SegmentCloak("*", 3, 8) + suffix; + // Use old cloaking verification to stay compatible with 2.0 + // But verify domainparts when use 3.0-only features + if (domainparts == 3) + testcloak = prefix + SegmentCloak("*", 3, 8) + suffix; + else + { + irc::sockets::sockaddrs sa; + testcloak = GenCloak(sa, "", testcloak + ConvToStr(domainparts)); + } break; case MODE_OPAQUE: testcloak = prefix + SegmentCloak("*", 4, 8) + suffix; @@ -331,7 +340,10 @@ class ModuleCloaking : public Module std::string modestr = tag->getString("mode"); if (modestr == "half") + { mode = MODE_HALF_CLOAK; + domainparts = tag->getInt("domainparts", 3, 1, 10); + } else if (modestr == "full") mode = MODE_OPAQUE; else |