X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=2d9c3f281c3953aeb2ad29119e7826c2158c7e0f;hb=bb3aa2fb37071f48a5312df8688c0a6990644fbb;hp=b6a33d2c48c0f3eae4a1b7cbd11450a1161932d0;hpb=20ea635c9fcd0d559ff6fc2863ab581591bc4ef8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index b6a33d2c4..2d9c3f281 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -73,7 +73,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs 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())) { @@ -108,7 +108,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs 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", 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); @@ -116,7 +116,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs } else { - ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Negative hit for ") + New->GetIPString()); + ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Negative hit for " + New->GetIPString()); } } else @@ -147,6 +147,9 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs 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) @@ -217,7 +220,7 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char if (!user->quietquit) { ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", - user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str()); + user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str()); } } else @@ -225,10 +228,9 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit)) { ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s (%s) [%s]", - user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str()); + 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); @@ -346,7 +348,7 @@ void UserManager::ServerNoticeAll(const char* text, ...) snprintf(formatbuffer,MAXBUF,"NOTICE $%s :%s", ServerInstance->Config->ServerName.c_str(), textbuffer); - for (std::vector::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)); @@ -367,7 +369,7 @@ void UserManager::ServerPrivmsgAll(const char* text, ...) snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s", ServerInstance->Config->ServerName.c_str(), textbuffer); - for (std::vector::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)); @@ -387,3 +389,14 @@ int UserManager::ModeCount(const char mode) } 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(); + } +}