summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/inspircd.conf.example5
-rw-r--r--include/users.h11
-rw-r--r--src/command_parse.cpp2
-rw-r--r--src/configreader.cpp1
-rw-r--r--src/users.cpp5
5 files changed, 21 insertions, 3 deletions
diff --git a/conf/inspircd.conf.example b/conf/inspircd.conf.example
index 726605b16..d5c9874df 100644
--- a/conf/inspircd.conf.example
+++ b/conf/inspircd.conf.example
@@ -309,6 +309,11 @@
# recvq: amount of data allowed in a client's queue before they are dropped.
recvq="8192"
+ # threshold: This specifies the seconds worth of penalty a user is allowed to have
+ # before fake lag is applied to them. If this value is set too low, every action will cause throttling.
+ # Set to 0 to disable.
+ threshold="10"
+
# localmax: Maximum local connections per IP.
localmax="3"
diff --git a/include/users.h b/include/users.h
index 385cd2dfe..42d04696a 100644
--- a/include/users.h
+++ b/include/users.h
@@ -108,6 +108,10 @@ struct CoreExport ConnectClass : public refcountbase
*/
unsigned long recvqmax;
+ /** Seconds worth of penalty before penalty system activates
+ */
+ unsigned long penaltythreshold;
+
/** Local max when connecting by this connection class
*/
unsigned long maxlocal;
@@ -181,6 +185,13 @@ struct CoreExport ConnectClass : public refcountbase
return (recvqmax ? recvqmax : 4096);
}
+ /** Returns the penalty threshold value
+ */
+ unsigned long GetPenaltyThreshold()
+ {
+ return penaltythreshold;
+ }
+
/** Returusn the maximum number of local sessions
*/
unsigned long GetMaxLocal()
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index fe0aab3b9..6dd4e663e 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -253,7 +253,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
{
// If it *doesn't* exist, give it a slightly heftier penalty than normal to deter flooding us crap
user->IncreasePenalty(cm != cmdlist.end() ? cm->second->Penalty : 2);
- do_more = (user->Penalty < 10);
+ do_more = (user->GetClass()->GetPenaltyThreshold() && ((unsigned long)user->Penalty < user->GetClass()->GetPenaltyThreshold()));
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 545ff86c2..879aeaa8e 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -724,6 +724,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
me->recvqmax = tag->getInt("recvq", me->recvqmax);
+ me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
me->maxlocal = tag->getInt("localmax", me->maxlocal);
me->maxglobal = tag->getInt("globalmax", me->maxglobal);
me->port = tag->getInt("port", me->port);
diff --git a/src/users.cpp b/src/users.cpp
index 4707fdc39..1675b621b 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1778,7 +1778,7 @@ const std::string FakeUser::GetFullRealHost()
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
: config(tag), type(t), name("unnamed"), registration_timeout(0), host(mask),
pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0),
- recvqmax(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
+ recvqmax(0), penaltythreshold(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
{
}
@@ -1787,7 +1787,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
registration_timeout(parent.registration_timeout), host(mask),
pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash),
softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax),
- recvqmax(parent.recvqmax), maxlocal(parent.maxlocal),
+ recvqmax(parent.recvqmax), penaltythreshold(parent.penaltythreshold), maxlocal(parent.maxlocal),
maxglobal(parent.maxglobal), maxchans(parent.maxchans),
port(parent.port), limit(parent.limit)
{
@@ -1804,6 +1804,7 @@ void ConnectClass::Update(const ConnectClass* src)
softsendqmax = src->softsendqmax;
hardsendqmax = src->hardsendqmax;
recvqmax = src->recvqmax;
+ penaltythreshold = src->penaltythreshold;
maxlocal = src->maxlocal;
maxglobal = src->maxglobal;
limit = src->limit;