}
catch (...)
{
- ServerInstance->Logs->Log("USERS", DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed.");
+ ServerInstance->Logs->Log("USERS", LOG_DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkeys have been unleashed.");
ServerInstance->SNO->WriteToSnoMask('a', "WARNING *** Duplicate UUID allocated!");
return;
}
}
catch (CoreException& modexcept)
{
- ServerInstance->Logs->Log("SOCKET", DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
}
}
- ServerInstance->Logs->Log("USERS", DEBUG,"New user fd: %d", socket);
+ ServerInstance->Logs->Log("USERS", LOG_DEBUG,"New user fd: %d", socket);
this->unregistered_count++;
New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
(*(this->clientlist))[New->nick] = New;
- New->ident.assign("unknown");
-
New->registered = REG_NONE;
New->signon = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
New->lastping = 1;
- /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
- New->dhost.assign(New->GetIPString(), 0, 64);
- New->host.assign(New->GetIPString(), 0, 64);
-
ServerInstance->Users->AddLocalClone(New);
ServerInstance->Users->AddGlobalClone(New);
- this->local_users.push_back(New);
+ New->localuseriter = this->local_users.insert(local_users.end(), New);
if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds()))
{
if (!b->Type.empty() && !New->exempt)
{
/* user banned */
- ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString());
+ ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "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);
}
else
{
- ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Negative hit for ") + New->GetIPString());
+ ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Negative hit for " + New->GetIPString());
}
}
else
if (!ServerInstance->SE->AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE))
{
- ServerInstance->Logs->Log("USERS", DEBUG,"Internal error on new connection");
+ ServerInstance->Logs->Log("USERS", LOG_DEBUG,"Internal error on new connection");
this->QuitUser(New, "Internal error handling connection");
}
if (ServerInstance->Config->RawLog)
New->WriteServ("NOTICE Auth :*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
+ FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(New));
+ if (New->quitting)
+ return;
+
FOREACH_MOD(I_OnUserInit,OnUserInit(New));
if (ServerInstance->Config->NoUserDns)
{
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("CULLLIST",LOG_DEBUG, "*** Warning *** - You tried to quit a user (%s) twice. Did your module call QuitUser twice?", user->nick.c_str());
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("CULLLIST",LOG_DEBUG, "*** Warning *** - You tried to quit a fake user (%s)", user->nick.c_str());
return;
}
user->quitting = true;
- ServerInstance->Logs->Log("USERS", DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
+ ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->host.c_str(), *operreason ? operreason : quitreason.c_str());
std::string reason;
{
if (!user->quietquit)
{
- ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s (%s) [%s]",
- user->nick.c_str(), user->ident.c_str(), user->host.c_str(), user->GetIPString(), oper_reason.c_str());
+ ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]",
+ user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str());
}
}
else
{
if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit))
{
- ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s (%s) [%s]",
- user->server.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str(), user->GetIPString(), oper_reason.c_str());
+ ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s (%s) [%s]",
+ user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str());
}
}
- user->AddToWhoWas();
}
user_hash::iterator iter = this->clientlist->find(user->nick);
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", LOG_DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
ServerInstance->Users->uuidlist->erase(user->uuid);
}
void UserManager::AddLocalClone(User *user)
{
- clonemap::iterator x;
- x = local_clones.find(user->GetCIDRMask());
- if (x != local_clones.end())
- x->second++;
- else
- local_clones[user->GetCIDRMask()] = 1;
+ local_clones[user->GetCIDRMask()]++;
}
void UserManager::AddGlobalClone(User *user)
{
- clonemap::iterator x;
-
- x = global_clones.find(user->GetCIDRMask());
- if (x != global_clones.end())
- x->second++;
- else
- global_clones[user->GetCIDRMask()] = 1;
+ global_clones[user->GetCIDRMask()]++;
}
void UserManager::RemoveCloneCounts(User *user)
snprintf(formatbuffer,MAXBUF,"NOTICE $%s :%s", ServerInstance->Config->ServerName.c_str(), textbuffer);
- for (std::vector<LocalUser*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ for (LocalUserList::const_iterator i = local_users.begin(); i != local_users.end(); i++)
{
User* t = *i;
t->WriteServ(std::string(formatbuffer));
snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s", ServerInstance->Config->ServerName.c_str(), textbuffer);
- for (std::vector<LocalUser*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ for (LocalUserList::const_iterator i = local_users.begin(); i != local_users.end(); i++)
{
User* t = *i;
t->WriteServ(std::string(formatbuffer));
}
return c;
}
+
+void UserManager::GarbageCollect()
+{
+ // Reset the already_sent IDs so we don't wrap it around and drop a message
+ LocalUser::already_sent_id = 0;
+ for (LocalUserList::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
+ {
+ (**i).already_sent = 0;
+ (**i).RemoveExpiredInvites();
+ }
+}