]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd). | |
3 | * m_stats.c: Sends the user statistics or config information. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
24 | * $Id: m_stats.c 1608 2006-06-04 02:11:40Z jilles $ | |
25 | */ | |
26 | ||
27 | #include "stdinc.h" | |
212380e3 AC |
28 | #include "class.h" /* report_classes */ |
29 | #include "client.h" /* Client */ | |
30 | #include "common.h" /* TRUE/FALSE */ | |
4562c604 | 31 | #include "match.h" |
212380e3 AC |
32 | #include "ircd.h" /* me */ |
33 | #include "listener.h" /* show_ports */ | |
212380e3 AC |
34 | #include "msg.h" /* Message */ |
35 | #include "hostmask.h" /* report_mtrie_conf_links */ | |
36 | #include "numeric.h" /* ERR_xxx */ | |
37 | #include "scache.h" /* list_scache */ | |
38 | #include "send.h" /* sendto_one */ | |
212380e3 AC |
39 | #include "s_conf.h" /* ConfItem */ |
40 | #include "s_serv.h" /* hunt_server */ | |
47adde3d | 41 | #include "s_stats.h" |
212380e3 | 42 | #include "s_user.h" /* show_opers */ |
212380e3 | 43 | #include "blacklist.h" /* dnsbl stuff */ |
212380e3 AC |
44 | #include "parse.h" |
45 | #include "modules.h" | |
46 | #include "hook.h" | |
47 | #include "s_newconf.h" | |
48 | #include "hash.h" | |
47adde3d VY |
49 | #include "reject.h" |
50 | #include "whowas.h" | |
212380e3 AC |
51 | |
52 | static int m_stats (struct Client *, struct Client *, int, const char **); | |
53 | ||
54 | struct Message stats_msgtab = { | |
55 | "STATS", 0, 0, 0, MFLG_SLOW, | |
56 | {mg_unreg, {m_stats, 2}, {m_stats, 3}, mg_ignore, mg_ignore, {m_stats, 2}} | |
57 | }; | |
58 | ||
59 | int doing_stats_hook; | |
60 | int doing_stats_p_hook; | |
61 | ||
62 | mapi_clist_av1 stats_clist[] = { &stats_msgtab, NULL }; | |
63 | mapi_hlist_av1 stats_hlist[] = { | |
64 | { "doing_stats", &doing_stats_hook }, | |
65 | { "doing_stats_p", &doing_stats_p_hook }, | |
66 | { NULL, NULL } | |
67 | }; | |
68 | ||
69 | DECLARE_MODULE_AV1(stats, NULL, NULL, stats_clist, stats_hlist, NULL, "$Revision: 1608 $"); | |
70 | ||
71 | const char *Lformat = "%s %u %u %u %u %u :%u %u %s"; | |
72 | ||
5b96d9a6 | 73 | static void stats_l_list(struct Client *s, const char *, int, int, rb_dlink_list *, char); |
212380e3 AC |
74 | static void stats_l_client(struct Client *source_p, struct Client *target_p, |
75 | char statchar); | |
76 | ||
77 | static void stats_spy(struct Client *, char, const char *); | |
78 | static void stats_p_spy(struct Client *); | |
79 | ||
80 | /* Heres our struct for the stats table */ | |
81 | struct StatsStruct | |
82 | { | |
83 | char letter; | |
23282da4 | 84 | void (*handler) (struct Client *source_p); |
212380e3 AC |
85 | int need_oper; |
86 | int need_admin; | |
87 | }; | |
88 | ||
23282da4 | 89 | static void stats_dns_servers(struct Client *); |
212380e3 AC |
90 | static void stats_delay(struct Client *); |
91 | static void stats_hash(struct Client *); | |
92 | static void stats_connect(struct Client *); | |
93 | static void stats_tdeny(struct Client *); | |
94 | static void stats_deny(struct Client *); | |
95 | static void stats_exempt(struct Client *); | |
96 | static void stats_events(struct Client *); | |
212380e3 AC |
97 | static void stats_hubleaf(struct Client *); |
98 | static void stats_auth(struct Client *); | |
99 | static void stats_tklines(struct Client *); | |
100 | static void stats_klines(struct Client *); | |
101 | static void stats_messages(struct Client *); | |
102 | static void stats_dnsbl(struct Client *); | |
103 | static void stats_oper(struct Client *); | |
104 | static void stats_operedup(struct Client *); | |
105 | static void stats_ports(struct Client *); | |
106 | static void stats_tresv(struct Client *); | |
107 | static void stats_resv(struct Client *); | |
108 | static void stats_usage(struct Client *); | |
109 | static void stats_tstats(struct Client *); | |
110 | static void stats_uptime(struct Client *); | |
111 | static void stats_shared(struct Client *); | |
112 | static void stats_servers(struct Client *); | |
113 | static void stats_tgecos(struct Client *); | |
114 | static void stats_gecos(struct Client *); | |
115 | static void stats_class(struct Client *); | |
116 | static void stats_memory(struct Client *); | |
117 | static void stats_servlinks(struct Client *); | |
118 | static void stats_ltrace(struct Client *, int, const char **); | |
119 | static void stats_ziplinks(struct Client *); | |
a235e410 | 120 | static void stats_comm(struct Client *); |
212380e3 AC |
121 | /* This table contains the possible stats items, in order: |
122 | * stats letter, function to call, operonly? adminonly? | |
123 | * case only matters in the stats letter column.. -- fl_ | |
124 | */ | |
125 | static struct StatsStruct stats_cmd_table[] = { | |
126 | /* letter function need_oper need_admin */ | |
127 | {'a', stats_dns_servers, 1, 1, }, | |
128 | {'A', stats_dns_servers, 1, 1, }, | |
129 | {'b', stats_delay, 1, 1, }, | |
130 | {'B', stats_hash, 1, 1, }, | |
131 | {'c', stats_connect, 0, 0, }, | |
132 | {'C', stats_connect, 0, 0, }, | |
133 | {'d', stats_tdeny, 1, 0, }, | |
134 | {'D', stats_deny, 1, 0, }, | |
135 | {'e', stats_exempt, 1, 0, }, | |
136 | {'E', stats_events, 1, 1, }, | |
a235e410 VY |
137 | {'f', stats_comm, 1, 1, }, |
138 | {'F', stats_comm, 1, 1, }, | |
212380e3 AC |
139 | {'h', stats_hubleaf, 0, 0, }, |
140 | {'H', stats_hubleaf, 0, 0, }, | |
141 | {'i', stats_auth, 0, 0, }, | |
142 | {'I', stats_auth, 0, 0, }, | |
143 | {'k', stats_tklines, 0, 0, }, | |
144 | {'K', stats_klines, 0, 0, }, | |
23282da4 JT |
145 | {'l', NULL /* special */, 0, 0, }, |
146 | {'L', NULL /* special */, 0, 0, }, | |
212380e3 AC |
147 | {'m', stats_messages, 0, 0, }, |
148 | {'M', stats_messages, 0, 0, }, | |
149 | {'n', stats_dnsbl, 0, 0, }, | |
150 | {'o', stats_oper, 0, 0, }, | |
151 | {'O', stats_oper, 0, 0, }, | |
152 | {'p', stats_operedup, 0, 0, }, | |
153 | {'P', stats_ports, 0, 0, }, | |
154 | {'q', stats_tresv, 1, 0, }, | |
155 | {'Q', stats_resv, 1, 0, }, | |
156 | {'r', stats_usage, 1, 0, }, | |
157 | {'R', stats_usage, 1, 0, }, | |
158 | {'t', stats_tstats, 1, 0, }, | |
159 | {'T', stats_tstats, 1, 0, }, | |
160 | {'u', stats_uptime, 0, 0, }, | |
161 | {'U', stats_shared, 1, 0, }, | |
162 | {'v', stats_servers, 0, 0, }, | |
163 | {'V', stats_servers, 0, 0, }, | |
164 | {'x', stats_tgecos, 1, 0, }, | |
165 | {'X', stats_gecos, 1, 0, }, | |
166 | {'y', stats_class, 0, 0, }, | |
167 | {'Y', stats_class, 0, 0, }, | |
168 | {'z', stats_memory, 1, 0, }, | |
169 | {'Z', stats_ziplinks, 1, 0, }, | |
170 | {'?', stats_servlinks, 0, 0, }, | |
171 | {(char) 0, (void (*)()) 0, 0, 0, } | |
172 | }; | |
173 | ||
174 | /* | |
175 | * m_stats by fl_ | |
176 | * parv[0] = sender prefix | |
177 | * parv[1] = stat letter/command | |
178 | * parv[2] = (if present) server/mask in stats L, or target | |
179 | * | |
180 | * This will search the tables for the appropriate stats letter, | |
181 | * if found execute it. | |
182 | */ | |
183 | static int | |
184 | m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
185 | { | |
186 | static time_t last_used = 0; | |
187 | int i; | |
188 | char statchar; | |
189 | ||
190 | statchar = parv[1][0]; | |
191 | ||
192 | if(MyClient(source_p) && !IsOper(source_p)) | |
193 | { | |
194 | /* Check the user is actually allowed to do /stats, and isnt flooding */ | |
e3354945 | 195 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 AC |
196 | { |
197 | /* safe enough to give this on a local connect only */ | |
198 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
199 | me.name, source_p->name, "STATS"); | |
200 | sendto_one_numeric(source_p, RPL_ENDOFSTATS, | |
201 | form_str(RPL_ENDOFSTATS), statchar); | |
202 | return 0; | |
203 | } | |
204 | else | |
e3354945 | 205 | last_used = rb_current_time(); |
212380e3 AC |
206 | } |
207 | ||
208 | if(hunt_server (client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME) | |
209 | return 0; | |
210 | ||
211 | if((statchar != 'L') && (statchar != 'l')) | |
212 | stats_spy(source_p, statchar, NULL); | |
213 | ||
23282da4 | 214 | for (i = 0; stats_cmd_table[i].letter; i++) |
212380e3 AC |
215 | { |
216 | if(stats_cmd_table[i].letter == statchar) | |
217 | { | |
218 | /* The stats table says what privs are needed, so check --fl_ */ | |
219 | /* Called for remote clients and for local opers, so check need_admin | |
220 | * and need_oper | |
221 | */ | |
9fc04df8 | 222 | if(stats_cmd_table[i].need_oper && !IsOper(source_p)) |
212380e3 AC |
223 | { |
224 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
225 | form_str (ERR_NOPRIVILEGES)); | |
226 | break; | |
227 | } | |
9fc04df8 JT |
228 | if(stats_cmd_table[i].need_admin && !IsOperAdmin(source_p)) |
229 | { | |
230 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
231 | me.name, source_p->name, "admin"); | |
232 | break; | |
233 | } | |
212380e3 AC |
234 | |
235 | /* Blah, stats L needs the parameters, none of the others do.. */ | |
236 | if(statchar == 'L' || statchar == 'l') | |
23282da4 | 237 | stats_ltrace (source_p, parc, parv); |
212380e3 AC |
238 | else |
239 | stats_cmd_table[i].handler (source_p); | |
240 | } | |
241 | } | |
242 | ||
243 | /* Send the end of stats notice, and the stats_spy */ | |
244 | sendto_one_numeric(source_p, RPL_ENDOFSTATS, | |
245 | form_str(RPL_ENDOFSTATS), statchar); | |
246 | ||
247 | return 0; | |
248 | } | |
249 | ||
250 | static void | |
251 | stats_dns_servers (struct Client *source_p) | |
252 | { | |
253 | report_dns_servers (source_p); | |
254 | } | |
255 | ||
256 | static void | |
257 | stats_delay(struct Client *source_p) | |
258 | { | |
259 | struct nd_entry *nd; | |
b37021a4 | 260 | struct DictionaryIter iter; |
212380e3 | 261 | |
b37021a4 | 262 | DICTIONARY_FOREACH(nd, &iter, nd_dict) |
212380e3 | 263 | { |
e4b9c8e1 | 264 | sendto_one_notice(source_p, ":Delaying: %s for %ld", |
212380e3 AC |
265 | nd->name, (long) nd->expire); |
266 | } | |
212380e3 AC |
267 | } |
268 | ||
269 | static void | |
270 | stats_hash(struct Client *source_p) | |
271 | { | |
272 | hash_stats(source_p); | |
273 | } | |
274 | ||
275 | static void | |
276 | stats_connect(struct Client *source_p) | |
277 | { | |
278 | static char buf[5]; | |
279 | struct server_conf *server_p; | |
280 | char *s; | |
5b96d9a6 | 281 | rb_dlink_node *ptr; |
212380e3 AC |
282 | |
283 | if((ConfigFileEntry.stats_c_oper_only || | |
284 | (ConfigServerHide.flatten_links && !IsExemptShide(source_p))) && | |
285 | !IsOper(source_p)) | |
286 | { | |
287 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
288 | form_str(ERR_NOPRIVILEGES)); | |
289 | return; | |
290 | } | |
291 | ||
5b96d9a6 | 292 | RB_DLINK_FOREACH(ptr, server_conf_list.head) |
212380e3 AC |
293 | { |
294 | server_p = ptr->data; | |
295 | ||
296 | if(ServerConfIllegal(server_p)) | |
297 | continue; | |
298 | ||
299 | buf[0] = '\0'; | |
300 | s = buf; | |
301 | ||
302 | if(IsOper(source_p)) | |
303 | { | |
304 | if(ServerConfAutoconn(server_p)) | |
305 | *s++ = 'A'; | |
8bd5767b | 306 | if(ServerConfSSL(server_p)) |
f53ed7f8 | 307 | *s++ = 'S'; |
212380e3 AC |
308 | if(ServerConfTb(server_p)) |
309 | *s++ = 'T'; | |
310 | if(ServerConfCompressed(server_p)) | |
311 | *s++ = 'Z'; | |
312 | } | |
313 | ||
314 | if(!buf[0]) | |
315 | *s++ = '*'; | |
316 | ||
317 | *s = '\0'; | |
318 | ||
319 | sendto_one_numeric(source_p, RPL_STATSCLINE, | |
320 | form_str(RPL_STATSCLINE), | |
212380e3 | 321 | "*@127.0.0.1", |
212380e3 AC |
322 | buf, server_p->name, |
323 | server_p->port, server_p->class_name); | |
324 | } | |
325 | } | |
326 | ||
327 | /* stats_tdeny() | |
328 | * | |
329 | * input - client to report to | |
330 | * output - none | |
331 | * side effects - client is given temp dline list. | |
332 | */ | |
333 | static void | |
334 | stats_tdeny (struct Client *source_p) | |
335 | { | |
336 | char *host, *pass, *user, *oper_reason; | |
337 | struct AddressRec *arec; | |
338 | struct ConfItem *aconf; | |
339 | int i; | |
340 | ||
341 | for (i = 0; i < ATABLE_SIZE; i++) | |
342 | { | |
343 | for (arec = atable[i]; arec; arec = arec->next) | |
344 | { | |
345 | if(arec->type == CONF_DLINE) | |
346 | { | |
347 | aconf = arec->aconf; | |
348 | ||
349 | if(!(aconf->flags & CONF_FLAGS_TEMPORARY)) | |
350 | continue; | |
351 | ||
352 | get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason); | |
353 | ||
354 | sendto_one_numeric(source_p, RPL_STATSDLINE, | |
355 | form_str (RPL_STATSDLINE), | |
356 | 'd', host, pass, | |
357 | oper_reason ? "|" : "", | |
358 | oper_reason ? oper_reason : ""); | |
359 | } | |
360 | } | |
361 | } | |
362 | } | |
363 | ||
364 | /* stats_deny() | |
365 | * | |
366 | * input - client to report to | |
367 | * output - none | |
368 | * side effects - client is given dline list. | |
369 | */ | |
370 | static void | |
371 | stats_deny (struct Client *source_p) | |
372 | { | |
373 | char *host, *pass, *user, *oper_reason; | |
374 | struct AddressRec *arec; | |
375 | struct ConfItem *aconf; | |
376 | int i; | |
377 | ||
378 | for (i = 0; i < ATABLE_SIZE; i++) | |
379 | { | |
380 | for (arec = atable[i]; arec; arec = arec->next) | |
381 | { | |
382 | if(arec->type == CONF_DLINE) | |
383 | { | |
384 | aconf = arec->aconf; | |
385 | ||
386 | if(aconf->flags & CONF_FLAGS_TEMPORARY) | |
387 | continue; | |
388 | ||
389 | get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason); | |
390 | ||
391 | sendto_one_numeric(source_p, RPL_STATSDLINE, | |
392 | form_str (RPL_STATSDLINE), | |
393 | 'D', host, pass, | |
394 | oper_reason ? "|" : "", | |
395 | oper_reason ? oper_reason : ""); | |
396 | } | |
397 | } | |
398 | } | |
399 | } | |
400 | ||
401 | ||
402 | /* stats_exempt() | |
403 | * | |
404 | * input - client to report to | |
405 | * output - none | |
406 | * side effects - client is given list of exempt blocks | |
407 | */ | |
408 | static void | |
409 | stats_exempt(struct Client *source_p) | |
410 | { | |
411 | char *name, *host, *pass, *user, *classname; | |
412 | struct AddressRec *arec; | |
413 | struct ConfItem *aconf; | |
414 | int i, port; | |
415 | ||
416 | if(ConfigFileEntry.stats_e_disabled) | |
417 | { | |
22f2f68a JT |
418 | sendto_one_numeric(source_p, ERR_DISABLED, |
419 | form_str(ERR_DISABLED), "STATS e"); | |
212380e3 AC |
420 | return; |
421 | } | |
422 | ||
423 | for (i = 0; i < ATABLE_SIZE; i++) | |
424 | { | |
425 | for (arec = atable[i]; arec; arec = arec->next) | |
426 | { | |
427 | if(arec->type == CONF_EXEMPTDLINE) | |
428 | { | |
429 | aconf = arec->aconf; | |
430 | get_printable_conf (aconf, &name, &host, &pass, | |
431 | &user, &port, &classname); | |
432 | ||
433 | sendto_one_numeric(source_p, RPL_STATSDLINE, | |
434 | form_str(RPL_STATSDLINE), | |
435 | 'e', host, pass, "", ""); | |
436 | } | |
437 | } | |
438 | }} | |
439 | ||
440 | ||
f237e31a JT |
441 | static void |
442 | stats_events_cb(char *str, void *ptr) | |
443 | { | |
444 | sendto_one_numeric(ptr, RPL_STATSDEBUG, "E :%s", str); | |
445 | } | |
446 | ||
447 | static void | |
448 | stats_events (struct Client *source_p) | |
449 | { | |
450 | rb_dump_events(stats_events_cb, source_p); | |
212380e3 AC |
451 | } |
452 | ||
212380e3 AC |
453 | static void |
454 | stats_hubleaf(struct Client *source_p) | |
455 | { | |
456 | struct remote_conf *hub_p; | |
5b96d9a6 | 457 | rb_dlink_node *ptr; |
212380e3 AC |
458 | |
459 | if((ConfigFileEntry.stats_h_oper_only || | |
460 | (ConfigServerHide.flatten_links && !IsExemptShide(source_p))) && | |
461 | !IsOper(source_p)) | |
462 | { | |
463 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
464 | form_str (ERR_NOPRIVILEGES)); | |
465 | return; | |
466 | } | |
467 | ||
5b96d9a6 | 468 | RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head) |
212380e3 AC |
469 | { |
470 | hub_p = ptr->data; | |
471 | ||
472 | if(hub_p->flags & CONF_HUB) | |
473 | sendto_one_numeric(source_p, RPL_STATSHLINE, | |
474 | form_str(RPL_STATSHLINE), | |
475 | hub_p->host, hub_p->server); | |
476 | else | |
477 | sendto_one_numeric(source_p, RPL_STATSLLINE, | |
478 | form_str(RPL_STATSLLINE), | |
479 | hub_p->host, hub_p->server); | |
480 | } | |
481 | } | |
482 | ||
483 | ||
484 | static void | |
485 | stats_auth (struct Client *source_p) | |
486 | { | |
487 | /* Oper only, if unopered, return ERR_NOPRIVS */ | |
488 | if((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper (source_p)) | |
489 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
490 | form_str (ERR_NOPRIVILEGES)); | |
491 | ||
492 | /* If unopered, Only return matching auth blocks */ | |
493 | else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p)) | |
494 | { | |
495 | struct ConfItem *aconf; | |
40c1fd47 | 496 | char *name, *host, *pass = "*", *user, *classname; |
212380e3 AC |
497 | int port; |
498 | ||
499 | if(MyConnect (source_p)) | |
500 | aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, | |
501 | (struct sockaddr *)&source_p->localClient->ip, | |
502 | CONF_CLIENT, | |
503 | source_p->localClient->ip.ss_family, | |
40c1fd47 | 504 | source_p->username, NULL); |
212380e3 AC |
505 | else |
506 | aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_CLIENT, | |
40c1fd47 | 507 | 0, source_p->username, NULL); |
212380e3 AC |
508 | |
509 | if(aconf == NULL) | |
510 | return; | |
511 | ||
512 | get_printable_conf (aconf, &name, &host, &pass, &user, &port, &classname); | |
40c1fd47 VY |
513 | if(!EmptyString(aconf->spasswd)) |
514 | pass = aconf->spasswd; | |
212380e3 AC |
515 | |
516 | sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE), | |
40c1fd47 | 517 | name, pass, show_iline_prefix(source_p, aconf, user), |
212380e3 AC |
518 | host, port, classname); |
519 | } | |
520 | ||
521 | /* Theyre opered, or allowed to see all auth blocks */ | |
522 | else | |
523 | report_auth (source_p); | |
524 | } | |
525 | ||
526 | ||
527 | static void | |
528 | stats_tklines(struct Client *source_p) | |
529 | { | |
530 | /* Oper only, if unopered, return ERR_NOPRIVS */ | |
531 | if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper (source_p)) | |
532 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
533 | form_str (ERR_NOPRIVILEGES)); | |
534 | ||
535 | /* If unopered, Only return matching klines */ | |
536 | else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper (source_p)) | |
537 | { | |
538 | struct ConfItem *aconf; | |
539 | char *host, *pass, *user, *oper_reason; | |
540 | ||
541 | if(MyConnect (source_p)) | |
542 | aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, | |
543 | (struct sockaddr *)&source_p->localClient->ip, | |
544 | CONF_KILL, | |
545 | source_p->localClient->ip.ss_family, | |
40c1fd47 | 546 | source_p->username, NULL); |
212380e3 AC |
547 | else |
548 | aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL, | |
40c1fd47 | 549 | 0, source_p->username, NULL); |
212380e3 AC |
550 | |
551 | if(aconf == NULL) | |
552 | return; | |
553 | ||
554 | /* dont report a permanent kline as a tkline */ | |
555 | if((aconf->flags & CONF_FLAGS_TEMPORARY) == 0) | |
556 | return; | |
557 | ||
558 | get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason); | |
559 | ||
560 | sendto_one_numeric(source_p, RPL_STATSKLINE, | |
0a621c4b JT |
561 | form_str(RPL_STATSKLINE), aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K', |
562 | host, user, pass, oper_reason ? "|" : "", | |
212380e3 AC |
563 | oper_reason ? oper_reason : ""); |
564 | } | |
565 | /* Theyre opered, or allowed to see all klines */ | |
566 | else | |
567 | { | |
568 | struct ConfItem *aconf; | |
5b96d9a6 | 569 | rb_dlink_node *ptr; |
212380e3 AC |
570 | int i; |
571 | char *user, *host, *pass, *oper_reason; | |
572 | ||
573 | for(i = 0; i < LAST_TEMP_TYPE; i++) | |
574 | { | |
5b96d9a6 | 575 | RB_DLINK_FOREACH(ptr, temp_klines[i].head) |
212380e3 AC |
576 | { |
577 | aconf = ptr->data; | |
578 | ||
579 | get_printable_kline(source_p, aconf, &host, &pass, | |
580 | &user, &oper_reason); | |
581 | ||
582 | sendto_one_numeric(source_p, RPL_STATSKLINE, | |
583 | form_str(RPL_STATSKLINE), | |
584 | 'k', host, user, pass, | |
585 | oper_reason ? "|" : "", | |
586 | oper_reason ? oper_reason : ""); | |
587 | } | |
588 | } | |
589 | } | |
590 | } | |
591 | ||
592 | static void | |
593 | stats_klines(struct Client *source_p) | |
594 | { | |
595 | /* Oper only, if unopered, return ERR_NOPRIVS */ | |
596 | if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper (source_p)) | |
597 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
598 | form_str (ERR_NOPRIVILEGES)); | |
599 | ||
600 | /* If unopered, Only return matching klines */ | |
601 | else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper (source_p)) | |
602 | { | |
603 | struct ConfItem *aconf; | |
604 | char *host, *pass, *user, *oper_reason; | |
605 | ||
606 | /* search for a kline */ | |
607 | if(MyConnect (source_p)) | |
608 | aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, | |
609 | (struct sockaddr *)&source_p->localClient->ip, | |
610 | CONF_KILL, | |
611 | source_p->localClient->ip.ss_family, | |
40c1fd47 | 612 | source_p->username, NULL); |
212380e3 AC |
613 | else |
614 | aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL, | |
40c1fd47 | 615 | 0, source_p->username, NULL); |
212380e3 AC |
616 | |
617 | if(aconf == NULL) | |
618 | return; | |
619 | ||
212380e3 AC |
620 | get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason); |
621 | ||
622 | sendto_one_numeric(source_p, RPL_STATSKLINE, form_str(RPL_STATSKLINE), | |
0a621c4b JT |
623 | aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K', |
624 | host, user, pass, oper_reason ? "|" : "", | |
212380e3 AC |
625 | oper_reason ? oper_reason : ""); |
626 | } | |
627 | /* Theyre opered, or allowed to see all klines */ | |
628 | else | |
629 | report_Klines (source_p); | |
630 | } | |
631 | ||
632 | static void | |
633 | stats_messages(struct Client *source_p) | |
634 | { | |
635 | report_messages(source_p); | |
636 | } | |
637 | ||
638 | static void | |
639 | stats_dnsbl(struct Client *source_p) | |
640 | { | |
5b96d9a6 | 641 | rb_dlink_node *ptr; |
212380e3 AC |
642 | struct Blacklist *blptr; |
643 | ||
5b96d9a6 | 644 | RB_DLINK_FOREACH(ptr, blacklist_list.head) |
212380e3 AC |
645 | { |
646 | blptr = ptr->data; | |
647 | ||
648 | /* use RPL_STATSDEBUG for now -- jilles */ | |
649 | sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s %s (%d)", | |
650 | blptr->hits, | |
651 | blptr->host, | |
652 | blptr->status & CONF_ILLEGAL ? "disabled" : "active", | |
653 | blptr->refcount); | |
654 | } | |
655 | } | |
656 | ||
657 | static void | |
658 | stats_oper(struct Client *source_p) | |
659 | { | |
660 | struct oper_conf *oper_p; | |
5b96d9a6 | 661 | rb_dlink_node *ptr; |
212380e3 AC |
662 | |
663 | if(!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only) | |
664 | { | |
665 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
666 | form_str (ERR_NOPRIVILEGES)); | |
667 | return; | |
668 | } | |
669 | ||
5b96d9a6 | 670 | RB_DLINK_FOREACH(ptr, oper_conf_list.head) |
212380e3 AC |
671 | { |
672 | oper_p = ptr->data; | |
673 | ||
674 | sendto_one_numeric(source_p, RPL_STATSOLINE, | |
675 | form_str(RPL_STATSOLINE), | |
676 | oper_p->username, oper_p->host, oper_p->name, | |
677 | IsOper(source_p) ? get_oper_privs(oper_p->flags) : "0", "-1"); | |
678 | } | |
679 | } | |
680 | ||
681 | ||
682 | /* stats_operedup() | |
683 | * | |
684 | * input - client pointer | |
685 | * output - none | |
686 | * side effects - client is shown a list of active opers | |
687 | */ | |
688 | static void | |
689 | stats_operedup (struct Client *source_p) | |
690 | { | |
691 | struct Client *target_p; | |
5b96d9a6 | 692 | rb_dlink_node *oper_ptr; |
212380e3 AC |
693 | unsigned int count = 0; |
694 | ||
5b96d9a6 | 695 | RB_DLINK_FOREACH (oper_ptr, oper_list.head) |
212380e3 AC |
696 | { |
697 | target_p = oper_ptr->data; | |
698 | ||
699 | if(IsOperInvis(target_p) && !IsOper(source_p)) | |
700 | continue; | |
701 | ||
702 | if(target_p->user->away) | |
703 | continue; | |
704 | ||
705 | count++; | |
706 | ||
707 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
708 | "p :%s (%s@%s)", | |
709 | target_p->name, target_p->username, | |
710 | target_p->host); | |
711 | } | |
712 | ||
713 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
714 | "p :%u staff members", count); | |
715 | ||
716 | stats_p_spy (source_p); | |
717 | } | |
718 | ||
719 | static void | |
720 | stats_ports (struct Client *source_p) | |
721 | { | |
722 | if(!IsOper (source_p) && ConfigFileEntry.stats_P_oper_only) | |
723 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
724 | form_str (ERR_NOPRIVILEGES)); | |
725 | else | |
726 | show_ports (source_p); | |
727 | } | |
728 | ||
729 | static void | |
730 | stats_tresv(struct Client *source_p) | |
731 | { | |
732 | struct ConfItem *aconf; | |
5b96d9a6 | 733 | rb_dlink_node *ptr; |
212380e3 AC |
734 | int i; |
735 | ||
5b96d9a6 | 736 | RB_DLINK_FOREACH(ptr, resv_conf_list.head) |
212380e3 AC |
737 | { |
738 | aconf = ptr->data; | |
739 | if(aconf->hold) | |
740 | sendto_one_numeric(source_p, RPL_STATSQLINE, | |
741 | form_str(RPL_STATSQLINE), | |
742 | 'q', aconf->port, aconf->name, aconf->passwd); | |
743 | } | |
744 | ||
745 | HASH_WALK(i, R_MAX, ptr, resvTable) | |
746 | { | |
747 | aconf = ptr->data; | |
748 | if(aconf->hold) | |
749 | sendto_one_numeric(source_p, RPL_STATSQLINE, | |
750 | form_str(RPL_STATSQLINE), | |
751 | 'q', aconf->port, aconf->name, aconf->passwd); | |
752 | } | |
753 | HASH_WALK_END | |
754 | } | |
755 | ||
756 | ||
757 | static void | |
758 | stats_resv(struct Client *source_p) | |
759 | { | |
760 | struct ConfItem *aconf; | |
5b96d9a6 | 761 | rb_dlink_node *ptr; |
212380e3 AC |
762 | int i; |
763 | ||
5b96d9a6 | 764 | RB_DLINK_FOREACH(ptr, resv_conf_list.head) |
212380e3 AC |
765 | { |
766 | aconf = ptr->data; | |
767 | if(!aconf->hold) | |
768 | sendto_one_numeric(source_p, RPL_STATSQLINE, | |
769 | form_str(RPL_STATSQLINE), | |
770 | 'Q', aconf->port, aconf->name, aconf->passwd); | |
771 | } | |
772 | ||
773 | HASH_WALK(i, R_MAX, ptr, resvTable) | |
774 | { | |
775 | aconf = ptr->data; | |
776 | if(!aconf->hold) | |
777 | sendto_one_numeric(source_p, RPL_STATSQLINE, | |
778 | form_str(RPL_STATSQLINE), | |
779 | 'Q', aconf->port, aconf->name, aconf->passwd); | |
780 | } | |
781 | HASH_WALK_END | |
782 | } | |
783 | ||
784 | static void | |
785 | stats_usage (struct Client *source_p) | |
786 | { | |
787 | struct rusage rus; | |
788 | time_t secs; | |
789 | time_t rup; | |
790 | #ifdef hz | |
791 | # define hzz hz | |
792 | #else | |
793 | # ifdef HZ | |
794 | # define hzz HZ | |
795 | # else | |
796 | int hzz = 1; | |
797 | # endif | |
798 | #endif | |
799 | ||
800 | if(getrusage(RUSAGE_SELF, &rus) == -1) | |
801 | { | |
802 | sendto_one_notice(source_p, ":Getruseage error: %s.", | |
803 | strerror(errno)); | |
804 | return; | |
805 | } | |
806 | secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec; | |
807 | if(0 == secs) | |
808 | secs = 1; | |
809 | ||
e3354945 | 810 | rup = (rb_current_time() - startup_time) * hzz; |
212380e3 AC |
811 | if(0 == rup) |
812 | rup = 1; | |
813 | ||
814 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
815 | "R :CPU Secs %d:%d User %d:%d System %d:%d", | |
816 | (int) (secs / 60), (int) (secs % 60), | |
817 | (int) (rus.ru_utime.tv_sec / 60), | |
818 | (int) (rus.ru_utime.tv_sec % 60), | |
819 | (int) (rus.ru_stime.tv_sec / 60), | |
820 | (int) (rus.ru_stime.tv_sec % 60)); | |
821 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
822 | "R :RSS %ld ShMem %ld Data %ld Stack %ld", | |
823 | rus.ru_maxrss, (rus.ru_ixrss / rup), | |
824 | (rus.ru_idrss / rup), (rus.ru_isrss / rup)); | |
825 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
826 | "R :Swaps %d Reclaims %d Faults %d", | |
827 | (int) rus.ru_nswap, (int) rus.ru_minflt, (int) rus.ru_majflt); | |
828 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
829 | "R :Block in %d out %d", | |
830 | (int) rus.ru_inblock, (int) rus.ru_oublock); | |
831 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
832 | "R :Msg Rcv %d Send %d", | |
833 | (int) rus.ru_msgrcv, (int) rus.ru_msgsnd); | |
834 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
835 | "R :Signals %d Context Vol. %d Invol %d", | |
836 | (int) rus.ru_nsignals, (int) rus.ru_nvcsw, | |
837 | (int) rus.ru_nivcsw); | |
838 | } | |
839 | ||
54ac8b60 VY |
840 | static void |
841 | stats_tstats (struct Client *source_p) | |
842 | { | |
47adde3d VY |
843 | struct Client *target_p; |
844 | struct ServerStatistics sp; | |
845 | rb_dlink_node *ptr; | |
846 | ||
847 | memcpy(&sp, &ServerStats, sizeof(struct ServerStatistics)); | |
848 | ||
8bd5767b JT |
849 | RB_DLINK_FOREACH(ptr, serv_list.head) |
850 | { | |
851 | target_p = ptr->data; | |
852 | ||
853 | sp.is_sbs += target_p->localClient->sendB; | |
854 | sp.is_sbr += target_p->localClient->receiveB; | |
855 | sp.is_sti += rb_current_time() - target_p->localClient->firsttime; | |
856 | sp.is_sv++; | |
857 | } | |
858 | ||
859 | RB_DLINK_FOREACH(ptr, lclient_list.head) | |
860 | { | |
861 | target_p = ptr->data; | |
862 | ||
863 | sp.is_cbs += target_p->localClient->sendB; | |
864 | sp.is_cbr += target_p->localClient->receiveB; | |
865 | sp.is_cti += rb_current_time() - target_p->localClient->firsttime; | |
866 | sp.is_cl++; | |
47adde3d VY |
867 | } |
868 | ||
869 | RB_DLINK_FOREACH(ptr, unknown_list.head) | |
870 | { | |
871 | sp.is_ni++; | |
872 | } | |
873 | ||
874 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
875 | "T :accepts %u refused %u", sp.is_ac, sp.is_ref); | |
876 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
877 | "T :rejected %u delaying %lu", | |
43946961 | 878 | sp.is_rej, delay_exit_length()); |
47adde3d VY |
879 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
880 | "T :nicks being delayed %lu", | |
881 | get_nd_count()); | |
882 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
883 | "T :unknown commands %u prefixes %u", | |
884 | sp.is_unco, sp.is_unpf); | |
885 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
886 | "T :nick collisions %u saves %u unknown closes %u", | |
887 | sp.is_kill, sp.is_save, sp.is_ni); | |
888 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
889 | "T :wrong direction %u empty %u", | |
890 | sp.is_wrdi, sp.is_empt); | |
891 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
892 | "T :numerics seen %u", sp.is_num); | |
893 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
894 | "T :tgchange blocked msgs %u restricted addrs %lu", | |
895 | sp.is_tgch, rb_dlink_list_length(&tgchange_list)); | |
896 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
897 | "T :auth successes %u fails %u", | |
898 | sp.is_asuc, sp.is_abad); | |
899 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
900 | "T :sasl successes %u fails %u", | |
901 | sp.is_ssuc, sp.is_sbad); | |
902 | sendto_one_numeric(source_p, RPL_STATSDEBUG, "T :Client Server"); | |
903 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
904 | "T :connected %u %u", sp.is_cl, sp.is_sv); | |
8bd5767b JT |
905 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
906 | "T :bytes sent %lluK %lluK", | |
907 | sp.is_cbs / 1024, | |
908 | sp.is_sbs / 1024); | |
909 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
910 | "T :bytes recv %lluK %lluK", | |
911 | sp.is_cbr / 1024, | |
7685dd09 | 912 | sp.is_sbr / 1024); |
8bd5767b JT |
913 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
914 | "T :time connected %lu %lu", | |
8982edb0 | 915 | (long int)sp.is_cti, (long int)sp.is_sti); |
212380e3 AC |
916 | } |
917 | ||
918 | static void | |
919 | stats_uptime (struct Client *source_p) | |
920 | { | |
921 | time_t now; | |
922 | ||
e3354945 | 923 | now = rb_current_time() - startup_time; |
212380e3 AC |
924 | sendto_one_numeric(source_p, RPL_STATSUPTIME, |
925 | form_str (RPL_STATSUPTIME), | |
926 | now / 86400, (now / 3600) % 24, | |
927 | (now / 60) % 60, now % 60); | |
928 | sendto_one_numeric(source_p, RPL_STATSCONN, | |
929 | form_str (RPL_STATSCONN), | |
930 | MaxConnectionCount, MaxClientCount, | |
931 | Count.totalrestartcount); | |
932 | } | |
933 | ||
934 | struct shared_flags | |
935 | { | |
936 | int flag; | |
937 | char letter; | |
938 | }; | |
939 | static struct shared_flags shared_flagtable[] = | |
940 | { | |
941 | { SHARED_PKLINE, 'K' }, | |
942 | { SHARED_TKLINE, 'k' }, | |
943 | { SHARED_UNKLINE, 'U' }, | |
944 | { SHARED_PXLINE, 'X' }, | |
945 | { SHARED_TXLINE, 'x' }, | |
946 | { SHARED_UNXLINE, 'Y' }, | |
947 | { SHARED_PRESV, 'Q' }, | |
948 | { SHARED_TRESV, 'q' }, | |
949 | { SHARED_UNRESV, 'R' }, | |
950 | { SHARED_LOCOPS, 'L' }, | |
951 | { SHARED_REHASH, 'H' }, | |
f5cb68d5 VY |
952 | { SHARED_TDLINE, 'd' }, |
953 | { SHARED_PDLINE, 'D' }, | |
954 | { SHARED_UNDLINE, 'E' }, | |
212380e3 AC |
955 | { 0, '\0'} |
956 | }; | |
957 | ||
958 | ||
959 | static void | |
960 | stats_shared (struct Client *source_p) | |
961 | { | |
962 | struct remote_conf *shared_p; | |
5b96d9a6 | 963 | rb_dlink_node *ptr; |
212380e3 AC |
964 | char buf[15]; |
965 | char *p; | |
966 | int i; | |
967 | ||
5b96d9a6 | 968 | RB_DLINK_FOREACH(ptr, shared_conf_list.head) |
212380e3 AC |
969 | { |
970 | shared_p = ptr->data; | |
971 | ||
972 | p = buf; | |
973 | ||
974 | *p++ = 'c'; | |
975 | ||
976 | for(i = 0; shared_flagtable[i].flag != 0; i++) | |
977 | { | |
978 | if(shared_p->flags & shared_flagtable[i].flag) | |
979 | *p++ = shared_flagtable[i].letter; | |
980 | } | |
981 | ||
982 | *p = '\0'; | |
983 | ||
984 | sendto_one_numeric(source_p, RPL_STATSULINE, | |
985 | form_str(RPL_STATSULINE), | |
986 | shared_p->server, shared_p->username, | |
987 | shared_p->host, buf); | |
988 | } | |
989 | ||
5b96d9a6 | 990 | RB_DLINK_FOREACH(ptr, cluster_conf_list.head) |
212380e3 AC |
991 | { |
992 | shared_p = ptr->data; | |
993 | ||
994 | p = buf; | |
995 | ||
996 | *p++ = 'C'; | |
997 | ||
998 | for(i = 0; shared_flagtable[i].flag != 0; i++) | |
999 | { | |
1000 | if(shared_p->flags & shared_flagtable[i].flag) | |
1001 | *p++ = shared_flagtable[i].letter; | |
1002 | } | |
1003 | ||
1004 | *p = '\0'; | |
1005 | ||
1006 | sendto_one_numeric(source_p, RPL_STATSULINE, | |
1007 | form_str(RPL_STATSULINE), | |
1008 | shared_p->server, "*", "*", buf); | |
1009 | } | |
1010 | } | |
1011 | ||
1012 | /* stats_servers() | |
1013 | * | |
1014 | * input - client pointer | |
1015 | * output - none | |
1016 | * side effects - client is shown lists of who connected servers | |
1017 | */ | |
1018 | static void | |
1019 | stats_servers (struct Client *source_p) | |
1020 | { | |
1021 | struct Client *target_p; | |
5b96d9a6 | 1022 | rb_dlink_node *ptr; |
212380e3 AC |
1023 | time_t seconds; |
1024 | int days, hours, minutes; | |
1025 | int j = 0; | |
1026 | ||
1027 | if(ConfigServerHide.flatten_links && !IsOper(source_p) && | |
1028 | !IsExemptShide(source_p)) | |
1029 | { | |
1030 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
1031 | form_str (ERR_NOPRIVILEGES)); | |
1032 | return; | |
1033 | } | |
1034 | ||
5b96d9a6 | 1035 | RB_DLINK_FOREACH (ptr, serv_list.head) |
212380e3 AC |
1036 | { |
1037 | target_p = ptr->data; | |
1038 | ||
1039 | j++; | |
e3354945 | 1040 | seconds = rb_current_time() - target_p->localClient->firsttime; |
212380e3 AC |
1041 | |
1042 | days = (int) (seconds / 86400); | |
1043 | seconds %= 86400; | |
1044 | hours = (int) (seconds / 3600); | |
1045 | seconds %= 3600; | |
1046 | minutes = (int) (seconds / 60); | |
1047 | seconds %= 60; | |
1048 | ||
1049 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1050 | "V :%s (%s!*@*) Idle: %d SendQ: %d " | |
1051 | "Connected: %d day%s, %d:%02d:%02d", | |
1052 | target_p->name, | |
1053 | (target_p->serv->by[0] ? target_p->serv->by : "Remote."), | |
e3354945 | 1054 | (int) (rb_current_time() - target_p->localClient->lasttime), |
e8e79621 | 1055 | (int) rb_linebuf_len (&target_p->localClient->buf_sendq), |
212380e3 AC |
1056 | days, (days == 1) ? "" : "s", hours, minutes, |
1057 | (int) seconds); | |
1058 | } | |
1059 | ||
1060 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1061 | "V :%d Server(s)", j); | |
1062 | } | |
1063 | ||
1064 | static void | |
1065 | stats_tgecos(struct Client *source_p) | |
1066 | { | |
1067 | struct ConfItem *aconf; | |
5b96d9a6 | 1068 | rb_dlink_node *ptr; |
212380e3 | 1069 | |
5b96d9a6 | 1070 | RB_DLINK_FOREACH(ptr, xline_conf_list.head) |
212380e3 AC |
1071 | { |
1072 | aconf = ptr->data; | |
1073 | ||
1074 | if(aconf->hold) | |
1075 | sendto_one_numeric(source_p, RPL_STATSXLINE, | |
1076 | form_str(RPL_STATSXLINE), | |
1077 | 'x', aconf->port, aconf->name, | |
1078 | aconf->passwd); | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | static void | |
1083 | stats_gecos(struct Client *source_p) | |
1084 | { | |
1085 | struct ConfItem *aconf; | |
5b96d9a6 | 1086 | rb_dlink_node *ptr; |
212380e3 | 1087 | |
5b96d9a6 | 1088 | RB_DLINK_FOREACH(ptr, xline_conf_list.head) |
212380e3 AC |
1089 | { |
1090 | aconf = ptr->data; | |
1091 | ||
1092 | if(!aconf->hold) | |
1093 | sendto_one_numeric(source_p, RPL_STATSXLINE, | |
1094 | form_str(RPL_STATSXLINE), | |
1095 | 'X', aconf->port, aconf->name, | |
1096 | aconf->passwd); | |
1097 | } | |
1098 | } | |
1099 | ||
1100 | static void | |
1101 | stats_class(struct Client *source_p) | |
1102 | { | |
1103 | if(ConfigFileEntry.stats_y_oper_only && !IsOper(source_p)) | |
1104 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
1105 | form_str (ERR_NOPRIVILEGES)); | |
1106 | else | |
1107 | report_classes(source_p); | |
1108 | } | |
1109 | ||
1110 | static void | |
1111 | stats_memory (struct Client *source_p) | |
1112 | { | |
47adde3d VY |
1113 | struct Client *target_p; |
1114 | struct Channel *chptr; | |
1115 | struct Ban *actualBan; | |
1116 | rb_dlink_node *rb_dlink; | |
1117 | rb_dlink_node *ptr; | |
1118 | int channel_count = 0; | |
1119 | int local_client_conf_count = 0; /* local client conf links */ | |
1120 | int users_counted = 0; /* user structs */ | |
1121 | ||
1122 | int channel_users = 0; | |
1123 | int channel_invites = 0; | |
1124 | int channel_bans = 0; | |
1125 | int channel_except = 0; | |
1126 | int channel_invex = 0; | |
1127 | int channel_quiets = 0; | |
1128 | ||
1129 | int class_count = 0; /* classes */ | |
1130 | int conf_count = 0; /* conf lines */ | |
1131 | int users_invited_count = 0; /* users invited */ | |
1132 | int user_channels = 0; /* users in channels */ | |
1133 | int aways_counted = 0; | |
1134 | size_t number_servers_cached; /* number of servers cached by scache */ | |
1135 | ||
1136 | size_t channel_memory = 0; | |
1137 | size_t channel_ban_memory = 0; | |
1138 | size_t channel_except_memory = 0; | |
1139 | size_t channel_invex_memory = 0; | |
1140 | size_t channel_quiet_memory = 0; | |
1141 | ||
1142 | size_t away_memory = 0; /* memory used by aways */ | |
1143 | size_t ww = 0; /* whowas array count */ | |
1144 | size_t wwm = 0; /* whowas array memory used */ | |
1145 | size_t conf_memory = 0; /* memory used by conf lines */ | |
1146 | size_t mem_servers_cached; /* memory used by scache */ | |
1147 | ||
1148 | size_t linebuf_count = 0; | |
1149 | size_t linebuf_memory_used = 0; | |
1150 | ||
1151 | size_t total_channel_memory = 0; | |
1152 | size_t totww = 0; | |
1153 | ||
1154 | size_t local_client_count = 0; | |
1155 | size_t local_client_memory_used = 0; | |
1156 | ||
1157 | size_t remote_client_count = 0; | |
1158 | size_t remote_client_memory_used = 0; | |
1159 | ||
1160 | size_t total_memory = 0; | |
1161 | ||
1162 | count_whowas_memory(&ww, &wwm); | |
1163 | ||
1164 | RB_DLINK_FOREACH(ptr, global_client_list.head) | |
1165 | { | |
1166 | target_p = ptr->data; | |
1167 | if(MyConnect(target_p)) | |
1168 | { | |
1169 | local_client_conf_count++; | |
1170 | } | |
1171 | ||
1172 | if(target_p->user) | |
1173 | { | |
1174 | users_counted++; | |
1175 | users_invited_count += rb_dlink_list_length(&target_p->user->invited); | |
1176 | user_channels += rb_dlink_list_length(&target_p->user->channel); | |
1177 | if(target_p->user->away) | |
1178 | { | |
1179 | aways_counted++; | |
1180 | away_memory += (strlen(target_p->user->away) + 1); | |
1181 | } | |
1182 | } | |
1183 | } | |
1184 | ||
1185 | /* Count up all channels, ban lists, except lists, Invex lists */ | |
1186 | RB_DLINK_FOREACH(ptr, global_channel_list.head) | |
1187 | { | |
1188 | chptr = ptr->data; | |
1189 | channel_count++; | |
1190 | channel_memory += (strlen(chptr->chname) + sizeof(struct Channel)); | |
1191 | ||
1192 | channel_users += rb_dlink_list_length(&chptr->members); | |
1193 | channel_invites += rb_dlink_list_length(&chptr->invites); | |
1194 | ||
1195 | RB_DLINK_FOREACH(rb_dlink, chptr->banlist.head) | |
1196 | { | |
1197 | actualBan = rb_dlink->data; | |
1198 | channel_bans++; | |
1199 | ||
1200 | channel_ban_memory += sizeof(rb_dlink_node) + sizeof(struct Ban); | |
1201 | } | |
1202 | ||
1203 | RB_DLINK_FOREACH(rb_dlink, chptr->exceptlist.head) | |
1204 | { | |
1205 | actualBan = rb_dlink->data; | |
1206 | channel_except++; | |
1207 | ||
1208 | channel_except_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban)); | |
1209 | } | |
1210 | ||
1211 | RB_DLINK_FOREACH(rb_dlink, chptr->invexlist.head) | |
1212 | { | |
1213 | actualBan = rb_dlink->data; | |
1214 | channel_invex++; | |
1215 | ||
1216 | channel_invex_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban)); | |
1217 | } | |
1218 | ||
1219 | RB_DLINK_FOREACH(rb_dlink, chptr->quietlist.head) | |
1220 | { | |
1221 | actualBan = rb_dlink->data; | |
1222 | channel_quiets++; | |
1223 | ||
1224 | channel_quiet_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban)); | |
1225 | } | |
1226 | } | |
1227 | ||
1228 | /* count up all classes */ | |
1229 | ||
1230 | class_count = rb_dlink_list_length(&class_list) + 1; | |
1231 | ||
1232 | rb_count_rb_linebuf_memory(&linebuf_count, &linebuf_memory_used); | |
1233 | ||
1234 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1235 | "z :Users %u(%lu) Invites %u(%lu)", | |
1236 | users_counted, | |
1237 | (unsigned long) users_counted * sizeof(struct User), | |
1238 | users_invited_count, | |
1239 | (unsigned long) users_invited_count * sizeof(rb_dlink_node)); | |
1240 | ||
1241 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1242 | "z :User channels %u(%lu) Aways %u(%d)", | |
1243 | user_channels, | |
1244 | (unsigned long) user_channels * sizeof(rb_dlink_node), | |
1245 | aways_counted, (int) away_memory); | |
1246 | ||
1247 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1248 | "z :Attached confs %u(%lu)", | |
1249 | local_client_conf_count, | |
1250 | (unsigned long) local_client_conf_count * sizeof(rb_dlink_node)); | |
1251 | ||
1252 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1253 | "z :Conflines %u(%d)", conf_count, (int) conf_memory); | |
1254 | ||
1255 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1256 | "z :Classes %u(%lu)", | |
1257 | class_count, | |
1258 | (unsigned long) class_count * sizeof(struct Class)); | |
1259 | ||
1260 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1261 | "z :Channels %u(%d)", | |
1262 | channel_count, (int) channel_memory); | |
1263 | ||
1264 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1265 | "z :Bans %u(%d) Exceptions %u(%d) Invex %u(%d) Quiets %u(%d)", | |
1266 | channel_bans, (int) channel_ban_memory, | |
1267 | channel_except, (int) channel_except_memory, | |
1268 | channel_invex, (int) channel_invex_memory, | |
1269 | channel_quiets, (int) channel_quiet_memory); | |
1270 | ||
1271 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1272 | "z :Channel members %u(%lu) invite %u(%lu)", | |
1273 | channel_users, | |
1274 | (unsigned long) channel_users * sizeof(rb_dlink_node), | |
1275 | channel_invites, | |
1276 | (unsigned long) channel_invites * sizeof(rb_dlink_node)); | |
1277 | ||
1278 | total_channel_memory = channel_memory + | |
1279 | channel_ban_memory + | |
1280 | channel_users * sizeof(rb_dlink_node) + channel_invites * sizeof(rb_dlink_node); | |
1281 | ||
1282 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1283 | "z :Whowas array %ld(%ld)", | |
1284 | (long)ww, (long)wwm); | |
1285 | ||
1286 | totww = wwm; | |
1287 | ||
1288 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1289 | "z :Hash: client %u(%ld) chan %u(%ld)", | |
1290 | U_MAX, (long)(U_MAX * sizeof(rb_dlink_list)), | |
1291 | CH_MAX, (long)(CH_MAX * sizeof(rb_dlink_list))); | |
1292 | ||
1293 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1294 | "z :linebuf %ld(%ld)", | |
1295 | (long)linebuf_count, (long)linebuf_memory_used); | |
1296 | ||
1297 | count_scache(&number_servers_cached, &mem_servers_cached); | |
1298 | ||
1299 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1300 | "z :scache %ld(%ld)", | |
1301 | (long)number_servers_cached, (long)mem_servers_cached); | |
1302 | ||
1303 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1304 | "z :hostname hash %d(%ld)", | |
1305 | HOST_MAX, (long)HOST_MAX * sizeof(rb_dlink_list)); | |
1306 | ||
1307 | total_memory = totww + total_channel_memory + conf_memory + | |
1308 | class_count * sizeof(struct Class); | |
1309 | ||
1310 | total_memory += mem_servers_cached; | |
1311 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1312 | "z :Total: whowas %d channel %d conf %d", | |
1313 | (int) totww, (int) total_channel_memory, | |
1314 | (int) conf_memory); | |
1315 | ||
1316 | count_local_client_memory(&local_client_count, &local_client_memory_used); | |
1317 | total_memory += local_client_memory_used; | |
1318 | ||
1319 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1320 | "z :Local client Memory in use: %ld(%ld)", | |
1321 | (long)local_client_count, (long)local_client_memory_used); | |
1322 | ||
1323 | ||
1324 | count_remote_client_memory(&remote_client_count, &remote_client_memory_used); | |
1325 | total_memory += remote_client_memory_used; | |
1326 | ||
1327 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1328 | "z :Remote client Memory in use: %ld(%ld)", | |
1329 | (long)remote_client_count, | |
1330 | (long)remote_client_memory_used); | |
212380e3 AC |
1331 | } |
1332 | ||
1333 | static void | |
1334 | stats_ziplinks (struct Client *source_p) | |
1335 | { | |
5b96d9a6 | 1336 | rb_dlink_node *ptr; |
212380e3 | 1337 | struct Client *target_p; |
4c79bbd3 | 1338 | struct ZipStats *zipstats; |
212380e3 | 1339 | int sent_data = 0; |
70b72a07 | 1340 | char buf[128], buf1[128]; |
5b96d9a6 | 1341 | RB_DLINK_FOREACH (ptr, serv_list.head) |
212380e3 AC |
1342 | { |
1343 | target_p = ptr->data; | |
1344 | if(IsCapable (target_p, CAP_ZIP)) | |
1345 | { | |
4c79bbd3 VY |
1346 | zipstats = target_p->localClient->zipstats; |
1347 | sprintf(buf, "%.2f%%", zipstats->out_ratio); | |
1348 | sprintf(buf1, "%.2f%%", zipstats->in_ratio); | |
212380e3 | 1349 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
70b72a07 | 1350 | "Z :ZipLinks stats for %s send[%s compression " |
4c79bbd3 VY |
1351 | "(%llu kB data/%llu kB wire)] recv[%s compression " |
1352 | "(%llu kB data/%llu kB wire)]", | |
212380e3 | 1353 | target_p->name, |
4c79bbd3 VY |
1354 | buf, zipstats->out >> 10, |
1355 | zipstats->out_wire >> 10, buf1, | |
1356 | zipstats->in >> 10, zipstats->in_wire >> 10); | |
212380e3 AC |
1357 | sent_data++; |
1358 | } | |
1359 | } | |
1360 | ||
1361 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1362 | "Z :%u ziplink(s)", sent_data); | |
1363 | } | |
1364 | ||
1365 | static void | |
1366 | stats_servlinks (struct Client *source_p) | |
1367 | { | |
1368 | static char Sformat[] = ":%s %d %s %s %u %u %u %u %u :%u %u %s"; | |
1369 | long uptime, sendK, receiveK; | |
1370 | struct Client *target_p; | |
5b96d9a6 | 1371 | rb_dlink_node *ptr; |
212380e3 | 1372 | int j = 0; |
70b72a07 | 1373 | char buf[128]; |
212380e3 AC |
1374 | |
1375 | if(ConfigServerHide.flatten_links && !IsOper (source_p) && | |
1376 | !IsExemptShide(source_p)) | |
1377 | { | |
1378 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, | |
1379 | form_str (ERR_NOPRIVILEGES)); | |
1380 | return; | |
1381 | } | |
1382 | ||
1383 | sendK = receiveK = 0; | |
1384 | ||
5b96d9a6 | 1385 | RB_DLINK_FOREACH (ptr, serv_list.head) |
212380e3 AC |
1386 | { |
1387 | target_p = ptr->data; | |
1388 | ||
1389 | j++; | |
1390 | sendK += target_p->localClient->sendK; | |
1391 | receiveK += target_p->localClient->receiveK; | |
1392 | ||
1393 | sendto_one(source_p, Sformat, | |
1394 | get_id(&me, source_p), RPL_STATSLINKINFO, get_id(source_p, source_p), | |
b3ebc7ab | 1395 | target_p->name, |
d269d0b6 | 1396 | (int) rb_linebuf_len (&target_p->localClient->buf_sendq), |
212380e3 AC |
1397 | (int) target_p->localClient->sendM, |
1398 | (int) target_p->localClient->sendK, | |
1399 | (int) target_p->localClient->receiveM, | |
1400 | (int) target_p->localClient->receiveK, | |
e3354945 VY |
1401 | rb_current_time() - target_p->localClient->firsttime, |
1402 | (rb_current_time() > target_p->localClient->lasttime) ? | |
1403 | (rb_current_time() - target_p->localClient->lasttime) : 0, | |
212380e3 AC |
1404 | IsOper (source_p) ? show_capabilities (target_p) : "TS"); |
1405 | } | |
1406 | ||
1407 | sendto_one_numeric(source_p, RPL_STATSDEBUG, | |
1408 | "? :%u total server(s)", j); | |
1409 | ||
70b72a07 | 1410 | snprintf(buf, sizeof buf, "%7.2f", _GMKv ((sendK))); |
212380e3 | 1411 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
70b72a07 JT |
1412 | "? :Sent total : %s %s", |
1413 | buf, _GMKs (sendK)); | |
1414 | snprintf(buf, sizeof buf, "%7.2f", _GMKv ((receiveK))); | |
212380e3 | 1415 | sendto_one_numeric(source_p, RPL_STATSDEBUG, |
70b72a07 JT |
1416 | "? :Recv total : %s %s", |
1417 | buf, _GMKs (receiveK)); | |
212380e3 | 1418 | |
e3354945 | 1419 | uptime = (rb_current_time() - startup_time); |
70b72a07 | 1420 | snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)", |
212380e3 AC |
1421 | _GMKv (me.localClient->sendK), |
1422 | _GMKs (me.localClient->sendK), | |
1423 | (float) ((float) me.localClient->sendK / (float) uptime)); | |
70b72a07 JT |
1424 | sendto_one_numeric(source_p, RPL_STATSDEBUG, "? :Server send: %s", buf); |
1425 | snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)", | |
212380e3 AC |
1426 | _GMKv (me.localClient->receiveK), |
1427 | _GMKs (me.localClient->receiveK), | |
1428 | (float) ((float) me.localClient->receiveK / (float) uptime)); | |
70b72a07 | 1429 | sendto_one_numeric(source_p, RPL_STATSDEBUG, "? :Server recv: %s", buf); |
212380e3 AC |
1430 | } |
1431 | ||
1432 | static void | |
1433 | stats_ltrace(struct Client *source_p, int parc, const char *parv[]) | |
1434 | { | |
1435 | int doall = 0; | |
1436 | int wilds = 0; | |
1437 | const char *name; | |
1438 | char statchar = parv[1][0]; | |
1439 | ||
1440 | /* this is def targeted at us somehow.. */ | |
1441 | if(parc > 2 && !EmptyString(parv[2])) | |
1442 | { | |
1443 | /* directed at us generically? */ | |
1444 | if(match(parv[2], me.name) || | |
1445 | (!MyClient(source_p) && !irccmp(parv[2], me.id))) | |
1446 | { | |
1447 | name = me.name; | |
1448 | doall = 1; | |
1449 | } | |
1450 | else | |
1451 | { | |
1452 | name = parv[2]; | |
1453 | wilds = strchr(name, '*') || strchr(name, '?'); | |
1454 | } | |
1455 | ||
1456 | /* must be directed at a specific person thats not us */ | |
1457 | if(!doall && !wilds) | |
1458 | { | |
1459 | struct Client *target_p; | |
1460 | ||
1461 | if(MyClient(source_p)) | |
1462 | target_p = find_named_person(name); | |
1463 | else | |
1464 | target_p = find_person(name); | |
1465 | ||
1466 | if(target_p != NULL) | |
1467 | { | |
1468 | stats_spy(source_p, statchar, target_p->name); | |
1469 | stats_l_client(source_p, target_p, statchar); | |
1470 | } | |
1471 | else | |
1472 | sendto_one_numeric(source_p, ERR_NOSUCHSERVER, | |
1473 | form_str(ERR_NOSUCHSERVER), | |
1474 | name); | |
1475 | ||
1476 | return; | |
1477 | } | |
1478 | } | |
1479 | else | |
1480 | { | |
1481 | name = me.name; | |
1482 | doall = 1; | |
1483 | } | |
1484 | ||
1485 | stats_spy(source_p, statchar, name); | |
1486 | ||
1487 | if(doall) | |
1488 | { | |
1489 | /* local opers get everyone */ | |
1490 | if(MyOper(source_p)) | |
1491 | { | |
1492 | stats_l_list(source_p, name, doall, wilds, &unknown_list, statchar); | |
1493 | stats_l_list(source_p, name, doall, wilds, &lclient_list, statchar); | |
1494 | } | |
1495 | else | |
1496 | { | |
1497 | /* they still need themselves if theyre local.. */ | |
1498 | if(MyClient(source_p)) | |
1499 | stats_l_client(source_p, source_p, statchar); | |
1500 | ||
1501 | stats_l_list(source_p, name, doall, wilds, &local_oper_list, statchar); | |
1502 | } | |
1503 | ||
1504 | if (!ConfigServerHide.flatten_links || IsOper(source_p) || | |
1505 | IsExemptShide(source_p)) | |
1506 | stats_l_list(source_p, name, doall, wilds, &serv_list, statchar); | |
1507 | ||
1508 | return; | |
1509 | } | |
1510 | ||
1511 | /* ok, at this point theyre looking for a specific client whos on | |
1512 | * our server.. but it contains a wildcard. --fl | |
1513 | */ | |
1514 | stats_l_list(source_p, name, doall, wilds, &lclient_list, statchar); | |
1515 | ||
1516 | return; | |
1517 | } | |
1518 | ||
1519 | ||
1520 | static void | |
1521 | stats_l_list(struct Client *source_p, const char *name, int doall, int wilds, | |
5b96d9a6 | 1522 | rb_dlink_list * list, char statchar) |
212380e3 | 1523 | { |
5b96d9a6 | 1524 | rb_dlink_node *ptr; |
212380e3 AC |
1525 | struct Client *target_p; |
1526 | ||
1527 | /* send information about connections which match. note, we | |
1528 | * dont need tests for IsInvisible(), because non-opers will | |
1529 | * never get here for normal clients --fl | |
1530 | */ | |
5b96d9a6 | 1531 | RB_DLINK_FOREACH(ptr, list->head) |
212380e3 AC |
1532 | { |
1533 | target_p = ptr->data; | |
1534 | ||
1535 | if(!doall && wilds && !match(name, target_p->name)) | |
1536 | continue; | |
1537 | ||
1538 | stats_l_client(source_p, target_p, statchar); | |
1539 | } | |
1540 | } | |
1541 | ||
1542 | void | |
1543 | stats_l_client(struct Client *source_p, struct Client *target_p, | |
1544 | char statchar) | |
1545 | { | |
1546 | if(IsAnyServer(target_p)) | |
1547 | { | |
1548 | sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat, | |
b3ebc7ab | 1549 | target_p->name, |
d269d0b6 | 1550 | (int) rb_linebuf_len(&target_p->localClient->buf_sendq), |
212380e3 AC |
1551 | (int) target_p->localClient->sendM, |
1552 | (int) target_p->localClient->sendK, | |
1553 | (int) target_p->localClient->receiveM, | |
1554 | (int) target_p->localClient->receiveK, | |
e3354945 VY |
1555 | rb_current_time() - target_p->localClient->firsttime, |
1556 | (rb_current_time() > target_p->localClient->lasttime) ? | |
1557 | (rb_current_time() - target_p->localClient->lasttime) : 0, | |
212380e3 AC |
1558 | IsOper(source_p) ? show_capabilities(target_p) : "-"); |
1559 | } | |
1560 | ||
1561 | else | |
1562 | { | |
1563 | sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat, | |
1564 | show_ip(source_p, target_p) ? | |
1565 | (IsUpper(statchar) ? | |
1566 | get_client_name(target_p, SHOW_IP) : | |
1567 | get_client_name(target_p, HIDE_IP)) : | |
1568 | get_client_name(target_p, MASK_IP), | |
d269d0b6 | 1569 | (int) rb_linebuf_len(&target_p->localClient->buf_sendq), |
212380e3 AC |
1570 | (int) target_p->localClient->sendM, |
1571 | (int) target_p->localClient->sendK, | |
1572 | (int) target_p->localClient->receiveM, | |
1573 | (int) target_p->localClient->receiveK, | |
e3354945 VY |
1574 | rb_current_time() - target_p->localClient->firsttime, |
1575 | (rb_current_time() > target_p->localClient->lasttime) ? | |
1576 | (rb_current_time() - target_p->localClient->lasttime) : 0, | |
212380e3 AC |
1577 | "-"); |
1578 | } | |
1579 | } | |
1580 | ||
f237e31a JT |
1581 | static void |
1582 | rb_dump_fd_callback(int fd, const char *desc, void *data) | |
1583 | { | |
1584 | struct Client *source_p = data; | |
1585 | sendto_one_numeric(source_p, RPL_STATSDEBUG, "F :fd %-3d desc '%s'", fd, desc); | |
1586 | } | |
1587 | ||
1588 | static void | |
1589 | stats_comm(struct Client *source_p) | |
1590 | { | |
1591 | rb_dump_fd(rb_dump_fd_callback, source_p); | |
a235e410 VY |
1592 | } |
1593 | ||
212380e3 AC |
1594 | /* |
1595 | * stats_spy | |
1596 | * | |
1597 | * inputs - pointer to client doing the /stats | |
1598 | * - char letter they are doing /stats on | |
1599 | * output - none | |
1600 | * side effects - | |
1601 | * This little helper function reports to opers if configured. | |
1602 | * personally, I don't see why opers need to see stats requests | |
1603 | * at all. They are just "noise" to an oper, and users can't do | |
1604 | * any damage with stats requests now anyway. So, why show them? | |
1605 | * -Dianora | |
1606 | */ | |
1607 | static void | |
1608 | stats_spy(struct Client *source_p, char statchar, const char *name) | |
1609 | { | |
1610 | hook_data_int data; | |
1611 | ||
1612 | data.client = source_p; | |
1613 | data.arg1 = name; | |
1614 | data.arg2 = (int) statchar; | |
1615 | ||
1616 | call_hook(doing_stats_hook, &data); | |
1617 | } | |
1618 | ||
1619 | /* stats_p_spy() | |
1620 | * | |
1621 | * input - pointer to client doing stats | |
1622 | * ouput - | |
1623 | * side effects - call hook doing_stats_p | |
1624 | */ | |
1625 | static void | |
1626 | stats_p_spy (struct Client *source_p) | |
1627 | { | |
1628 | hook_data data; | |
1629 | ||
1630 | data.client = source_p; | |
1631 | data.arg1 = data.arg2 = NULL; | |
1632 | ||
1633 | call_hook(doing_stats_p_hook, &data); | |
1634 | } | |
1635 |