From 7cfd4039ca3a835abfa88dfd595187fb11aa6901 Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Fri, 13 Aug 2010 16:56:24 -0400 Subject: Remove duplicated settings now solely defined by the class --- src/channels.cpp | 27 ++++++++------------------- src/command_parse.cpp | 12 +++++------- src/configreader.cpp | 4 ---- src/modules/m_ident.cpp | 3 +-- src/server.cpp | 2 +- src/users.cpp | 22 ++++++++-------------- 6 files changed, 23 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/channels.cpp b/src/channels.cpp index ee9cb7227..1d614b1e4 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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 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 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; } } diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 729fd3089..c6afe8f86 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -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) { /* diff --git a/src/configreader.cpp b/src/configreader.cpp index afe05ea97..3c843f835 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -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); diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 6c1148cfc..a93c7ed22 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -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; diff --git a/src/server.cpp b/src/server.cpp index 3f86a348e..a52cde91f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -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(); diff --git a/src/users.cpp b/src/users.cpp index 8a239a2d8..1fc51661b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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; } -- cgit v1.3.1-10-gc9f91