summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-11 16:01:56 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-11 16:01:56 +0000
commit98bea6aca4a6033f1b2693fbaa4935ef009eb30a (patch)
tree9a800c930db5aa68783491756b20012602d37e6a /src/modules
parent52214a3195d062bc45522e7da58bbe7611d040f6 (diff)
Add safelist:maxlisters which prevents more than x number of people doing a LIST at the same time.
(as i've just noticed, 500 bots all doing LIST at once can severely lag your ircd) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6658 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_safelist.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 1bdfb97bd..45e4dab11 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -38,6 +38,8 @@ class ModuleSafeList : public Module
{
time_t ThrottleSecs;
size_t ServerNameSize;
+ int global_listing;
+ int LimitList;
public:
ModuleSafeList(InspIRCd* Me) : Module::Module(Me)
{
@@ -52,7 +54,9 @@ class ModuleSafeList : public Module
{
ConfigReader MyConf(ServerInstance);
ThrottleSecs = MyConf.ReadInteger("safelist", "throttle", "60", 0, true);
+ LimitList = MyConf.ReadInteger("safelist", "maxlisters", "50", 0, true);
ServerNameSize = strlen(ServerInstance->Config->ServerName) + 4;
+ global_listing = 0;
}
virtual Version GetVersion()
@@ -88,6 +92,14 @@ class ModuleSafeList : public Module
*/
int HandleList(const char** parameters, int pcnt, userrec* user)
{
+ if (global_listing >= LimitList)
+ {
+ user->WriteServ("NOTICE %s :*** Server load is currently too heavy. Please try again later.", user->nick);
+ user->WriteServ("321 %s Channel :Users Name",user->nick);
+ user->WriteServ("323 %s :End of channel list.",user->nick);
+ return 1;
+ }
+
/* First, let's check if the user is currently /list'ing */
ListData *ld;
user->GetExt("safelist_cache", ld);
@@ -117,6 +129,7 @@ class ModuleSafeList : public Module
DELETE(last_list_time);
user->Shrink("safelist_last");
}
+
/*
* start at channel 0! ;)
@@ -130,6 +143,8 @@ class ModuleSafeList : public Module
user->WriteServ("321 %s Channel :Users Name",user->nick);
+ global_listing++;
+
return 1;
}
@@ -185,6 +200,7 @@ class ModuleSafeList : public Module
{
user->Shrink("safelist_cache");
DELETE(ld);
+ global_listing--;
}
}
}