1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
14 /* $Core: libIRCDcull_list */
17 #include "cull_list.h"
19 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
24 void CullList::AddItem(User* user)
32 void CullList::MakeSilent(User* user)
34 user->quietquit = true;
43 while (list.size() && i++ != 100)
45 std::vector<User *>::iterator a = list.begin();
48 user_hash::iterator iter = ServerInstance->clientlist->find(u->nick);
49 const char* preset_reason = u->GetOperQuit();
50 std::string reason = u->operquitmsg;
51 std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg;
53 if (reason.length() > MAXQUIT - 1)
54 reason.resize(MAXQUIT - 1);
55 if (oper_reason.length() > MAXQUIT - 1)
56 oper_reason.resize(MAXQUIT - 1);
58 if (u->registered != REG_ALL)
59 if (ServerInstance->unregistered_count)
60 ServerInstance->unregistered_count--;
64 if ((!u->sendq.empty()) && (!(*u->GetWriteError())))
68 if (u->registered == REG_ALL)
70 FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(u, reason, oper_reason));
71 u->PurgeEmptyChannels();
72 u->WriteCommonQuit(reason, oper_reason);
75 FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(u));
79 if (ServerInstance->Config->GetIOHook(u->GetPort()))
83 ServerInstance->Config->GetIOHook(u->GetPort())->OnRawSocketClose(u->GetFd());
85 catch (CoreException& modexcept)
87 ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
91 ServerInstance->SE->DelFd(u);
96 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
97 * if they were an oper with +sn +qQ.
99 if (u->registered == REG_ALL)
105 ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick,u->ident,u->host,oper_reason.c_str());
110 if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit))
112 ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",u->server,u->nick,u->ident,u->host,oper_reason.c_str());
118 if (iter != ServerInstance->clientlist->end())
122 std::vector<User*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),u);
123 if (x != ServerInstance->local_users.end())
124 ServerInstance->local_users.erase(x);
126 ServerInstance->clientlist->erase(iter);
130 list.erase(list.begin());