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 AddClient(InspIRCd* Instance, int socket, int port, bool iscached, int socketfamily, sockaddr* ip, const std::string &targetip);
76 /** Add a user to the local clone map
77 * @param user The user to add
79 void AddLocalClone(User *user);
81 /** Add a user to the global clone map
82 * @param user The user to add
84 void AddGlobalClone(User *user);
86 /** Remove all clone counts from the user, you should
87 * use this if you change the user's IP address
88 * after they have registered.
89 * @param user The user to remove
91 void RemoveCloneCounts(User *user);
93 /** Return the number of global clones of this user
94 * @param user The user to get a count for
95 * @return The global clone count of this user
97 unsigned long GlobalCloneCount(User *user);
99 /** Return the number of local clones of this user
100 * @param user The user to get a count for
101 * @return The local clone count of this user
103 unsigned long LocalCloneCount(User *user);
105 /** Return a count of users, unknown and known connections
106 * @return The number of users
108 unsigned int UserCount();
110 /** Return a count of fully registered connections only
111 * @return The number of registered users
113 unsigned int RegisteredUserCount();
115 /** Return a count of opered (umode +o) users only
116 * @return The number of opers
118 unsigned int OperCount();
120 /** Return a count of unregistered (before NICK/USER) users only
121 * @return The number of unregistered (unknown) connections
123 unsigned int UnregisteredUserCount();
125 /** Return a count of local users on this server only
126 * @return The number of local users
128 unsigned int LocalUserCount();
133 /** Number of users with a certain mode set on them
135 int ModeCount(const char mode);
137 /** Send a server notice to all local users
138 * @param text The text format string to send
139 * @param ... The format arguments
141 void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
143 /** Send a server message (PRIVMSG) to all local users
144 * @param text The text format string to send
145 * @param ... The format arguments
147 void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
149 /** Send text to all users with a specific set of modes
150 * @param modes The modes to check against, without a +, e.g. 'og'
151 * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
152 * mode characters in the first parameter causes receipt of the message, and
153 * if you specify WM_OR, all the modes must be present.
154 * @param text The text format string to send
155 * @param ... The format arguments
157 void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5);