summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-06-24 18:37:25 +0200
committerattilamolnar <attilamolnar@hush.com>2012-07-26 00:52:31 +0200
commitd5792b9227ce7c550c345617733bfc81b8894588 (patch)
treef492e165fec89851cd4883217ea6e9daa608edd6 /src/modules
parentdd7aff3701037b060ee5a582ffec0fe4e18e6437 (diff)
m_connflood Cleanup
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_connflood.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp
index d0e925716..9d7c9cb2c 100644
--- a/src/modules/m_connflood.cpp
+++ b/src/modules/m_connflood.cpp
@@ -23,27 +23,25 @@
/* $ModDesc: Connection throttle */
-int conns = 0, throttled = 0;
-
class ModuleConnFlood : public Module
{
private:
- int seconds, maxconns, timeout, boot_wait;
+ int seconds, timeout, boot_wait;
+ unsigned int conns;
+ unsigned int maxconns;
+ bool throttled;
time_t first;
std::string quitmsg;
public:
- ModuleConnFlood() {
-
+ ModuleConnFlood()
+ : conns(0), throttled(false)
+ {
InitConf();
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
- virtual ~ModuleConnFlood()
- {
- }
-
virtual Version GetVersion()
{
return Version("Connection throttle", VF_VENDOR);
@@ -78,12 +76,12 @@ public:
/* increase connection count */
conns++;
- if (throttled == 1)
+ if (throttled)
{
if (tdiff > seconds + timeout)
{
/* expire throttle */
- throttled = 0;
+ throttled = false;
ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle deactivated");
return MOD_RES_PASSTHRU;
}
@@ -96,7 +94,7 @@ public:
{
if (conns >= maxconns)
{
- throttled = 1;
+ throttled = true;
ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle activated");
ServerInstance->Users->QuitUser(user, quitmsg);
return MOD_RES_DENY;