InspIRCd  3.0
usermanager.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2015 Adam <[email protected]>
5  * Copyright (C) 2013-2016 Attila Molnar <[email protected]>
6  * Copyright (C) 2012-2013, 2017, 2019 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 
52 
53  private:
56  CloneMap clonemap;
57 
60  const CloneCounts zeroclonecounts;
61 
64  LocalList local_users;
65 
69  already_sent_t already_sent_id;
70 
71  public:
74  UserManager();
75 
78  ~UserManager();
79 
82  user_hash clientlist;
83 
86  user_hash uuidlist;
87 
91 
95  unsigned int unregistered_count;
96 
98  unsigned int uline_count;
99 
103  void DoBackgroundUserStuff();
104 
116  void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
117 
124  void QuitUser(User* user, const std::string& quitreason, const std::string* operreason = NULL);
125 
129  void AddClone(User* user);
130 
136  void RemoveCloneCounts(User *user);
137 
140  void RehashCloneCounts();
141 
148  const CloneCounts& GetCloneCounts(User* user) const;
149 
153  const CloneMap& GetCloneMap() const { return clonemap; }
154 
158  unsigned int UserCount() const { return this->clientlist.size(); }
159 
163  unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount() - this->ULineCount(); }
164 
168  unsigned int OperCount() const { return this->all_opers.size(); }
169 
173  unsigned int UnregisteredUserCount() const { return this->unregistered_count; }
174 
178  unsigned int ULineCount() const { return this->uline_count; }
179 
183  unsigned int LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
184 
188  user_hash& GetUsers() { return clientlist; }
189 
193  const LocalList& GetLocalUsers() const { return local_users; }
194 
199  void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
200 
204  already_sent_t NextAlreadySentId();
205 };
fakederef
Definition: inspircd.h:71
UserManager::clientlist
user_hash clientlist
Definition: usermanager.h:82
UserManager::uline_count
unsigned int uline_count
Definition: usermanager.h:98
UserManager::GetUsers
user_hash & GetUsers()
Definition: usermanager.h:188
UserManager::unregistered_count
unsigned int unregistered_count
Definition: usermanager.h:95
UserManager::ULineCount
unsigned int ULineCount() const
Definition: usermanager.h:178
UserManager::LocalList
insp::intrusive_list< LocalUser > LocalList
Definition: usermanager.h:51
irc::sockets::sockaddrs
Definition: socket.h:62
UserManager::all_opers
OperList all_opers
Definition: usermanager.h:90
UserManager::UnregisteredUserCount
unsigned int UnregisteredUserCount() const
Definition: usermanager.h:173
insp::intrusive_list< LocalUser >
UserManager
Definition: usermanager.h:31
UserManager::OperList
std::vector< User * > OperList
Definition: usermanager.h:47
UserManager::OperCount
unsigned int OperCount() const
Definition: usermanager.h:168
User
Definition: users.h:233
UserManager::uuidlist
user_hash uuidlist
Definition: usermanager.h:86
UserManager::GetCloneMap
const CloneMap & GetCloneMap() const
Definition: usermanager.h:153
UserManager::RegisteredUserCount
unsigned int RegisteredUserCount()
Definition: usermanager.h:163
UserManager::GetLocalUsers
const LocalList & GetLocalUsers() const
Definition: usermanager.h:193
UserManager::LocalUserCount
unsigned int LocalUserCount() const
Definition: usermanager.h:183
UserManager::CloneMap
std::map< irc::sockets::cidr_mask, CloneCounts > CloneMap
Definition: usermanager.h:43
ListenSocket
Definition: socket.h:173
UserManager::CloneCounts
Definition: usermanager.h:34
UserManager::UserCount
unsigned int UserCount() const
Definition: usermanager.h:158