From 8831595e1a5306f4204fedc6ecbc4a3c9299fb35 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 8 Jan 2023 16:12:43 +0000 Subject: Rework how users are assigned to connect classes. - Move core connect class checks and to the core_user module. - Add pre-change and post-change events for when a connect class changes. - Split explicit class changing out into its own method. - Remove the need to almost always call CheckClass after SetClass. - Add use counting to the connect class instead of relying on the shared_ptr use count. --- src/usermanager.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/usermanager.cpp') diff --git a/src/usermanager.cpp b/src/usermanager.cpp index bcb6e58d3..25fd9317e 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -173,12 +173,8 @@ void UserManager::AddUser(int socket, ListenSocket* via, const irc::sockets::soc return; } - // First class check. We do this again in LocalUser::FullConnect() after DNS is done, and NICK/USER is received. - New->SetClass(); - // If the user doesn't have an acceptable connect class CheckClass() quits them - New->CheckClass(ServerInstance->Config->CCOnConnect); - if (New->quitting) - return; + if (!New->FindConnectClass()) + return; // User does not match any connect classes. /* * even with bancache, we still have to keep User::exempt current. @@ -296,6 +292,8 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std user->GetIPString().c_str(), operquitmsg.c_str()); } local_users.erase(lu); + if (lu->GetClass()) + lu->GetClass()->use_count--; } if (!clientlist.erase(user->nick)) -- cgit v1.3.1-10-gc9f91