Remove duplicated settings now solely defined by the <connect> class

This commit is contained in:
Daniel De Graaf 2010-08-13 16:56:24 -04:00
parent 250c206a8b
commit 7cfd4039ca
9 changed files with 38 additions and 72 deletions

View File

@ -378,6 +378,12 @@
# module be loaded as well.
modes="+x">
# Connect classes can also be assigned upon /OPER, or by modules like m_sqlauth.
# Classes with only a name (no allow=/deny=) are allowed for this use; they never match new users.
<connect name="OperOnlyClass"
# some higher limits for opers
commandrate="50000" maxchans="100" hardsendq="10485760">
#-#-#-#-#-#-#-#-#-#-#-#- CIDR CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-
# #
@ -425,16 +431,6 @@
# not when the command is run.
#<execfiles rules="wget -O - http://www.example.com/rules.txt">
#-#-#-#-#-#-#-#-#-#-#-# MAXIMUM CHANNELS -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# #
<channels
# users: Maximum number of channels a user can be in at once.
users="20"
# opers: Maximum number of channels a oper can be in at once.
opers="60">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-# DNS SERVER -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# If these values are not defined, InspIRCd uses the default DNS resolver
# of your system.

View File

@ -24,14 +24,13 @@
# - servers/auspex: allows opers with this priv to see more detail about server information than normal users.
# ACTIONS:
# - users/mass-message: allows opers with this priv to PRIVMSG and NOTICE to a server mask (e.g. NOTICE $*)
# - channels/high-join-limit: allows opers with this priv to join <channels:opers> total channels instead of <channels:users> total channels.
# - channels/set-permanent: allows opers with this priv to set +P on channels with m_permchannels.
# PERMISSIONS:
# - users/flood/no-throttle: allows opers with this priv to send commands without being throttled (*NOTE)
# - users/flood/increased-buffers: allows opers with this priv to send and recieve data without worrying about being disconnected for exceeding limits (*NOTE)
# OVERRIDE:
# - override/<permname>: allows permisison to be overridden via m_override
#
# *NOTE: These privs are potantially dangerous, as they grant users with them the ability to hammer your server's CPU/RAM as much as they want, essentially.
privs="users/auspex channels/auspex servers/auspex users/mass-message channels/high-join-limit channels/set-permanent users/flood/no-throttle users/flood/increased-buffers"
# NOTE: many of the settings (channels/high-join-limit, users/flood/*) have changed to
# numerical settings in the <connect> class to allow them to be assigned to users.
#
privs="users/auspex channels/auspex servers/auspex users/mass-message channels/high-join-limit"
# usermodes: Oper-only usermodes that opers with this class can use.
usermodes="*"
@ -61,6 +60,9 @@
# classes: classes (above blocks) that this type belongs to.
classes="OperChat BanControl HostCloak Shutdown ServerLink"
# class: A named <connect> class for this oper; use to raise general user limits
class="OperOnlyClass"
# vhost: host oper gets on oper-up. This is optional.
vhost="netadmin.omega.org.za"

View File

@ -479,14 +479,6 @@ class CoreExport ServerConfig
ConfigTagIndex oper_classes;
/** Max channels per user
*/
unsigned int MaxChans;
/** Oper max channels per user
*/
unsigned int OperMaxChans;
/** TS6-like server ID.
* NOTE: 000...999 are usable for InspIRCd servers. This
* makes code simpler. 0AA, 1BB etc with letters are reserved

View File

@ -209,30 +209,19 @@ Channel* Channel::JoinUser(User *user, const std::string& cn, bool override, con
/*
* We don't restrict the number of channels that remote users or users that are override-joining may be in.
* We restrict local users to MaxChans channels.
* We restrict local operators to OperMaxChans channels.
* We restrict local users to the maximum defined in their <connect> block
* This is a lot more logical than how it was formerly. -- w00t
*/
if (IS_LOCAL(user) && !override)
{
if (user->HasPrivPermission("channels/high-join-limit"))
unsigned int maxchans = user->GetClass()->maxchans;
// default if not set in <connect> is 20
if (!maxchans)
maxchans = 20;
if (user->chans.size() >= maxchans)
{
if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
{
user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn.c_str());
return NULL;
}
}
else
{
unsigned int maxchans = user->GetClass()->maxchans;
if (!maxchans)
maxchans = ServerInstance->Config->MaxChans;
if (user->chans.size() >= maxchans)
{
user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn.c_str());
return NULL;
}
user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn.c_str());
return NULL;
}
}

View File

@ -191,14 +191,7 @@ bool CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
/* find the command, check it exists */
Commandtable::iterator cm = cmdlist.find(command);
/* Modify the user's penalty regardless of whether or not the command exists */
bool do_more = true;
if (!user->HasPrivPermission("users/flood/no-throttle"))
{
// If it *doesn't* exist, give it a slightly heftier penalty than normal to deter flooding us crap
user->CommandFloodPenalty += cm != cmdlist.end() ? cm->second->Penalty * 1000 : 2000;
}
if (cm == cmdlist.end())
{
@ -219,11 +212,16 @@ bool CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
{
if (user->registered == REG_ALL)
user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s %s :Unknown command",user->nick.c_str(),command.c_str());
// don't flood crap, please
user->CommandFloodPenalty += 2000;
ServerInstance->stats->statsUnknown++;
return true;
}
}
// account for the penalty of the command
user->CommandFloodPenalty += cm->second->Penalty * 1000;
if (cm->second->max_params && command_p.size() > cm->second->max_params)
{
/*

View File

@ -28,8 +28,6 @@ ServerConfig::ServerConfig()
NetBufferSize = 10240;
SoftLimit = ServerInstance->SE->GetMaxFds();
MaxConn = SOMAXCONN;
MaxChans = 20;
OperMaxChans = 30;
c_ipv4_range = 32;
c_ipv6_range = 128;
}
@ -431,8 +429,6 @@ void ServerConfig::Fill()
WhoWasGroupSize = ConfValue("whowas")->getInt("groupsize");
WhoWasMaxGroups = ConfValue("whowas")->getInt("maxgroups");
WhoWasMaxKeep = ServerInstance->Duration(ConfValue("whowas")->getString("maxkeep"));
MaxChans = ConfValue("channels")->getInt("users", 20);
OperMaxChans = ConfValue("channels")->getInt("opers", 60);
c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32);

View File

@ -229,7 +229,7 @@ class IdentRequestSocket : public EventHandler
/* Truncate the ident at any characters we don't like, skip leading spaces */
size_t k = 0;
for (const char *j = token.c_str(); *j && (k < ServerInstance->Config->Limits.IdentMax + 1); j++)
for (const char *j = token.c_str(); *j && (k++ < ServerInstance->Config->Limits.IdentMax); j++)
{
if (*j == ' ')
continue;
@ -244,7 +244,6 @@ class IdentRequestSocket : public EventHandler
break;
}
/* Re-check with IsIdent, in case that changes and this doesn't (paranoia!) */
if (!ident.empty() && ServerInstance->IsIdent(ident.c_str()))
{
result = ident;

View File

@ -75,7 +75,7 @@ void InspIRCd::BuildISupport()
{
// the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
std::stringstream v;
v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes - 1 << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax - 1;
v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes - 1 << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax - 1;
v << " CASEMAPPING=rfc1459 STATUSMSG=" << Modes->BuildPrefixes(false) << " CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic - 1 << " KICKLEN=" << Config->Limits.MaxKick - 1 << " MAXTARGETS=" << Config->MaxTargets - 1;
v << " AWAYLEN=" << Config->Limits.MaxAway - 1 << " CHANMODES=" << this->Modes->GiveModeList(MODETYPE_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
Config->data005 = v.str();

View File

@ -465,18 +465,14 @@ void UserIOHandler::OnDataReady()
if (user->quitting)
return;
if (recvq.length() > user->MyClass->recvqmax && !user->HasPrivPermission("users/flood/increased-buffers"))
if (recvq.length() > user->MyClass->recvqmax)
{
ServerInstance->Users->QuitUser(user, "RecvQ exceeded");
ServerInstance->SNO->WriteToSnoMask('a', "User %s RecvQ of %lu exceeds connect class maximum of %lu",
user->nick.c_str(), (unsigned long)recvq.length(), user->MyClass->recvqmax);
ServerInstance->SNO->WriteToSnoMask('a', "User %s RecvQ exceeds maximum of %lu (class %s)",
user->nick.c_str(), user->MyClass->recvqmax, user->MyClass->name.c_str());
}
unsigned long sendqmax = ULONG_MAX;
if (!user->HasPrivPermission("users/flood/increased-buffers"))
sendqmax = user->MyClass->softsendqmax;
unsigned long penaltymax = ULONG_MAX;
if (!user->HasPrivPermission("users/flood/no-fakelag"))
penaltymax = user->MyClass->penaltythreshold * 1000;
unsigned long sendqmax = user->MyClass->softsendqmax;
unsigned long penaltymax = user->MyClass->penaltythreshold * 1000;
while (user->CommandFloodPenalty < penaltymax && getSendQSize() < sendqmax)
{
@ -505,7 +501,6 @@ eol_found:
// just found a newline. Terminate the string, and pull it out of recvq
recvq = recvq.substr(qpos);
// TODO should this be moved to when it was inserted in recvq?
ServerInstance->stats->statsRecv += qpos;
user->bytes_in += qpos;
user->cmds_in++;
@ -523,16 +518,15 @@ eol_found:
void UserIOHandler::AddWriteBuf(const std::string &data)
{
if (!user->quitting && getSendQSize() + data.length() > user->MyClass->hardsendqmax &&
!user->HasPrivPermission("users/flood/increased-buffers"))
if (!user->quitting && getSendQSize() + data.length() > user->MyClass->hardsendqmax)
{
/*
* Quit the user FIRST, because otherwise we could recurse
* here and hit the same limit.
*/
ServerInstance->Users->QuitUser(user, "SendQ exceeded");
ServerInstance->SNO->WriteToSnoMask('a', "User %s SendQ exceeds connect class maximum of %lu",
user->nick.c_str(), user->MyClass->hardsendqmax);
ServerInstance->SNO->WriteToSnoMask('a', "User %s SendQ exceeds maximum of %lu (class %s)",
user->nick.c_str(), user->MyClass->hardsendqmax, user->MyClass->name.c_str());
return;
}