2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 /** A list of ip addresses cross referenced against clone counts */
26 typedef std::map<irc::sockets::cidr_mask, unsigned int> clonemap;
28 class CoreExport UserManager
31 /** Map of local ip addresses for clone counting
33 clonemap local_clones;
37 for (user_hash::iterator i = clientlist->begin();i != clientlist->end();i++)
46 /** Client list, a hash_map containing all clients, local and remote
48 user_hash* clientlist;
50 /** Client list stored by UUID. Contains all clients, and is updated
51 * automatically by the constructor and destructor of User.
55 /** Local client list, a list containing only local clients
57 LocalUserList local_users;
59 /** Oper list, a vector containing all local and remote opered users
61 std::list<User*> all_opers;
63 /** Number of unregistered users online right now.
64 * (Unregistered means before USER/NICK/dns)
66 unsigned int unregistered_count;
68 /** Number of elements in local_users
70 unsigned int local_count;
72 /** Map of global ip addresses for clone counting
73 * XXX - this should be private, but m_clones depends on it currently.
75 clonemap global_clones;
77 /** Add a client to the system.
78 * This will create a new User, insert it into the user_hash,
79 * initialize it as not yet registered, and add it to the socket engine.
80 * @param socket The socket id (file descriptor) this user is on
81 * @param via The socket that this user connected using
82 * @param client The IP address and client port of the user
83 * @param server The server IP address and port used by the user
84 * @return This function has no return value, but a call to AddClient may remove the user.
86 void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
88 /** Disconnect a user gracefully
89 * @param user The user to remove
90 * @param quitreason The quit reason to show to normal users
91 * @param operreason The quit reason to show to opers
92 * @return Although this function has no return type, on exit the user provided will no longer exist.
94 void QuitUser(User *user, const std::string &quitreason, const char* operreason = "");
96 /** Add a user to the local clone map
97 * @param user The user to add
99 void AddLocalClone(User *user);
101 /** Add a user to the global clone map
102 * @param user The user to add
104 void AddGlobalClone(User *user);
106 /** Remove all clone counts from the user, you should
107 * use this if you change the user's IP address
108 * after they have registered.
109 * @param user The user to remove
111 void RemoveCloneCounts(User *user);
113 /** Return the number of global clones of this user
114 * @param user The user to get a count for
115 * @return The global clone count of this user
117 unsigned long GlobalCloneCount(User *user);
119 /** Return the number of local clones of this user
120 * @param user The user to get a count for
121 * @return The local clone count of this user
123 unsigned long LocalCloneCount(User *user);
125 /** Return a count of users, unknown and known connections
126 * @return The number of users
128 unsigned int UserCount();
130 /** Return a count of fully registered connections only
131 * @return The number of registered users
133 unsigned int RegisteredUserCount();
135 /** Return a count of opered (umode +o) users only
136 * @return The number of opers
138 unsigned int OperCount();
140 /** Return a count of unregistered (before NICK/USER) users only
141 * @return The number of unregistered (unknown) connections
143 unsigned int UnregisteredUserCount();
145 /** Return a count of local users on this server only
146 * @return The number of local users
148 unsigned int LocalUserCount();
153 /** Number of users with a certain mode set on them
155 int ModeCount(const char mode);
157 /** Send a server notice to all local users
158 * @param text The text format string to send
159 * @param ... The format arguments
161 void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
163 /** Send a server message (PRIVMSG) to all local users
164 * @param text The text format string to send
165 * @param ... The format arguments
167 void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);