From d7a0cd3db1e8b64a6f706f1831e645ad69aa7927 Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 9 Apr 2008 15:34:54 +0000 Subject: Move QuitUser into UserManager class, and unstaticize it. This prepares for some benchmarking lulz on object pooling I plan to do today, as well as making more sense now we *have* a manager class git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9442 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/usermanager.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/usermanager.cpp') diff --git a/src/usermanager.cpp b/src/usermanager.cpp index ecbd683b7..6385fb929 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -96,7 +96,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac if (!i) { - User::QuitUser(Instance, New, "Access denied by configuration"); + this->QuitUser(New, "Access denied by configuration"); return; } @@ -111,7 +111,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac if ((this->local_users.size() > Instance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)Instance->SE->GetMaxFds())) { Instance->SNO->WriteToSnoMask('A', "Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit); - User::QuitUser(Instance, New,"No more connections allowed"); + this->QuitUser(New,"No more connections allowed"); return; } @@ -127,7 +127,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac */ if (socket >= Instance->SE->GetMaxFds()) { - User::QuitUser(Instance, New, "Server is full"); + this->QuitUser(New, "Server is full"); return; } @@ -146,7 +146,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac Instance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString()); if (*Instance->Config->MoronBanner) New->WriteServ("NOTICE %s :*** %s", New->nick, Instance->Config->MoronBanner); - User::QuitUser(Instance, New, b->Reason); + this->QuitUser(New, b->Reason); return; } else @@ -171,7 +171,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac if (!Instance->SE->AddFd(New)) { Instance->Logs->Log("USERS", DEBUG,"Internal error on new connection"); - User::QuitUser(Instance, New, "Internal error handling connection"); + this->QuitUser(New, "Internal error handling connection"); } /* NOTE: even if dns lookups are *off*, we still need to display this. @@ -189,6 +189,22 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac } } +void UserManager::QuitUser(User *user, const std::string &quitreason, const char* operreason) +{ + ServerInstance->Logs->Log("USERS", DEBUG,"QuitUser: %s '%s'", user->nick, quitreason.c_str()); + user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident, user->host, *operreason ? operreason : quitreason.c_str()); + user->quietquit = false; + user->quitmsg = quitreason; + + if (!*operreason) + user->operquitmsg = quitreason; + else + user->operquitmsg = operreason; + + ServerInstance->GlobalCulls.AddItem(user); +} + + void UserManager::AddLocalClone(User *user) { clonemap::iterator x = local_clones.find(user->GetIPString()); -- cgit v1.2.3