X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=2189b1c8ad22be3320ae8eb04ce83611420f2805;hb=a69a7d1dd17065764cec9a0d36ea7626d7945d04;hp=a31ac086e8e728c260078dc4b8082a732fe2cbce;hpb=c4cb1f9477b1fbf8662bedb1c36f84ff6f87e1f3;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index a31ac086e..2189b1c8a 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -171,27 +171,30 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char return; } + if (IS_FAKE(user)) + { + ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a fake user (%s)", user->nick.c_str()); + return; + } + + if (IS_FAKE(user)) + { + ServerInstance->Logs->Log("CULLLIST",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'", 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()); - user->quietquit = false; - user->quitmsg = quitreason; - std::string reason; std::string oper_reason; reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit); - if (!*operreason) - { - user->operquitmsg = quitreason; - oper_reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit); - } - else - { - user->operquitmsg = operreason; + if (operreason && *operreason) oper_reason.assign(operreason, 0, ServerInstance->Config->Limits.MaxQuit); - } + else + oper_reason = quitreason; ServerInstance->GlobalCulls.AddItem(user); @@ -204,8 +207,73 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(user)); - // Move the user onto their UID, to allow nick to be reused immediately user->UpdateNickHash(user->uuid.c_str()); + + user_hash::iterator iter = this->clientlist->find(user->uuid); + + if (user->registered != REG_ALL) + if (ServerInstance->Users->unregistered_count) + ServerInstance->Users->unregistered_count--; + + if (IS_LOCAL(user)) + { + if (!user->sendq.empty()) + user->FlushWriteBuf(); + + if (user->GetIOHook()) + { + try + { + user->GetIOHook()->OnRawSocketClose(user->GetFd()); + } + catch (CoreException& modexcept) + { + ServerInstance->Logs->Log("USERS",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason()); + } + } + + ServerInstance->SE->DelFd(user); + user->CloseSocket(); + } + + /* + * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything + * if they were an oper with +sn +qQ. + */ + if (user->registered == REG_ALL) + { + if (IS_LOCAL(user)) + { + if (!user->quietquit) + { + ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]", + user->nick.c_str(), user->ident.c_str(), user->host.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]", + user->server, user->nick.c_str(), user->ident.c_str(), user->host.c_str(), oper_reason.c_str()); + } + } + user->AddToWhoWas(); + } + + 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.."); + + if (IS_LOCAL(user)) + { + std::vector::iterator x = find(local_users.begin(),local_users.end(),user); + if (x != local_users.end()) + local_users.erase(x); + else + ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector"); + } }