Skip to content

Commit

Permalink
Merge pull request #27 from DjSlash/maxconnwarn
Browse files Browse the repository at this point in the history
Add <connect:maxconnwarn>
  • Loading branch information
rburchell committed Apr 9, 2012
2 parents 88b1a5a + 10e0af3 commit c5e73ec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/inspircd.conf.example
Expand Up @@ -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"

Expand Down
4 changes: 4 additions & 0 deletions include/users.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/configreader.cpp
Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/users.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
}

Expand All @@ -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)
{
}
Expand All @@ -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;
}

0 comments on commit c5e73ec

Please sign in to comment.