diff options
| author | 2025-10-26 17:47:14 +0000 | |
|---|---|---|
| committer | 2025-10-26 17:47:14 +0000 | |
| commit | a13e442599de6ee06f7a3e3357aa71375bc1422e (patch) | |
| tree | 38ba02c66640016e88cac129b2ce975474c792e9 /src/users.cpp | |
| parent | Start splitting the user I/O interface from the network socket. (diff) | |
Avoid duplicating some of the send/receive queue limiting code.
Diffstat (limited to 'src/users.cpp')
| -rw-r--r-- | src/users.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp index 2f9f70987..a57704879 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -651,6 +651,35 @@ void LocalUser::Send(ClientProtocol::Event& protoev, ClientProtocol::MessageList } } +bool LocalUserIO::CheckMaxRecvQ() const +{ + if (!user || !user->GetClass()) + return true; // Should never happen. + + if ((GetRecvQSize() > user->GetClass()->recvqmax) && !user->HasPrivPermission("users/flood/increased-buffers")) + { + ServerInstance->Users.QuitUser(user, "RecvQ exceeded"); + ServerInstance->SNO.WriteToSnoMask('a', "User {} RecvQ of {} exceeds connect class maximum of {}", + user->nick, GetRecvQSize(), user->GetClass()->recvqmax); + return false; + } + return true; +} + +bool LocalUserIO::CheckMaxSendQ(size_t extra) const +{ + if (!user || !user->GetClass()) + return true; // Should never happen. + + if ((GetSendQSize() + extra > user->GetClass()->hardsendqmax) && !user->HasPrivPermission("users/flood/increased-buffers")) + { + user->quitting_sendq = true; + ServerInstance->GlobalCulls.AddSQItem(user); + return false; + } + return true; +} + void User::WriteNumeric(const Numeric::Numeric& numeric) { LocalUser* const localuser = IS_LOCAL(this); |
