Make some stuff configurable that hasnt been and should be.

<securelist waittime="n">: number of seconds a user must wait before LIST
<safelist throttle="n">: Number of seconds a user must wait between each LIST command


git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6563 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2007-02-10 15:18:49 +00:00
parent d1f78ff160
commit 50d65268f4
3 changed files with 31 additions and 6 deletions

View File

@ -1495,6 +1495,16 @@
# Provide /LIST throttling (to prevent flooding) and /LIST safety to
# prevent excess flood when the list is large.
#<module name="m_safelist.so">
#
#-#-#-#-#-#-#-#-#-#-# 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.
#
#<safelist throttle="60">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# SAJOIN module: Adds the /SAJOIN command
@ -1526,8 +1536,13 @@
# Securelist can be harmful to some irc search engines such as #
# netsplit.de and searchirc.com. To prevent securelist blocking these #
# sites from listing, define exception tags as shown below: #
<securelist exception="*@*.searchirc.org">
<securelist exception="*@*.netsplit.de">
<securelist exception="*@*.searchirc.org"> #
<securelist exception="*@*.netsplit.de"> #
# #
# Define the following variable to change how long a user must wait #
# before issuing a LIST. If not defined, defaults to 60 seconds. #
# #
#<securelist waittime="60"> #
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Set Idle module: Adds a command for opers to change their

View File

@ -152,10 +152,12 @@ class ListTimer : public InspTimer
class ModuleSafeList : public Module
{
unsigned int ThrottleSecs;
public:
ModuleSafeList(InspIRCd* Me) : Module::Module(Me)
{
timer = NULL;
OnRehash(NULL, "");
}
virtual ~ModuleSafeList()
@ -163,6 +165,12 @@ class ModuleSafeList : public Module
if (timer)
ServerInstance->Timers->DelTimer(timer);
}
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader MyConf(ServerInstance);
ThrottleSecs = MyConf.ReadInteger("safelist", "throttle", "60", 0, true);
}
virtual Version GetVersion()
{
@ -171,7 +179,7 @@ class ModuleSafeList : public Module
void Implements(char* List)
{
List[I_OnPreCommand] = List[I_OnCleanup] = List[I_OnUserQuit] = List[I_On005Numeric] = 1;
List[I_OnPreCommand] = List[I_OnCleanup] = List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnRehash] = 1;
}
/*
@ -215,7 +223,7 @@ class ModuleSafeList : public Module
user->GetExt("safelist_last", last_list_time);
if (last_list_time)
{
if (ServerInstance->Time() < (*last_list_time)+60)
if (ServerInstance->Time() < (*last_list_time)+ThrottleSecs)
{
user->WriteServ("NOTICE %s :*** Woah there, slow down a little, you can't /LIST so often!",user->nick);
user->WriteServ("321 %s Channel :Users Name",user->nick);

View File

@ -24,6 +24,7 @@ class ModuleSecureList : public Module
{
private:
std::vector<std::string> allowlist;
unsigned int WaitTime;
public:
ModuleSecureList(InspIRCd* Me) : Module::Module(Me)
{
@ -45,6 +46,7 @@ class ModuleSecureList : public Module
allowlist.clear();
for (int i = 0; i < MyConf->Enumerate("securelist"); i++)
allowlist.push_back(MyConf->ReadValue("securelist", "exception", i));
WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
DELETE(MyConf);
}
@ -63,7 +65,7 @@ class ModuleSecureList : public Module
if (!validated)
return 0;
if ((command == "LIST") && (ServerInstance->Time() < (user->signon+60)) && (!*user->oper))
if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!*user->oper))
{
/* Normally wouldnt be allowed here, are they exempt? */
for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
@ -71,7 +73,7 @@ class ModuleSecureList : public Module
return 0;
/* Not exempt, BOOK EM DANNO! */
user->WriteServ("NOTICE %s :*** You cannot list within the first minute of connecting. Please try again later.",user->nick);
user->WriteServ("NOTICE %s :*** You cannot list within the first %d seconds of connecting. Please try again later.",user->nick, WaitTime);
/* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
* receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
*/