diff options
author | Sheogorath <sheogorath@shivering-isles.com> | 2017-06-27 22:41:07 +0200 |
---|---|---|
committer | Sheogorath <sheogorath@shivering-isles.com> | 2017-10-11 10:52:30 +0200 |
commit | aa5bd1eafe987e7c73200aa04e3023dffcb4a307 (patch) | |
tree | 2631856cfc51070b7734cb1fdbb3d2f7fc0e60c6 /src/modules/m_cloaking.cpp | |
parent | 6acb2dcdd235e2594f800f33978e1a598c7792da (diff) |
Make domainparts configureable
Diffstat (limited to 'src/modules/m_cloaking.cpp')
-rw-r--r-- | src/modules/m_cloaking.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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 |