1 |
adx |
30 |
/* |
2 |
michael |
2865 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
9857 |
* Copyright (c) 1997-2021 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
michael |
4565 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
adx |
30 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
1220 |
/*! \file client.h |
23 |
|
|
* \brief Header including structures, macros and prototypes for client handling |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
|
|
|
28 |
adx |
30 |
#ifndef INCLUDED_client_h |
29 |
|
|
#define INCLUDED_client_h |
30 |
|
|
|
31 |
michael |
1011 |
#include "list.h" |
32 |
adx |
30 |
#include "fdlist.h" |
33 |
|
|
#include "ircd_defs.h" |
34 |
|
|
#include "dbuf.h" |
35 |
michael |
3324 |
#include "auth.h" |
36 |
adx |
30 |
|
37 |
michael |
2811 |
|
38 |
adx |
30 |
/* |
39 |
|
|
* status macros. |
40 |
|
|
*/ |
41 |
michael |
6315 |
enum |
42 |
|
|
{ |
43 |
michael |
8437 |
STAT_CONNECTING = 1, |
44 |
michael |
8431 |
STAT_HANDSHAKE, |
45 |
|
|
STAT_ME, |
46 |
|
|
STAT_UNKNOWN, |
47 |
|
|
STAT_SERVER, |
48 |
|
|
STAT_CLIENT |
49 |
michael |
6315 |
}; |
50 |
adx |
30 |
|
51 |
michael |
6315 |
enum |
52 |
|
|
{ |
53 |
michael |
8431 |
REG_NEED_USER = 1 << 0, /**< User must send USER command */ |
54 |
|
|
REG_NEED_NICK = 1 << 1, /**< User must send NICK command */ |
55 |
|
|
REG_NEED_CAP = 1 << 2, /**< In middle of CAP negotiations */ |
56 |
michael |
6315 |
REG_INIT = REG_NEED_USER | REG_NEED_NICK |
57 |
|
|
}; |
58 |
michael |
503 |
|
59 |
michael |
5562 |
#define ID_or_name(x,client_p) ((IsServer(client_p->from) && (x)->id[0]) ? (x)->id : (x)->name) |
60 |
adx |
30 |
|
61 |
|
|
#define IsConnecting(x) ((x)->status == STAT_CONNECTING) |
62 |
|
|
#define IsHandshake(x) ((x)->status == STAT_HANDSHAKE) |
63 |
|
|
#define IsMe(x) ((x)->status == STAT_ME) |
64 |
|
|
#define IsUnknown(x) ((x)->status == STAT_UNKNOWN) |
65 |
|
|
#define IsServer(x) ((x)->status == STAT_SERVER) |
66 |
|
|
#define IsClient(x) ((x)->status == STAT_CLIENT) |
67 |
|
|
|
68 |
|
|
#define SetConnecting(x) {(x)->status = STAT_CONNECTING; \ |
69 |
michael |
2865 |
(x)->handler = UNREGISTERED_HANDLER; } |
70 |
adx |
30 |
|
71 |
|
|
#define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \ |
72 |
michael |
2865 |
(x)->handler = UNREGISTERED_HANDLER; } |
73 |
adx |
30 |
|
74 |
|
|
#define SetMe(x) {(x)->status = STAT_ME; \ |
75 |
michael |
2865 |
(x)->handler = UNREGISTERED_HANDLER; } |
76 |
adx |
30 |
|
77 |
|
|
#define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \ |
78 |
michael |
2865 |
(x)->handler = UNREGISTERED_HANDLER; } |
79 |
adx |
30 |
|
80 |
|
|
#define SetServer(x) {(x)->status = STAT_SERVER; \ |
81 |
michael |
2865 |
(x)->handler = SERVER_HANDLER; } |
82 |
adx |
30 |
|
83 |
|
|
#define SetClient(x) {(x)->status = STAT_CLIENT; \ |
84 |
michael |
6617 |
(x)->handler = CLIENT_HANDLER; } |
85 |
adx |
30 |
|
86 |
michael |
4588 |
#define MyConnect(x) ((x)->connection != NULL) |
87 |
michael |
1219 |
#define MyClient(x) (MyConnect(x) && IsClient(x)) |
88 |
adx |
30 |
|
89 |
|
|
/* |
90 |
|
|
* ts stuff |
91 |
|
|
*/ |
92 |
michael |
6315 |
enum |
93 |
|
|
{ |
94 |
|
|
TS_CURRENT = 6, /**< Current TS protocol version */ |
95 |
michael |
9834 |
TS_MINIMUM = 6, /**< Minimum supported TS protocol version */ |
96 |
michael |
6315 |
}; |
97 |
adx |
30 |
|
98 |
michael |
6315 |
enum |
99 |
|
|
{ |
100 |
michael |
8431 |
CAP_MULTI_PREFIX = 1 << 0, /**< ircv3.1 multi-prefix client capability */ |
101 |
|
|
CAP_AWAY_NOTIFY = 1 << 1, /**< ircv3.1 away-notify client capability */ |
102 |
|
|
CAP_UHNAMES = 1 << 2, /**< ircv3.2 userhost-in-names client capability */ |
103 |
|
|
CAP_EXTENDED_JOIN = 1 << 3, /**< ircv3.1 extended-join client capability */ |
104 |
|
|
CAP_ACCOUNT_NOTIFY = 1 << 4, /**< ircv3.1 account-notify client capability */ |
105 |
|
|
CAP_INVITE_NOTIFY = 1 << 5, /**< ircv3.2 invite-notify client capability */ |
106 |
michael |
9804 |
CAP_CHGHOST = 1 << 6, /**< ircv3.2 chghost client capability */ |
107 |
michael |
9811 |
CAP_CAP_NOTIFY = 1 << 7, /**< ircv3 CAP LS 302 cap-notify client capability */ |
108 |
michael |
6315 |
}; |
109 |
adx |
30 |
|
110 |
michael |
9799 |
#define HasCap(x, y) ((x)->connection->cap & (y)) |
111 |
michael |
1146 |
|
112 |
michael |
2910 |
|
113 |
adx |
30 |
/* housekeeping flags */ |
114 |
michael |
6315 |
enum |
115 |
|
|
{ |
116 |
michael |
8431 |
FLAGS_PINGSENT = 1 << 0, /**< Unreplied ping sent */ |
117 |
|
|
FLAGS_DEADSOCKET = 1 << 1, /**< Local socket is dead--Exiting soon */ |
118 |
|
|
FLAGS_KILLED = 1 << 2, /**< Prevents "QUIT" from being sent for this */ |
119 |
|
|
FLAGS_CLOSING = 1 << 3, /**< Set when closing to suppress errors */ |
120 |
|
|
FLAGS_GOTID = 1 << 4, /**< Successful ident lookup achieved */ |
121 |
|
|
FLAGS_SENDQEX = 1 << 5, /**< Sendq exceeded */ |
122 |
|
|
FLAGS_IPHASH = 1 << 6, /**< Iphashed this client */ |
123 |
|
|
FLAGS_MARK = 1 << 7, /**< Marked client */ |
124 |
|
|
FLAGS_CANFLOOD = 1 << 8, /**< Client has the ability to flood */ |
125 |
|
|
FLAGS_EXEMPTKLINE = 1 << 9, /**< Client is exempt from k-lines */ |
126 |
|
|
FLAGS_NOLIMIT = 1 << 10, /**< Client is exempt from limits */ |
127 |
|
|
FLAGS_PING_COOKIE = 1 << 11, /**< PING Cookie */ |
128 |
|
|
FLAGS_FLOODDONE = 1 << 12, /**< Flood grace period has been ended. */ |
129 |
|
|
FLAGS_EOB = 1 << 13, /**< Server has sent us an EOB */ |
130 |
|
|
FLAGS_HIDDEN = 1 << 14, /**< A hidden server. Not shown in /links */ |
131 |
|
|
FLAGS_BLOCKED = 1 << 15, /**< Must wait for COMM_SELECT_WRITE */ |
132 |
michael |
8496 |
FLAGS_EXEMPTRESV = 1 << 16, /**< Client is exempt from RESV */ |
133 |
|
|
FLAGS_GOTUSER = 1 << 17, /**< If we received a USER command */ |
134 |
|
|
FLAGS_FINISHED_AUTH = 1 << 18, /**< Client has been released from auth */ |
135 |
|
|
FLAGS_FLOOD_NOTICED = 1 << 19, /**< Notice to opers about this flooder has been sent */ |
136 |
|
|
FLAGS_SERVICE = 1 << 20, /**< Client/server is a network service */ |
137 |
michael |
9157 |
FLAGS_TLS = 1 << 21, /**< User is connected via TLS (Transport Layer Security) */ |
138 |
michael |
8496 |
FLAGS_SQUIT = 1 << 22, |
139 |
michael |
9792 |
FLAGS_EXEMPTXLINE = 1 << 23, /**< Client is exempt from x-lines */ |
140 |
|
|
FLAGS_CAP302 = 1 << 24 /**< Client supports the IRCv3 CAP 302 extension */ |
141 |
michael |
6315 |
}; |
142 |
adx |
30 |
|
143 |
michael |
1219 |
#define HasFlag(x, y) ((x)->flags & (y)) |
144 |
|
|
#define AddFlag(x, y) ((x)->flags |= (y)) |
145 |
|
|
#define DelFlag(x, y) ((x)->flags &= ~(y)) |
146 |
adx |
30 |
|
147 |
michael |
1219 |
|
148 |
adx |
30 |
/* umodes, settable flags */ |
149 |
michael |
6315 |
enum |
150 |
|
|
{ |
151 |
michael |
8431 |
UMODE_SERVNOTICE = 1 << 0, /**< Server notices such as kill */ |
152 |
|
|
UMODE_CCONN = 1 << 1, /**< Can see client connection notices */ |
153 |
|
|
UMODE_REJ = 1 << 2, /**< Bot Rejections */ |
154 |
|
|
UMODE_SKILL = 1 << 3, /**< Server Killed */ |
155 |
michael |
9638 |
UMODE_FLOOD = 1 << 4, /**< Flooding/spambot notices */ |
156 |
michael |
8431 |
UMODE_SPY = 1 << 5, /**< See STATS / LINKS */ |
157 |
|
|
UMODE_DEBUG = 1 << 6, /**< 'debugging' info */ |
158 |
|
|
UMODE_NCHANGE = 1 << 7, /**< Nick change notice */ |
159 |
|
|
UMODE_WALLOP = 1 << 8, /**< Send wallops to them */ |
160 |
|
|
UMODE_INVISIBLE = 1 << 9, /**< Makes user invisible */ |
161 |
michael |
9638 |
UMODE_EXTERNAL = 1 << 10, /**< Show servers introduced and splitting */ |
162 |
|
|
UMODE_CALLERID = 1 << 11, /**< Block unless caller id's */ |
163 |
|
|
UMODE_SOFTCALLERID = 1 << 12, /**< Block unless on common channel */ |
164 |
|
|
UMODE_LOCOPS = 1 << 13, /**< Can see LOCOPS messages */ |
165 |
|
|
UMODE_DEAF = 1 << 14, /**< Don't receive channel messages */ |
166 |
|
|
UMODE_REGISTERED = 1 << 15, /**< User has identified for that nick. */ |
167 |
|
|
UMODE_REGONLY = 1 << 16, /**< Only registered nicks may PM */ |
168 |
|
|
UMODE_HIDDEN = 1 << 17, /**< IRC operator status is hidden */ |
169 |
|
|
UMODE_OPER = 1 << 18, /**< IRC operator */ |
170 |
|
|
UMODE_ADMIN = 1 << 19, /**< Admin on server */ |
171 |
|
|
UMODE_FARCONNECT = 1 << 20, /**< Can see remote client connects/exits */ |
172 |
|
|
UMODE_SECURE = 1 << 21, /**< User is connected via TLS */ |
173 |
|
|
UMODE_WEBIRC = 1 << 22, /**< User connected via a webirc gateway */ |
174 |
|
|
UMODE_HIDEIDLE = 1 << 23, /**< Hides idle and signon time in WHOIS */ |
175 |
|
|
UMODE_HIDECHANS = 1 << 24, /**< Hides channel list in WHOIS */ |
176 |
michael |
9775 |
UMODE_EXPIRATION = 1 << 25, /**< Receives *LINE expiration notices */ |
177 |
|
|
UMODE_BOT = 1 << 26 /**< Client is marked as a bot in WHOIS and WHO */ |
178 |
michael |
6315 |
}; |
179 |
db |
849 |
|
180 |
michael |
1158 |
#define HasUMode(x, y) ((x)->umodes & (y)) |
181 |
|
|
#define AddUMode(x, y) ((x)->umodes |= (y)) |
182 |
|
|
#define DelUMode(x, y) ((x)->umodes &= ~(y)) |
183 |
|
|
|
184 |
adx |
30 |
|
185 |
michael |
6691 |
/** irc-operator privilege flags */ |
186 |
michael |
6315 |
enum |
187 |
|
|
{ |
188 |
michael |
8431 |
OPER_FLAG_ADMIN = 1 << 0, /**< Oper can set user mode +a */ |
189 |
|
|
OPER_FLAG_CLOSE = 1 << 1, /**< Oper can use CLOSE command */ |
190 |
|
|
OPER_FLAG_CONNECT = 1 << 2, /**< Oper can do local CONNECT */ |
191 |
|
|
OPER_FLAG_CONNECT_REMOTE = 1 << 3, /**< Oper can do remote CONNECT */ |
192 |
|
|
OPER_FLAG_DIE = 1 << 4, /**< Oper can use DIE command */ |
193 |
|
|
OPER_FLAG_DLINE = 1 << 5, /**< Oper can use DLINE command */ |
194 |
|
|
OPER_FLAG_GLOBOPS = 1 << 6, /**< Oper can use GLOBOPS command */ |
195 |
|
|
OPER_FLAG_JOIN_RESV = 1 << 7, /**< Oper can use JOIN on resv {} channels */ |
196 |
|
|
OPER_FLAG_KILL = 1 << 8, /**< Oper can KILL local users */ |
197 |
|
|
OPER_FLAG_KILL_REMOTE = 1 << 9, /**< Oper can KILL remote users */ |
198 |
|
|
OPER_FLAG_KLINE = 1 << 10, /**< Oper can use KLINE command */ |
199 |
|
|
OPER_FLAG_LOCOPS = 1 << 11, /**< Oper can use LOCOPS command */ |
200 |
|
|
OPER_FLAG_MODULE = 1 << 12, /**< Oper can use MODULE command */ |
201 |
|
|
OPER_FLAG_NICK_RESV = 1 << 13, /**< Oper can use NICK on resv {} nicks */ |
202 |
|
|
OPER_FLAG_OPME = 1 << 14, /**< Oper can use OPME command */ |
203 |
|
|
OPER_FLAG_REHASH = 1 << 15, /**< Oper can use REHASH command */ |
204 |
|
|
OPER_FLAG_REHASH_REMOTE = 1 << 16, /**< Oper can do remote REHASH command */ |
205 |
|
|
OPER_FLAG_REMOTEBAN = 1 << 17, /**< Oper can set remote bans */ |
206 |
|
|
OPER_FLAG_RESTART = 1 << 18, /**< Oper can use RESTART command */ |
207 |
|
|
OPER_FLAG_RESV = 1 << 19, /**< Oper can use RESV command */ |
208 |
|
|
OPER_FLAG_SET = 1 << 20, /**< Oper can use SET command */ |
209 |
|
|
OPER_FLAG_SQUIT = 1 << 21, /**< Oper can do local SQUIT */ |
210 |
|
|
OPER_FLAG_SQUIT_REMOTE = 1 << 22, /**< Oper can do remote SQUIT */ |
211 |
|
|
OPER_FLAG_UNDLINE = 1 << 23, /**< Oper can use UNDLINE command */ |
212 |
|
|
OPER_FLAG_UNKLINE = 1 << 24, /**< Oper can use UNKLINE command */ |
213 |
|
|
OPER_FLAG_UNRESV = 1 << 25, /**< Oper can use UNRESV command */ |
214 |
|
|
OPER_FLAG_UNXLINE = 1 << 26, /**< Oper can use UNXLINE command */ |
215 |
|
|
OPER_FLAG_WALLOPS = 1 << 27, /**< Oper can use WALLOPS command */ |
216 |
|
|
OPER_FLAG_XLINE = 1 << 28 /**< Oper can use XLINE command */ |
217 |
michael |
6315 |
}; |
218 |
adx |
30 |
|
219 |
michael |
6620 |
#define HasOFlag(x, y) ((x)->connection->operflags & (y)) |
220 |
michael |
4588 |
#define AddOFlag(x, y) ((x)->connection->operflags |= (y)) |
221 |
|
|
#define DelOFlag(x, y) ((x)->connection->operflags &= ~(y)) |
222 |
|
|
#define ClrOFlag(x) ((x)->connection->operflags = 0) |
223 |
adx |
30 |
|
224 |
|
|
|
225 |
michael |
1219 |
|
226 |
adx |
30 |
/* flags macros. */ |
227 |
|
|
#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) |
228 |
|
|
#define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET) |
229 |
michael |
2865 |
#define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING|FLAGS_KILLED)) |
230 |
adx |
30 |
|
231 |
|
|
/* oper flags */ |
232 |
|
|
#define SetOper(x) {(x)->umodes |= UMODE_OPER; \ |
233 |
michael |
6616 |
if (MyClient((x))) (x)->handler = OPER_HANDLER;} |
234 |
adx |
30 |
|
235 |
|
|
#define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \ |
236 |
michael |
6616 |
if (MyClient((x))) \ |
237 |
michael |
2865 |
(x)->handler = CLIENT_HANDLER; } |
238 |
adx |
30 |
|
239 |
|
|
#define IsHidden(x) ((x)->flags & FLAGS_HIDDEN) |
240 |
|
|
|
241 |
|
|
|
242 |
michael |
7304 |
/*! \brief server ban types */ |
243 |
|
|
enum |
244 |
|
|
{ |
245 |
|
|
CLIENT_BAN_KLINE, |
246 |
|
|
CLIENT_BAN_DLINE, |
247 |
|
|
CLIENT_BAN_XLINE |
248 |
|
|
}; |
249 |
|
|
|
250 |
michael |
1798 |
/*! \brief addr_mask_type enumeration */ |
251 |
|
|
enum addr_mask_type |
252 |
|
|
{ |
253 |
michael |
8437 |
HIDE_IP, /**< IP is hidden. Resolved hostname is shown instead */ |
254 |
|
|
SHOW_IP, /**< IP is shown. No parts of it are hidden or masked */ |
255 |
|
|
MASK_IP /**< IP is masked. 255.255.255.255 is shown instead */ |
256 |
michael |
1798 |
}; |
257 |
|
|
|
258 |
|
|
/*! \brief Server structure */ |
259 |
|
|
struct Server |
260 |
|
|
{ |
261 |
michael |
8437 |
dlink_list server_list; /**< Servers on this server */ |
262 |
|
|
dlink_list client_list; /**< Clients on this server */ |
263 |
michael |
8613 |
char by[NICKLEN + 1]; /**< Who activated this connection */ |
264 |
michael |
1798 |
}; |
265 |
|
|
|
266 |
|
|
/*! \brief ListTask structure */ |
267 |
|
|
struct ListTask |
268 |
|
|
{ |
269 |
michael |
6385 |
dlink_node node; /**< Embedded list node used to link into listing_client_list */ |
270 |
michael |
8437 |
dlink_list show_mask; /**< Channels to show */ |
271 |
|
|
dlink_list hide_mask; /**< Channels to hide */ |
272 |
michael |
1798 |
|
273 |
michael |
8437 |
unsigned int hash_index; /**< The hash bucket we are currently in */ |
274 |
michael |
1798 |
unsigned int users_min; |
275 |
|
|
unsigned int users_max; |
276 |
michael |
8917 |
unsigned int created_min; /**< Real time */ |
277 |
|
|
unsigned int created_max; /**< Real time */ |
278 |
|
|
unsigned int topicts_min; /**< Real time */ |
279 |
|
|
unsigned int topicts_max; /**< Real time */ |
280 |
michael |
4489 |
char topic[TOPICLEN + 1]; |
281 |
michael |
1798 |
}; |
282 |
|
|
|
283 |
michael |
4576 |
/*! \brief Connection structure |
284 |
michael |
1798 |
* |
285 |
|
|
* Allocated only for local clients, that are directly connected |
286 |
|
|
* to \b this server with a socket. |
287 |
|
|
*/ |
288 |
michael |
4576 |
struct Connection |
289 |
michael |
1798 |
{ |
290 |
michael |
8613 |
dlink_node lclient_node; |
291 |
michael |
1798 |
|
292 |
|
|
unsigned int registration; |
293 |
michael |
9799 |
unsigned int cap; /**< Client CAP bit-field */ |
294 |
michael |
9790 |
unsigned int capab; /**< Server CAPAB bit field */ |
295 |
michael |
1798 |
|
296 |
|
|
unsigned int operflags; /**< IRC Operator privilege flags */ |
297 |
|
|
unsigned int random_ping; /**< Holding a 32bit value used for PING cookies */ |
298 |
|
|
|
299 |
michael |
8613 |
uintmax_t serial; /**< Used to enforce 1 send per nick */ |
300 |
michael |
8919 |
uintmax_t last_data; /**< Last time data read from socket; monotonic time */ |
301 |
|
|
uintmax_t last_ping; /**< Last time data read from socket; currently this is a copy of last_data |
302 |
|
|
which can be modified by check_pings_list; monotonic time */ |
303 |
|
|
uintmax_t created_real; /**< Time client was created; real time */ |
304 |
|
|
uintmax_t created_monotonic; /**< Time client was created; monotonic time */ |
305 |
michael |
8917 |
uintmax_t last_caller_id_time; /**< Monotonic time */ |
306 |
|
|
uintmax_t first_received_message_time; /**< Monotonic time */ |
307 |
|
|
uintmax_t last_privmsg; /**< Last time we got a PRIVMSG; monotonic time */ |
308 |
|
|
uintmax_t last_join_time; /**< When this client last joined a channel; monotonic time */ |
309 |
|
|
uintmax_t last_leave_time; /**< When this client last left a channel; monotonic time */ |
310 |
michael |
1798 |
|
311 |
michael |
8796 |
unsigned int join_leave_count; /**< Count of JOIN/LEAVE in less than MIN_JOIN_LEAVE_TIME seconds */ |
312 |
michael |
8797 |
unsigned int oper_warn_count_down; /**< Warn opers of this possible spambot every time this gets to 0 */ |
313 |
michael |
7862 |
unsigned int received_number_of_privmsgs; |
314 |
michael |
1798 |
|
315 |
|
|
struct ListTask *list_task; |
316 |
|
|
|
317 |
|
|
struct dbuf_queue buf_sendq; |
318 |
|
|
struct dbuf_queue buf_recvq; |
319 |
|
|
|
320 |
michael |
3335 |
struct |
321 |
|
|
{ |
322 |
michael |
8613 |
unsigned int messages; /**< Statistics: protocol messages sent/received */ |
323 |
|
|
uintmax_t bytes; /**< Statistics: total bytes sent/received */ |
324 |
michael |
1798 |
} recv, send; |
325 |
|
|
|
326 |
michael |
3860 |
struct |
327 |
|
|
{ |
328 |
michael |
4313 |
unsigned int count; /**< How many AWAY/INVITE/KNOCK/NICK requests client has sent */ |
329 |
michael |
8917 |
uintmax_t last_attempt; /**< Last time the AWAY/INVITE/KNOCK/NICK request was issued; monotonic time */ |
330 |
michael |
4313 |
} away, invite, knock, nick; |
331 |
michael |
3860 |
|
332 |
michael |
8339 |
struct AuthRequest *auth; |
333 |
michael |
8613 |
struct Listener *listener; /**< Listener accepted from */ |
334 |
|
|
dlink_list acceptlist; /**< Clients I'll allow to talk to me */ |
335 |
michael |
9750 |
dlink_list monitors; /**< Chain of Monitor pointer blocks */ |
336 |
michael |
8613 |
dlink_list confs; /**< Configuration record associated */ |
337 |
|
|
dlink_list invited; /**< Chain of invite pointer blocks */ |
338 |
michael |
1798 |
|
339 |
michael |
8613 |
fde_t *fd; /**< Pointer to fdlist.c:fd_table[] */ |
340 |
michael |
4439 |
|
341 |
michael |
1798 |
/* Anti-flood stuff. We track how many messages were parsed and how |
342 |
|
|
* many we were allowed in the current second, and apply a simple |
343 |
|
|
* decay to avoid flooding. |
344 |
|
|
* -- adrian |
345 |
|
|
*/ |
346 |
michael |
8613 |
int sent_parsed; /**< How many messages we've parsed in this second */ |
347 |
michael |
1798 |
|
348 |
michael |
4439 |
char *password; /**< Password supplied by the client/server */ |
349 |
michael |
1798 |
}; |
350 |
|
|
|
351 |
|
|
/*! \brief Client structure */ |
352 |
|
|
struct Client |
353 |
|
|
{ |
354 |
|
|
dlink_node node; |
355 |
michael |
8613 |
dlink_node lnode; /**< Used for Server->servers/users */ |
356 |
michael |
1798 |
|
357 |
michael |
6621 |
struct Connection *connection; /**< Connection structure associated with this client */ |
358 |
michael |
8613 |
struct Client *hnext; /**< For client hash table lookups by name */ |
359 |
|
|
struct Client *idhnext; /**< For SID hash table lookups by sid */ |
360 |
|
|
struct Server *serv; /**< ...defined, if this is a server */ |
361 |
|
|
struct Client *servptr; /**< Points to server this Client is on */ |
362 |
|
|
struct Client *from; /**< == self, if Local Client, *NEVER* NULL! */ |
363 |
michael |
1798 |
|
364 |
michael |
8917 |
uintmax_t tsinfo; /**< Timestamp on this nick; real time */ |
365 |
michael |
1798 |
|
366 |
michael |
8613 |
unsigned int flags; /**< Client flags */ |
367 |
|
|
unsigned int umodes; /**< User modes this client has set */ |
368 |
|
|
unsigned int hopcount; /**< Number of servers to this 0 = local */ |
369 |
|
|
unsigned int status; /**< Client type */ |
370 |
|
|
unsigned int handler; /**< Handler index */ |
371 |
michael |
1798 |
|
372 |
michael |
8613 |
dlink_list whowas_list; |
373 |
|
|
dlink_list channel; /**< Chain of channel pointer blocks */ |
374 |
|
|
dlink_list svstags; /**< List of ServicesTag items */ |
375 |
michael |
1798 |
|
376 |
michael |
8496 |
struct irc_ssaddr ip; /**< Real IP address */ |
377 |
|
|
|
378 |
michael |
9408 |
char *tls_certfp; /**< TLS certificate fingerprint */ |
379 |
michael |
9411 |
char *tls_cipher; /**< Exact copy of tls_get_cipher() */ |
380 |
michael |
3335 |
|
381 |
michael |
8613 |
char away[AWAYLEN + 1]; /**< Client's AWAY message. Can be set/unset via AWAY command */ |
382 |
|
|
char name[HOSTLEN + 1]; /**< Unique name for a client nick or host */ |
383 |
|
|
char id[IDLEN + 1]; /**< Client ID, unique ID per client */ |
384 |
|
|
char account[ACCOUNTLEN + 1]; /**< Services account */ |
385 |
|
|
|
386 |
michael |
2865 |
/* |
387 |
michael |
2345 |
* client->username is the username from ident or the USER message, |
388 |
|
|
* If the client is idented the USER message is ignored, otherwise |
389 |
|
|
* the username part of the USER message is put here prefixed with a |
390 |
michael |
1798 |
* tilde depending on the auth{} block. Once a client has registered, |
391 |
|
|
* this field should be considered read-only. |
392 |
|
|
*/ |
393 |
michael |
8613 |
char username[USERLEN + 1]; /**< client's username */ |
394 |
michael |
3335 |
|
395 |
michael |
1798 |
/* |
396 |
michael |
8211 |
* client->host contains the resolved name or ip address as a string |
397 |
|
|
* for the user, it may be fiddled with for oper spoofing etc. |
398 |
|
|
* once it's changed the *real* address goes away. |
399 |
michael |
1798 |
*/ |
400 |
michael |
8613 |
char host[HOSTLEN + 1]; /**< Client's hostname. Can be faked/spoofed */ |
401 |
michael |
1798 |
|
402 |
|
|
/* |
403 |
michael |
8214 |
* client->realhost contains the resolved name or ip address as a string |
404 |
|
|
* for the user. Once a client has registered, this field should be |
405 |
|
|
* considered read-only. |
406 |
|
|
*/ |
407 |
michael |
8613 |
char realhost[HOSTLEN + 1]; /**< Client's real hostname */ |
408 |
michael |
8214 |
|
409 |
|
|
|
410 |
|
|
/* |
411 |
michael |
2345 |
* client->info for unix clients will normally contain the info from the |
412 |
michael |
1798 |
* gcos field in /etc/passwd but anything can go here. |
413 |
|
|
*/ |
414 |
michael |
8613 |
char info[REALLEN + 1]; /**< Free form additional client info */ |
415 |
michael |
1798 |
|
416 |
|
|
/* |
417 |
|
|
* client->sockhost contains the ip address gotten from the socket as a |
418 |
|
|
* string, this field should be considered read-only once the connection |
419 |
|
|
* has been made. (set in s_bsd.c only) |
420 |
|
|
*/ |
421 |
michael |
8613 |
char sockhost[HOSTIPLEN + 1]; /**< This is the host name from the socket ip address as string */ |
422 |
michael |
1798 |
}; |
423 |
|
|
|
424 |
|
|
|
425 |
michael |
9890 |
struct AcceptItem |
426 |
|
|
{ |
427 |
|
|
dlink_node node; |
428 |
|
|
char *nick; |
429 |
|
|
char *user; |
430 |
|
|
char *host; |
431 |
|
|
}; |
432 |
|
|
|
433 |
|
|
|
434 |
adx |
30 |
extern struct Client me; |
435 |
|
|
extern dlink_list listing_client_list; |
436 |
|
|
extern dlink_list global_client_list; |
437 |
michael |
4209 |
extern dlink_list global_server_list; /* global servers on the network */ |
438 |
michael |
4213 |
extern dlink_list local_client_list; /* local clients only ON this server */ |
439 |
|
|
extern dlink_list local_server_list; /* local servers to this server ONLY */ |
440 |
michael |
1666 |
extern dlink_list unknown_list; /* unknown clients ON this server only */ |
441 |
|
|
extern dlink_list oper_list; /* our opers, duplicated in local_client_list */ |
442 |
adx |
30 |
|
443 |
michael |
8656 |
extern bool accept_message(struct Client *, struct Client *); |
444 |
michael |
5544 |
extern unsigned int client_get_idle_time(const struct Client *, const struct Client *); |
445 |
michael |
9890 |
extern struct AcceptItem *accept_find(const char *, const char *, |
446 |
|
|
const char *, dlink_list *, |
447 |
michael |
2363 |
int (*)(const char *, const char *)); |
448 |
michael |
9890 |
extern void accept_del(struct AcceptItem *, dlink_list *); |
449 |
|
|
extern void accept_clear_list(dlink_list *); |
450 |
michael |
3171 |
extern void exit_client(struct Client *, const char *); |
451 |
michael |
7304 |
extern void conf_try_ban(struct Client *, int, const char *); |
452 |
adx |
30 |
extern void check_conf_klines(void); |
453 |
michael |
1798 |
extern void client_init(void); |
454 |
adx |
30 |
extern void dead_link_on_write(struct Client *, int); |
455 |
|
|
extern void dead_link_on_read(struct Client *, int); |
456 |
|
|
extern void exit_aborted_clients(void); |
457 |
|
|
extern void free_exited_clients(void); |
458 |
michael |
7957 |
extern struct Client *client_make(struct Client *); |
459 |
michael |
3192 |
extern struct Client *find_chasing(struct Client *, const char *); |
460 |
michael |
7345 |
extern struct Client *find_person(const struct Client *, const char *); |
461 |
michael |
7997 |
extern const char *client_get_name(const struct Client *, enum addr_mask_type); |
462 |
michael |
8437 |
#endif /* INCLUDED_client_h */ |