aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Daniel De Graaf2010-03-27 09:56:43 -0500
committerGravatar Daniel De Graaf2010-03-27 10:01:54 -0500
commit32b80d37cd8b9d9b1efb8cd2df9f716cffe03b6c (patch)
treedff1e0a0e506793570eb6e561a6ad17055802099 /src/modules
parentSend module load/unload notifications as metadata (diff)
Add debouncing to m_cloaking, and fix cloak of hosts without dots
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_cloaking.cpp22
1 files changed, 20 insertions, 2 deletions
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)
{