1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __USERMANAGER_H
15 #define __USERMANAGER_H
19 /** A list of ip addresses cross referenced against clone counts */
20 typedef std::map<irc::string, unsigned int> clonemap;
22 class CoreExport UserManager : public classbase
25 InspIRCd *ServerInstance;
27 /** Map of local ip addresses for clone counting
29 clonemap local_clones;
31 UserManager(InspIRCd *Instance)
33 ServerInstance = Instance;
37 /** Client list, a hash_map containing all clients, local and remote
39 user_hash* clientlist;
41 /** Client list stored by UUID. Contains all clients, and is updated
42 * automatically by the constructor and destructor of User.
46 /** Local client list, a vector containing only local clients
48 std::vector<User*> local_users;
50 /** Oper list, a vector containing all local and remote opered users
52 std::list<User*> all_opers;
54 /** Number of unregistered users online right now.
55 * (Unregistered means before USER/NICK/dns)
57 int unregistered_count;
59 /** Map of global ip addresses for clone counting
60 * XXX - this should be private, but m_clones depends on it currently.
62 clonemap global_clones;
64 /** Add a client to the system.
65 * This will create a new User, insert it into the user_hash,
66 * initialize it as not yet registered, and add it to the socket engine.
67 * @param Instance a pointer to the server instance
68 * @param socket The socket id (file descriptor) this user is on
69 * @param port The port number this user connected on
70 * @param iscached This variable is reserved for future use
71 * @param ip The IP address of the user
72 * @return This function has no return value, but a call to AddClient may remove the user.
74 void AddUser(InspIRCd* Instance, int socket, int port, bool iscached, int socketfamily, sockaddr* ip, const std::string &targetip);
76 /** Disconnect a user gracefully
77 * @param user The user to remove
78 * @param r The quit reason to show to normal users
79 * @param oreason The quit reason to show to opers
80 * @return Although this function has no return type, on exit the user provided will no longer exist.
82 void QuitUser(User *user, const std::string &quitreason, const char* operreason = "");
84 /** Add a user to the local clone map
85 * @param user The user to add
87 void AddLocalClone(User *user);
89 /** Add a user to the global clone map
90 * @param user The user to add
92 void AddGlobalClone(User *user);
94 /** Remove all clone counts from the user, you should
95 * use this if you change the user's IP address
96 * after they have registered.
97 * @param user The user to remove
99 void RemoveCloneCounts(User *user);
101 /** Return the number of global clones of this user
102 * @param user The user to get a count for
103 * @return The global clone count of this user
105 unsigned long GlobalCloneCount(User *user);
107 /** Return the number of local clones of this user
108 * @param user The user to get a count for
109 * @return The local clone count of this user
111 unsigned long LocalCloneCount(User *user);
113 /** Return a count of users, unknown and known connections
114 * @return The number of users
116 unsigned int UserCount();
118 /** Return a count of fully registered connections only
119 * @return The number of registered users
121 unsigned int RegisteredUserCount();
123 /** Return a count of opered (umode +o) users only
124 * @return The number of opers
126 unsigned int OperCount();
128 /** Return a count of unregistered (before NICK/USER) users only
129 * @return The number of unregistered (unknown) connections
131 unsigned int UnregisteredUserCount();
133 /** Return a count of local users on this server only
134 * @return The number of local users
136 unsigned int LocalUserCount();
141 /** Number of users with a certain mode set on them
143 int ModeCount(const char mode);
145 /** Send a server notice to all local users
146 * @param text The text format string to send
147 * @param ... The format arguments
149 void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
151 /** Send a server message (PRIVMSG) to all local users
152 * @param text The text format string to send
153 * @param ... The format arguments
155 void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
157 /** Send text to all users with a specific set of modes
158 * @param modes The modes to check against, without a +, e.g. 'og'
159 * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
160 * mode characters in the first parameter causes receipt of the message, and
161 * if you specify WM_OR, all the modes must be present.
162 * @param text The text format string to send
163 * @param ... The format arguments
165 void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5);