]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cull_list.cpp
Remove CullList rate limiting to fix UID collisions on large networks
[user/henk/code/inspircd.git] / src / cull_list.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $Core */
15
16 #include "inspircd.h"
17 #include "cull_list.h"
18
19 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
20 {
21         list.clear();
22 }
23
24 void CullList::AddItem(User* user)
25 {
26         list.push_back(user);
27 }
28
29 void CullList::MakeSilent(User* user)
30 {
31         user->quietquit = true;
32         return;
33 }
34
35 int CullList::Apply()
36 {
37         int n = list.size();
38
39         while (list.size())
40         {
41                 std::vector<User *>::iterator a = list.begin();
42
43                 User *u = (*a);
44                 // user has been moved onto their UID; that's why this isn't find(u->nick)
45                 user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->uuid);
46
47                 if (u->registered != REG_ALL)
48                         if (ServerInstance->Users->unregistered_count)
49                                 ServerInstance->Users->unregistered_count--;
50
51                 if (IS_LOCAL(u))
52                 {
53                         if (!u->sendq.empty())
54                                 u->FlushWriteBuf();
55
56                         if (u->GetIOHook())
57                         {
58                                 try
59                                 {
60                                         u->GetIOHook()->OnRawSocketClose(u->GetFd());
61                                 }
62                                 catch (CoreException& modexcept)
63                                 {
64                                         ServerInstance->Logs->Log("CULLLIST",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
65                                 }
66                         }
67
68                         ServerInstance->SE->DelFd(u);
69                         u->CloseSocket();
70                 }
71
72                 /*
73                  * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
74                  * if they were an oper with +sn +qQ.
75                  */
76                 if (u->registered == REG_ALL)
77                 {
78                         if (IS_LOCAL(u))
79                         {
80                                 if (!u->quietquit)
81                                 {
82                                         ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]", u->nick.c_str(), u->ident.c_str(), u->host.c_str(), u->operquitmsg.c_str());
83                                 }
84                         }
85                         else
86                         {
87                                 if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit))
88                                 {
89                                         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(), u->operquitmsg.c_str());
90                                 }
91                         }
92                         u->AddToWhoWas();
93                 }
94
95                 if (iter != ServerInstance->Users->clientlist->end())
96                 {
97                         ServerInstance->Users->clientlist->erase(iter);
98                 }
99                 else
100                 {
101                         ServerInstance->Logs->Log("CULLLIST", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
102                 }
103
104                 if (IS_LOCAL(u))
105                 {
106                         std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u);
107                         if (x != ServerInstance->Users->local_users.end())
108                                 ServerInstance->Users->local_users.erase(x);
109                         else
110                         {
111                                 ServerInstance->Logs->Log("CULLLIST", DEBUG, "Failed to remove user from vector..");
112                         }
113                 }
114
115                 delete u;
116                 list.erase(list.begin());
117         }
118
119         return n;
120 }
121