From 32b80d37cd8b9d9b1efb8cd2df9f716cffe03b6c Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Sat, 27 Mar 2010 09:56:43 -0500 Subject: Add debouncing to m_cloaking, and fix cloak of hosts without dots --- src/modules/m_cloaking.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 59dd008af..c6dca1e63 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -32,6 +32,10 @@ class CloakUser : public ModeHandler Module* HashProvider; const char *xtab[4]; + std::string debounce_uid; + time_t debounce_ts; + int debounce_count; + /** This function takes a domain name string and returns just the last two domain parts, * or the last domain part if only two are available. Failing that it just returns what it was given. * @@ -58,7 +62,7 @@ class CloakUser : public ModeHandler } if (splitdot == host.length()) - return host; + return ""; else return host.substr(splitdot); } @@ -79,8 +83,22 @@ class CloakUser : public ModeHandler return MODEACTION_ALLOW; } + if (dest->uuid == debounce_uid && debounce_ts == ServerInstance->Time()) + { + // prevent spamming using /mode user +x-x+x-x+x-x + if (++debounce_count > 2) + return MODEACTION_DENY; + } + else + { + debounce_uid = dest->uuid; + debounce_count = 1; + debounce_ts = ServerInstance->Time(); + } + /* don't allow this user to spam modechanges */ - dest->IncreasePenalty(5); + if (source == dest) + dest->IncreasePenalty(5); if (adding) { -- cgit v1.3.1-10-gc9f91