summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRutger <djslash+github@djslash.org>2012-04-01 21:11:25 +0200
committerRutger <djslash+github@djslash.org>2012-04-01 21:11:25 +0200
commit10e0af3831cf29399541d4e2f6f2d6adfb7672bb (patch)
tree53437dad2cfc24964d4b25db74f1b280c4b1c2a3
parente73e4be15485f545ff485d3d372b513dd28bf759 (diff)
Add <connect:maxconnwarn>
Created the maxconnwarn variable in the connect block, so you can make connect blocks that only warns about max connections if you want to. This reduces noise from connecting clients that have low maxlocal and/or maxglobal. It is enabled by default.
-rw-r--r--docs/inspircd.conf.example3
-rw-r--r--include/users.h4
-rw-r--r--src/configreader.cpp1
-rw-r--r--src/users.cpp11
4 files changed, 15 insertions, 4 deletions
diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example
index ffec002a2..322a6e820 100644
--- a/docs/inspircd.conf.example
+++ b/docs/inspircd.conf.example
@@ -268,6 +268,9 @@
# globalmax: Maximum global (network-wide) connections per IP (or CIDR mask, see below).
globalmax="3"
+ # maxconnwarn: Enable warnings when localmax or globalmax is hit (defaults to on)
+ maxconnwarn="off"
+
# useident: Defines if users in this class MUST respond to a ident query or not.
useident="no"
diff --git a/include/users.h b/include/users.h
index 3536fc350..73ef3624e 100644
--- a/include/users.h
+++ b/include/users.h
@@ -121,6 +121,10 @@ struct CoreExport ConnectClass : public refcountbase
*/
unsigned long maxglobal;
+ /** True if max connections for this class is hit and a warning is wanted
+ */
+ bool maxconnwarn;
+
/** Max channels for this class
*/
unsigned int maxchans;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 6ef5105aa..a1a244501 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -375,6 +375,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
me->maxlocal = tag->getInt("localmax", me->maxlocal);
me->maxglobal = tag->getInt("globalmax", me->maxglobal);
me->maxchans = tag->getInt("maxchans", me->maxchans);
+ me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
me->limit = tag->getInt("limit", me->limit);
ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
diff --git a/src/users.cpp b/src/users.cpp
index 7f8e3df8a..6277f95f9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -734,13 +734,15 @@ void LocalUser::CheckClass()
else if ((a->GetMaxLocal()) && (ServerInstance->Users->LocalCloneCount(this) > a->GetMaxLocal()))
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
- ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
+ if (a->maxconnwarn)
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
return;
}
else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
- ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
+ if (a->maxconnwarn)
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
return;
}
@@ -1693,7 +1695,7 @@ const std::string& FakeUser::GetFullRealHost()
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
: config(tag), type(t), fakelag(true), name("unnamed"), registration_timeout(0), host(mask),
pingtime(0), softsendqmax(0), hardsendqmax(0), recvqmax(0),
- penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxchans(0), limit(0)
+ penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxconnwarn(true), maxchans(0), limit(0)
{
}
@@ -1702,7 +1704,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
registration_timeout(parent.registration_timeout), host(mask), pingtime(parent.pingtime),
softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax), recvqmax(parent.recvqmax),
penaltythreshold(parent.penaltythreshold), commandrate(parent.commandrate),
- maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), maxchans(parent.maxchans),
+ maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), maxconnwarn(parent.maxconnwarn), maxchans(parent.maxchans),
limit(parent.limit)
{
}
@@ -1723,6 +1725,7 @@ void ConnectClass::Update(const ConnectClass* src)
commandrate = src->commandrate;
maxlocal = src->maxlocal;
maxglobal = src->maxglobal;
+ maxconnwarn = src->maxconnwarn;
maxchans = src->maxchans;
limit = src->limit;
}