1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "cull_list.h"
19 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
24 void CullList::AddItem(User* user)
29 void CullList::MakeSilent(User* user)
31 user->quietquit = true;
40 while (list.size() && i++ != 100)
42 std::vector<User *>::iterator a = list.begin();
45 user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->nick);
46 const std::string& preset_reason = u->GetOperQuit();
48 std::string oper_reason;
50 reason.assign(u->quitmsg, 0, ServerInstance->Config->Limits.MaxQuit);
51 oper_reason.assign(preset_reason.empty() ? preset_reason : u->operquitmsg, 0, ServerInstance->Config->Limits.MaxQuit);
53 if (u->registered != REG_ALL)
54 if (ServerInstance->Users->unregistered_count)
55 ServerInstance->Users->unregistered_count--;
59 if (!u->sendq.empty())
63 if (u->registered == REG_ALL)
65 FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(u, reason, oper_reason));
66 u->PurgeEmptyChannels();
67 u->WriteCommonQuit(reason, oper_reason);
70 FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(u));
78 u->GetIOHook()->OnRawSocketClose(u->GetFd());
80 catch (CoreException& modexcept)
82 ServerInstance->Logs->Log("CULLLIST",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
86 ServerInstance->SE->DelFd(u);
91 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
92 * if they were an oper with +sn +qQ.
94 if (u->registered == REG_ALL)
100 ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]", u->nick.c_str(), u->ident.c_str(), u->host.c_str(), oper_reason.c_str());
105 if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit))
107 ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]", u->server, u->nick.c_str(), u->ident.c_str(), u->host.c_str(), oper_reason.c_str());
113 if (iter != ServerInstance->Users->clientlist->end())
115 ServerInstance->Users->clientlist->erase(iter);
119 ServerInstance->Logs->Log("CULLLIST", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
124 std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u);
125 if (x != ServerInstance->Users->local_users.end())
126 ServerInstance->Users->local_users.erase(x);
129 ServerInstance->Logs->Log("CULLLIST", DEBUG, "Failed to remove user from vector..");
134 list.erase(list.begin());