Skip to content

Commit

Permalink
Add sensible defaults and limits to ConnectClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
SadieCat committed Nov 24, 2021
1 parent d120324 commit 460220f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions include/users.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,37 @@ class CoreExport ConnectClass final
bool uniqueusername:1;

/** Maximum rate of commands (units: millicommands per second). */
unsigned long commandrate = 0;
unsigned long commandrate = 1000UL;

/** The maximum number of bytes that users in this class can have in their send queue before they are disconnected. */
unsigned long hardsendqmax = 0;
unsigned long hardsendqmax = 1048576UL;

/** The maximum number of users in this class that can connect to the local server from one host. */
unsigned long limit = 0;
unsigned long limit = 5000UL;

/** The maximum number of channels that users in this class can join. */
unsigned long maxchans = 20;
unsigned long maxchans = 20UL;

/** The maximum number of users in this class that can connect to the entire network from one host. */
unsigned long maxglobal = 0;
unsigned long maxglobal = 3UL;

/** The maximum number of users that can be in this class on the local server. */
unsigned long maxlocal = 0;
unsigned long maxlocal = 3UL;

/** The amount of penalty that a user in this class can have before the penalty system activates. */
unsigned long penaltythreshold = 0;
unsigned long penaltythreshold = 20UL;

/** The number of seconds between keepalive checks for idle clients in this class. */
unsigned long pingtime = 0;
unsigned long pingtime = 120UL;

/** The maximum number of bytes that users in this class can have in their receive queue before they are disconnected. */
unsigned long recvqmax = 0;
unsigned long recvqmax = 4096UL;

/** The number of seconds that connecting users have to register within in this class. */
unsigned long registration_timeout = 0;
unsigned long registration_timeout = 90UL;

/** The maximum number of bytes that users in this class can have in their send queue before their commands stop being processed. */
unsigned long softsendqmax = 0;
unsigned long softsendqmax = 4096UL;

/** Creates a new connect class from a config tag. */
ConnectClass(std::shared_ptr<ConfigTag> tag, char type, const std::vector<std::string>& masks);
Expand All @@ -154,48 +154,48 @@ class CoreExport ConnectClass final
*/
time_t GetRegTimeout()
{
return (registration_timeout ? registration_timeout : 90);
return registration_timeout;
}

/** Returns the ping frequency
*/
unsigned long GetPingTime()
{
return (pingtime ? pingtime : 120L);
return pingtime;
}

/** Returns the maximum sendq value (soft limit)
* Note that this is in addition to internal OS buffers
*/
unsigned long GetSendqSoftMax()
{
return (softsendqmax ? softsendqmax : 4096L);
return softsendqmax;
}

/** Returns the maximum sendq value (hard limit)
*/
unsigned long GetSendqHardMax()
{
return (hardsendqmax ? hardsendqmax : 0x100000L);
return hardsendqmax;
}

/** Returns the maximum recvq value
*/
unsigned long GetRecvqMax()
{
return (recvqmax ? recvqmax : 4096L);
return recvqmax;
}

/** Returns the penalty threshold value
*/
unsigned long GetPenaltyThreshold()
{
return penaltythreshold ? penaltythreshold : (fakelag ? 10L : 20L);
return penaltythreshold;
}

unsigned long GetCommandRate()
{
return commandrate ? commandrate : 1000L;
return commandrate;
}

/** Return the maximum number of local sessions
Expand Down
16 changes: 8 additions & 8 deletions src/configreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
me->softsendqmax = value;
me->hardsendqmax = value * 8;
}
me->softsendqmax = tag->getUInt("softsendq", me->softsendqmax);
me->hardsendqmax = tag->getUInt("hardsendq", me->hardsendqmax);
me->recvqmax = tag->getUInt("recvq", me->recvqmax);
me->penaltythreshold = tag->getUInt("threshold", me->penaltythreshold);
me->commandrate = tag->getUInt("commandrate", me->commandrate);
me->softsendqmax = tag->getUInt("softsendq", me->softsendqmax, ServerInstance->Config->Limits.MaxLine);
me->hardsendqmax = tag->getUInt("hardsendq", me->hardsendqmax, ServerInstance->Config->Limits.MaxLine);
me->recvqmax = tag->getUInt("recvq", me->recvqmax, ServerInstance->Config->Limits.MaxLine);
me->penaltythreshold = tag->getUInt("threshold", me->penaltythreshold, 1);
me->commandrate = tag->getUInt("commandrate", me->commandrate, 1);
me->fakelag = tag->getBool("fakelag", me->fakelag);
me->maxlocal = tag->getUInt("localmax", me->maxlocal);
me->maxglobal = tag->getUInt("globalmax", me->maxglobal);
me->maxlocal = tag->getUInt("localmax", me->maxlocal, 1);
me->maxglobal = tag->getUInt("globalmax", me->maxglobal, 1);
me->maxchans = tag->getUInt("maxchans", me->maxchans);
me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
me->limit = tag->getUInt("limit", me->limit);
me->limit = tag->getUInt("limit", me->limit, 1);
me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
me->uniqueusername = tag->getBool("uniqueusername", me->uniqueusername);
me->password = tag->getString("password", me->password);
Expand Down

0 comments on commit 460220f

Please sign in to comment.