summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/inspircd.conf.example18
-rw-r--r--src/modules/m_safelist.cpp16
2 files changed, 28 insertions, 6 deletions
diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example
index 1ea44d1bf..2849650c3 100644
--- a/docs/inspircd.conf.example
+++ b/docs/inspircd.conf.example
@@ -1561,13 +1561,19 @@
#
#-#-#-#-#-#-#-#-#-#-# SAFELIST CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-#-#
#
-# When using Safelist, you may set the following value, which sets the
-# amount of time in seconds a user must wait between LIST commands.
-# For example, if this is set to 60 (the default) then the user may not
-# /LIST more than once a minute. If not defined, the default value is
-# 60 seconds.
+# When using Safelist, you may set the following values;
#
-#<safelist throttle="60">
+# The first value, 'throttle', sets the amount of time in seconds a user
+# must wait between LIST commands. For example, if this is set to 60
+# (the default) then the user may not /LIST more than once a minute.
+# If not defined, the default value is 60 seconds.
+#
+# The second value, 'maxlisters', indicates the maximum number of users
+# which may be retrieving a LIST at once. It is not recommended you raise
+# this value, as increasing it too high can make your network vulnerable
+# to floodbots which waste your bandwidth and CPU time with LIST requests.
+#
+#<safelist throttle="60" maxlisters="50">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# SAJOIN module: Adds the /SAJOIN command
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--;
}
}
}