#include "xline.h"
#include "bancache.h"
+UserManager::UserManager()
+ : unregistered_count(0), local_count(0)
+{
+}
+
/* add a client connection to the sockets list */
void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
{
this->unregistered_count++;
/* The users default nick is their UUID */
- New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
+ New->nick = New->uuid;
(*(this->clientlist))[New->nick] = New;
New->registered = REG_NONE;
- New->signon = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
+ New->signon = ServerInstance->Time();
New->lastping = 1;
ServerInstance->Users->AddLocalClone(New);
ServerInstance->Users->AddGlobalClone(New);
New->localuseriter = this->local_users.insert(local_users.end(), New);
+ local_count++;
if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds()))
{
ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString());
if (!ServerInstance->Config->MoronBanner.empty())
New->WriteServ("NOTICE %s :*** %s", New->nick.c_str(), ServerInstance->Config->MoronBanner.c_str());
- this->QuitUser(New, b->Reason);
+
+ if (ServerInstance->Config->HideBans)
+ this->QuitUser(New, b->Type + "-Lined", b->Reason.c_str());
+ else
+ this->QuitUser(New, b->Reason);
return;
}
else
{
ServerInstance->Logs->Log("USERS", DEBUG,"Internal error on new connection");
this->QuitUser(New, "Internal error handling connection");
+ return;
}
/* NOTE: even if dns lookups are *off*, we still need to display this.
{
if (user->quitting)
{
- ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a user (%s) twice. Did your module call QuitUser twice?", user->nick.c_str());
+ ServerInstance->Logs->Log("USERS", DEFAULT, "ERROR: Tried to quit quitting user: " + user->nick);
return;
}
if (IS_SERVER(user))
{
- ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a fake user (%s)", user->nick.c_str());
+ ServerInstance->Logs->Log("USERS", DEFAULT, "ERROR: Tried to quit server user: " + user->nick);
return;
}
if (iter != this->clientlist->end())
this->clientlist->erase(iter);
else
- ServerInstance->Logs->Log("USERS", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
+ ServerInstance->Logs->Log("USERS", DEFAULT, "ERROR: Nick not found in clientlist, cannot remove: " + user->nick);
ServerInstance->Users->uuidlist->erase(user->uuid);
}
}
}
+void UserManager::RehashCloneCounts()
+{
+ local_clones.clear();
+ global_clones.clear();
+
+ const user_hash& hash = *ServerInstance->Users->clientlist;
+ for (user_hash::const_iterator i = hash.begin(); i != hash.end(); ++i)
+ {
+ User* u = i->second;
+
+ if (IS_LOCAL(u))
+ AddLocalClone(u);
+ AddGlobalClone(u);
+ }
+}
+
unsigned long UserManager::GlobalCloneCount(User *user)
{
clonemap::iterator x = global_clones.find(user->GetCIDRMask());
unsigned int UserManager::LocalUserCount()
{
/* Doesnt count unregistered clients */
- return (this->local_users.size() - this->UnregisteredUserCount());
+ return (this->local_count - this->UnregisteredUserCount());
}
void UserManager::ServerNoticeAll(const char* text, ...)