InspIRCd  3.0
usermanager.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2015 Adam <[email protected]>
5  * Copyright (C) 2012-2016 Attila Molnar <[email protected]>
6  * Copyright (C) 2012-2013, 2017, 2019-2020 Sadie Powell <[email protected]>
7  * Copyright (C) 2012 Robby <[email protected]>
8  * Copyright (C) 2010 Craig Edwards <[email protected]>
9  * Copyright (C) 2009 Daniel De Graaf <[email protected]>
10  * Copyright (C) 2008 Thomas Stagner <[email protected]>
11  * Copyright (C) 2008 Robin Burchell <[email protected]>
12  *
13  * This file is part of InspIRCd. InspIRCd is free software: you can
14  * redistribute it and/or modify it under the terms of the GNU General Public
15  * License as published by the Free Software Foundation, version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 #include <list>
30 
31 class CoreExport UserManager : public fakederef<UserManager>
32 {
33  public:
34  struct CloneCounts
35  {
36  unsigned int global;
37  unsigned int local;
38  CloneCounts() : global(0), local(0) { }
39  };
40 
43  typedef std::map<irc::sockets::cidr_mask, CloneCounts> CloneMap;
44 
47  typedef std::vector<User*> OperList;
48 
50  typedef std::vector<User*> ULineList;
51 
55 
56  private:
59  CloneMap clonemap;
60 
63  const CloneCounts zeroclonecounts;
64 
67  LocalList local_users;
68 
72  already_sent_t already_sent_id;
73 
74  public:
77  UserManager();
78 
81  ~UserManager();
82 
85  user_hash clientlist;
86 
89  user_hash uuidlist;
90 
94 
97 
101  unsigned int unregistered_count;
102 
106  void DoBackgroundUserStuff();
107 
119  void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
120 
127  void QuitUser(User* user, const std::string& quitreason, const std::string* operreason = NULL);
128 
132  void AddClone(User* user);
133 
139  void RemoveCloneCounts(User *user);
140 
143  void RehashCloneCounts();
144 
151  const CloneCounts& GetCloneCounts(User* user) const;
152 
156  const CloneMap& GetCloneMap() const { return clonemap; }
157 
161  unsigned int UserCount() const { return this->clientlist.size(); }
162 
166  unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount() - this->ULineCount(); }
167 
171  unsigned int OperCount() const { return this->all_opers.size(); }
172 
176  unsigned int UnregisteredUserCount() const { return this->unregistered_count; }
177 
181  unsigned int ULineCount() const { return this->all_ulines.size(); }
182 
186  unsigned int LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
187 
191  user_hash& GetUsers() { return clientlist; }
192 
196  const LocalList& GetLocalUsers() const { return local_users; }
197 
202  void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
203 
207  already_sent_t NextAlreadySentId();
208 };
Definition: socket.h:173
Definition: users.h:244
Definition: usermanager.h:32
user_hash & GetUsers()
Definition: usermanager.h:191
const CloneMap & GetCloneMap() const
Definition: usermanager.h:156
unsigned int unregistered_count
Definition: usermanager.h:101
unsigned int ULineCount() const
Definition: usermanager.h:181
const LocalList & GetLocalUsers() const
Definition: usermanager.h:196
user_hash uuidlist
Definition: usermanager.h:89
user_hash clientlist
Definition: usermanager.h:85
OperList all_opers
Definition: usermanager.h:93
unsigned int OperCount() const
Definition: usermanager.h:171
unsigned int UnregisteredUserCount() const
Definition: usermanager.h:176
std::vector< User * > ULineList
Definition: usermanager.h:50
std::vector< User * > OperList
Definition: usermanager.h:47
unsigned int UserCount() const
Definition: usermanager.h:161
unsigned int RegisteredUserCount()
Definition: usermanager.h:166
ULineList all_ulines
Definition: usermanager.h:96
insp::intrusive_list< LocalUser > LocalList
Definition: usermanager.h:54
unsigned int LocalUserCount() const
Definition: usermanager.h:186
std::map< irc::sockets::cidr_mask, CloneCounts > CloneMap
Definition: usermanager.h:43
Definition: usermanager.h:35
Definition: inspircd.h:72
Definition: socket.h:63