* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
break;
}
- *c++;
+ c++;
}
std::string s = this->FormatNoticeMasks();
return data;
}
-void User::DecrementModes()
-{
- ServerInstance->Logs->Log("USERS", DEBUG, "DecrementModes()");
- for (unsigned char n = 'A'; n <= 'z'; n++)
- {
- if (modes[n-65])
- {
- ServerInstance->Logs->Log("USERS", DEBUG,"DecrementModes() found mode %c", n);
- ModeHandler* mh = ServerInstance->Modes->FindMode(n, MODETYPE_USER);
- if (mh)
- {
- ServerInstance->Logs->Log("USERS", DEBUG,"Found handler %c and call ChangeCount", n);
- mh->ChangeCount(-1);
- }
- }
- }
-}
-
User::User(const std::string &uid, const std::string& sid, int type)
: uuid(uid), server(sid), usertype(type)
{
{
bytes_in = bytes_out = cmds_in = cmds_out = 0;
server_sa.sa.sa_family = AF_UNSPEC;
- Penalty = 0;
+ CommandFloodPenalty = 0;
lastping = nping = 0;
eh.SetFd(myfd);
memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
unsigned long sendqmax = ULONG_MAX;
if (!user->HasPrivPermission("users/flood/increased-buffers"))
sendqmax = user->MyClass->GetSendqSoftMax();
- int penaltymax = user->MyClass->GetPenaltyThreshold();
- if (penaltymax == 0 || user->HasPrivPermission("users/flood/no-fakelag"))
- penaltymax = INT_MAX;
+ unsigned long penaltymax = ULONG_MAX;
+ if (!user->HasPrivPermission("users/flood/no-fakelag"))
+ penaltymax = user->MyClass->GetPenaltyThreshold() * 1000;
- while (user->Penalty < penaltymax && getSendQSize() < sendqmax)
+ while (user->CommandFloodPenalty < penaltymax && getSendQSize() < sendqmax)
{
std::string line;
line.reserve(MAXBUF);
return;
}
// Add pseudo-penalty so that we continue processing after sendq recedes
- if (user->Penalty == 0 && getSendQSize() >= sendqmax)
- user->Penalty++;
+ if (user->CommandFloodPenalty == 0 && getSendQSize() >= sendqmax)
+ user->CommandFloodPenalty++;
+ if (user->CommandFloodPenalty >= penaltymax && !user->MyClass->fakelag)
+ ServerInstance->Users->QuitUser(user, "Excess Flood");
}
void UserIOHandler::AddWriteBuf(const std::string &data)
PurgeEmptyChannels();
this->InvalidateCache();
- this->DecrementModes();
if (client_sa.sa.sa_family != AF_UNSPEC)
ServerInstance->Users->RemoveCloneCounts(this);
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
- : config(tag), type(t), name("unnamed"), registration_timeout(0), host(mask),
- pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0),
- recvqmax(0), penaltythreshold(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
+ : config(tag), type(t), fakelag(true), name("unnamed"), registration_timeout(0), host(mask),
+ pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0), recvqmax(0),
+ penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
{
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, const ConnectClass& parent)
- : config(tag), type(t), name("unnamed"),
- registration_timeout(parent.registration_timeout), host(mask),
- pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash),
- softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax),
- recvqmax(parent.recvqmax), penaltythreshold(parent.penaltythreshold), maxlocal(parent.maxlocal),
- maxglobal(parent.maxglobal), maxchans(parent.maxchans),
+ : config(tag), type(t), fakelag(parent.fakelag), name("unnamed"),
+ registration_timeout(parent.registration_timeout), host(mask), pingtime(parent.pingtime),
+ pass(parent.pass), hash(parent.hash), softsendqmax(parent.softsendqmax),
+ hardsendqmax(parent.hardsendqmax), recvqmax(parent.recvqmax),
+ penaltythreshold(parent.penaltythreshold), commandrate(parent.commandrate),
+ maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), maxchans(parent.maxchans),
port(parent.port), limit(parent.limit)
{
}