X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=4ebc3b5834be57142002bb52b983e6a579279b81;hb=bd1471bc08be28bc2554d35fdaeb078338b14266;hp=37f64b9d2904d6d3b701f12c67bca2f721316a1a;hpb=467b276d9d0407ec412262525c43c28d47fdae2f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 37f64b9d2..4ebc3b583 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -24,6 +24,30 @@ #include "xline.h" #include "iohook.h" +namespace +{ + class WriteCommonQuit : public User::ForEachNeighborHandler + { + std::string line; + std::string operline; + + void Execute(LocalUser* user) CXX11_OVERRIDE + { + user->Write(user->IsOper() ? operline : line); + } + + public: + WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg) + : line(":" + user->GetFullHost() + " QUIT :") + , operline(line) + { + line += msg; + operline += opermsg; + user->ForEachNeighbor(*this, false); + } + }; +} + UserManager::UserManager() : unregistered_count(0) { @@ -69,7 +93,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs this->clientlist[New->nick] = New; New->registered = REG_NONE; - New->signon = ServerInstance->Time() + ServerInstance->Config->dns_timeout; + New->signon = ServerInstance->Time(); New->lastping = 1; this->AddClone(New); @@ -112,7 +136,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs /* user banned */ ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString()); if (!ServerInstance->Config->XLineMessage.empty()) - New->WriteNotice("*** " + ServerInstance->Config->XLineMessage); + New->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage); this->QuitUser(New, b->Reason); return; } @@ -180,7 +204,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: if (user->registered == REG_ALL) { FOREACH_MOD(OnUserQuit, (user, reason, *operreason)); - user->WriteCommonQuit(reason, *operreason); + WriteCommonQuit(user, reason, *operreason); } else unregistered_count--; @@ -193,6 +217,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: if (lu->registered == REG_ALL) ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", user->GetFullRealHost().c_str(), user->GetIPString().c_str(), operreason->c_str()); + local_users.erase(lu); } if (!clientlist.erase(user->nick)) @@ -229,6 +254,18 @@ void UserManager::RemoveCloneCounts(User *user) } } +void UserManager::RehashCloneCounts() +{ + clonemap.clear(); + + const user_hash& hash = ServerInstance->Users.GetUsers(); + for (user_hash::const_iterator i = hash.begin(); i != hash.end(); ++i) + { + User* u = i->second; + AddClone(u); + } +} + const UserManager::CloneCounts& UserManager::GetCloneCounts(User* user) const { CloneMap::const_iterator it = clonemap.find(user->GetCIDRMask()); @@ -244,7 +281,7 @@ void UserManager::ServerNoticeAll(const char* text, ...) VAFORMAT(message, text, text); message = "NOTICE $" + ServerInstance->Config->ServerName + " :" + message; - for (LocalUserList::const_iterator i = local_users.begin(); i != local_users.end(); i++) + for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) { User* t = *i; t->WriteServ(message); @@ -255,7 +292,7 @@ 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++) + for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) { (**i).already_sent = 0; (**i).RemoveExpiredInvites(); @@ -283,13 +320,10 @@ void UserManager::DoBackgroundUserStuff() /* * loop over all local users.. */ - for (LocalUserList::iterator i = local_users.begin(); i != local_users.end(); ++i) + for (LocalList::iterator i = local_users.begin(); i != local_users.end(); ++i) { LocalUser* curr = *i; - if (curr->quitting) - continue; - if (curr->CommandFloodPenalty || curr->eh.getSendQSize()) { unsigned int rate = curr->MyClass->GetCommandRate(); @@ -303,7 +337,7 @@ void UserManager::DoBackgroundUserStuff() switch (curr->registered) { case REG_ALL: - if (ServerInstance->Time() > curr->nping) + if (ServerInstance->Time() >= curr->nping) { // This user didn't answer the last ping, remove them if (!curr->lastping) @@ -326,10 +360,15 @@ void UserManager::DoBackgroundUserStuff() curr->FullConnect(); continue; } + + // If the user has been quit in OnCheckReady then we shouldn't + // quit them again for having a registration timeout. + if (curr->quitting) + continue; break; } - if (curr->registered != REG_ALL && (ServerInstance->Time() > (curr->age + curr->MyClass->GetRegTimeout()))) + if (curr->registered != REG_ALL && curr->MyClass && (ServerInstance->Time() > (curr->signon + curr->MyClass->GetRegTimeout()))) { /* * registration timeout -- didnt send USER/NICK/HOST