diff options
author | Robin Burchell <viroteck@viroteck.net> | 2012-04-09 06:38:53 -0700 |
---|---|---|
committer | Robin Burchell <viroteck@viroteck.net> | 2012-04-09 06:38:53 -0700 |
commit | c5e73ec35ea4a3376e67fb90714850db837d8ba2 (patch) | |
tree | 770d2b01fe1dd1821a29b5c749ae9c9e5289c703 | |
parent | 88b1a5a17da363891f76df614218b35d63f23f6d (diff) | |
parent | 10e0af3831cf29399541d4e2f6f2d6adfb7672bb (diff) |
Merge pull request #27 from DjSlash/maxconnwarn
Add <connect:maxconnwarn>
-rw-r--r-- | docs/inspircd.conf.example | 3 | ||||
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | src/configreader.cpp | 1 | ||||
-rw-r--r-- | src/users.cpp | 11 |
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; } |