16
16
#include "cull_list.h"
18
CullItem::CullItem(userrec* u, std::string &r, const char* o_reason)
23
/* Seperate oper reason not set, use the user reason */
25
this->oper_reason = o_reason;
27
this->oper_reason = r;
30
CullItem::CullItem(userrec* u, const char* r, const char* o_reason)
35
/* Seperate oper reason not set, use the user reason */
37
this->oper_reason = o_reason;
39
this->oper_reason = r;
42
void CullItem::MakeSilent()
47
bool CullItem::IsSilent()
56
userrec* CullItem::GetUser()
61
std::string& CullItem::GetReason()
66
std::string& CullItem::GetOperReason()
68
return this->oper_reason;
71
18
CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
77
23
void CullList::AddItem(userrec* user, std::string &reason, const char* o_reason)
83
29
void CullList::AddItem(userrec* user, const char* reason, const char* o_reason)
85
if (exempt.find(user) == exempt.end())
87
CullItem item(user, reason, o_reason);
34
user->quitting = true;
35
user->quitmsg = reason;
38
user->operquitmsg = reason;
40
user->operquitmsg = o_reason;
93
45
void CullList::MakeSilent(userrec* user)
95
for (std::vector<CullItem>::iterator a = list.begin(); a != list.end(); ++a)
97
if (a->GetUser() == user)
47
user->silentquit = true;
106
50
int CullList::Apply()
108
53
int n = list.size();
55
while (list.size() && i++ != 100)
111
std::vector<CullItem>::iterator a = list.begin();
113
user_hash::iterator iter = ServerInstance->clientlist->find(a->GetUser()->nick);
114
std::map<userrec*, userrec*>::iterator exemptiter = exempt.find(a->GetUser());
115
const char* preset_reason = a->GetUser()->GetOperQuit();
116
std::string reason = a->GetReason();
117
std::string oper_reason = *preset_reason ? preset_reason : a->GetOperReason();
57
std::vector<userrec *>::iterator li = list.begin();
60
user_hash::iterator iter = ServerInstance->clientlist->find(a->nick);
61
std::string reason = a->quitmsg;
62
std::string oper_reason = a->operquitmsg;
119
64
if (reason.length() > MAXQUIT - 1)
120
65
reason.resize(MAXQUIT - 1);
121
66
if (oper_reason.length() > MAXQUIT - 1)
122
67
oper_reason.resize(MAXQUIT - 1);
124
if (a->GetUser()->registered != REG_ALL)
69
if (a->registered != REG_ALL)
125
70
if (ServerInstance->unregistered_count)
126
71
ServerInstance->unregistered_count--;
128
if (IS_LOCAL(a->GetUser()))
130
if ((!a->GetUser()->sendq.empty()) && (!(*a->GetUser()->GetWriteError())))
131
a->GetUser()->FlushWriteBuf();
134
if (a->GetUser()->registered == REG_ALL)
136
FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(), reason, oper_reason));
137
a->GetUser()->PurgeEmptyChannels();
138
a->GetUser()->WriteCommonQuit(reason, oper_reason);
141
FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(a->GetUser()));
143
if (IS_LOCAL(a->GetUser()))
145
if (ServerInstance->Config->GetIOHook(a->GetUser()->GetPort()))
75
if ((!a->sendq.empty()) && (!(*a->GetWriteError())))
79
if (a->registered == REG_ALL)
81
FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a, reason, oper_reason));
82
a->PurgeEmptyChannels();
83
a->WriteCommonQuit(reason, oper_reason);
86
FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(a));
90
if (ServerInstance->Config->GetIOHook(a->GetPort()))
149
ServerInstance->Config->GetIOHook(a->GetUser()->GetPort())->OnRawSocketClose(a->GetUser()->GetFd());
94
ServerInstance->Config->GetIOHook(a->GetPort())->OnRawSocketClose(a->GetFd());
151
96
catch (CoreException& modexcept)
157
ServerInstance->SE->DelFd(a->GetUser());
158
a->GetUser()->CloseSocket();
102
ServerInstance->SE->DelFd(a);
162
107
* this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
163
108
* if they were an oper with +sn +qQ.
165
if (a->GetUser()->registered == REG_ALL)
110
if (a->registered == REG_ALL)
167
if (IS_LOCAL(a->GetUser()))
171
ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,oper_reason.c_str());
116
ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",a->nick,a->ident,a->host,oper_reason.c_str());
176
if ((!ServerInstance->SilentULine(a->GetUser()->server)) && (!a->IsSilent()))
121
if ((!ServerInstance->SilentULine(a->server)) && (!a->silentquit))
178
ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",a->GetUser()->server,a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,oper_reason.c_str());
123
ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",a->server,a->nick,a->ident,a->host,oper_reason.c_str());
181
a->GetUser()->AddToWhoWas();
184
129
if (iter != ServerInstance->clientlist->end())
186
if (IS_LOCAL(a->GetUser()))
188
std::vector<userrec*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),a->GetUser());
133
std::vector<userrec*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),a);
189
134
if (x != ServerInstance->local_users.end())
190
135
ServerInstance->local_users.erase(x);
192
137
ServerInstance->clientlist->erase(iter);
196
141
list.erase(list.begin());
197
exempt.erase(exemptiter);