]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_stats.c
extern void send_pop_queue(struct Client *); in header, will implement this some...
[irc/rqf/shadowircd.git] / modules / m_stats.c
CommitLineData
212380e3 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 28#include "class.h" /* report_classes */
29#include "client.h" /* Client */
30#include "common.h" /* TRUE/FALSE */
31#include "irc_string.h"
32#include "ircd.h" /* me */
33#include "listener.h" /* show_ports */
34#include "s_gline.h"
35#include "msg.h" /* Message */
36#include "hostmask.h" /* report_mtrie_conf_links */
37#include "numeric.h" /* ERR_xxx */
38#include "scache.h" /* list_scache */
39#include "send.h" /* sendto_one */
212380e3 40#include "s_conf.h" /* ConfItem */
41#include "s_serv.h" /* hunt_server */
42#include "s_stats.h" /* tstats */
43#include "s_user.h" /* show_opers */
212380e3 44#include "blacklist.h" /* dnsbl stuff */
212380e3 45#include "parse.h"
46#include "modules.h"
47#include "hook.h"
48#include "s_newconf.h"
49#include "hash.h"
50
51static int m_stats (struct Client *, struct Client *, int, const char **);
52
53struct Message stats_msgtab = {
54 "STATS", 0, 0, 0, MFLG_SLOW,
55 {mg_unreg, {m_stats, 2}, {m_stats, 3}, mg_ignore, mg_ignore, {m_stats, 2}}
56};
57
58int doing_stats_hook;
59int doing_stats_p_hook;
60
61mapi_clist_av1 stats_clist[] = { &stats_msgtab, NULL };
62mapi_hlist_av1 stats_hlist[] = {
63 { "doing_stats", &doing_stats_hook },
64 { "doing_stats_p", &doing_stats_p_hook },
65 { NULL, NULL }
66};
67
68DECLARE_MODULE_AV1(stats, NULL, NULL, stats_clist, stats_hlist, NULL, "$Revision: 1608 $");
69
70const char *Lformat = "%s %u %u %u %u %u :%u %u %s";
71
08d11e34 72static void stats_l_list(struct Client *s, const char *, int, int, rb_dlink_list *, char);
212380e3 73static void stats_l_client(struct Client *source_p, struct Client *target_p,
74 char statchar);
75
76static void stats_spy(struct Client *, char, const char *);
77static void stats_p_spy(struct Client *);
78
79/* Heres our struct for the stats table */
80struct StatsStruct
81{
82 char letter;
83 void (*handler) ();
84 int need_oper;
85 int need_admin;
86};
87
88static void stats_dns_servers (struct Client *);
89static void stats_delay(struct Client *);
90static void stats_hash(struct Client *);
91static void stats_connect(struct Client *);
92static void stats_tdeny(struct Client *);
93static void stats_deny(struct Client *);
94static void stats_exempt(struct Client *);
95static void stats_events(struct Client *);
96static void stats_glines(struct Client *);
97static void stats_pending_glines(struct Client *);
98static void stats_hubleaf(struct Client *);
99static void stats_auth(struct Client *);
100static void stats_tklines(struct Client *);
101static void stats_klines(struct Client *);
102static void stats_messages(struct Client *);
103static void stats_dnsbl(struct Client *);
104static void stats_oper(struct Client *);
105static void stats_operedup(struct Client *);
106static void stats_ports(struct Client *);
107static void stats_tresv(struct Client *);
108static void stats_resv(struct Client *);
109static void stats_usage(struct Client *);
110static void stats_tstats(struct Client *);
111static void stats_uptime(struct Client *);
112static void stats_shared(struct Client *);
113static void stats_servers(struct Client *);
114static void stats_tgecos(struct Client *);
115static void stats_gecos(struct Client *);
116static void stats_class(struct Client *);
117static void stats_memory(struct Client *);
118static void stats_servlinks(struct Client *);
119static void stats_ltrace(struct Client *, int, const char **);
120static void stats_ziplinks(struct Client *);
b8127271 121static void stats_comm(struct Client *);
212380e3 122/* This table contains the possible stats items, in order:
123 * stats letter, function to call, operonly? adminonly?
124 * case only matters in the stats letter column.. -- fl_
125 */
126static struct StatsStruct stats_cmd_table[] = {
127 /* letter function need_oper need_admin */
128 {'a', stats_dns_servers, 1, 1, },
129 {'A', stats_dns_servers, 1, 1, },
130 {'b', stats_delay, 1, 1, },
131 {'B', stats_hash, 1, 1, },
132 {'c', stats_connect, 0, 0, },
133 {'C', stats_connect, 0, 0, },
134 {'d', stats_tdeny, 1, 0, },
135 {'D', stats_deny, 1, 0, },
136 {'e', stats_exempt, 1, 0, },
137 {'E', stats_events, 1, 1, },
b8127271
VY
138 {'f', stats_comm, 1, 1, },
139 {'F', stats_comm, 1, 1, },
212380e3 140 {'g', stats_pending_glines, 1, 0, },
141 {'G', stats_glines, 1, 0, },
142 {'h', stats_hubleaf, 0, 0, },
143 {'H', stats_hubleaf, 0, 0, },
144 {'i', stats_auth, 0, 0, },
145 {'I', stats_auth, 0, 0, },
146 {'k', stats_tklines, 0, 0, },
147 {'K', stats_klines, 0, 0, },
148 {'l', stats_ltrace, 0, 0, },
149 {'L', stats_ltrace, 0, 0, },
150 {'m', stats_messages, 0, 0, },
151 {'M', stats_messages, 0, 0, },
152 {'n', stats_dnsbl, 0, 0, },
153 {'o', stats_oper, 0, 0, },
154 {'O', stats_oper, 0, 0, },
155 {'p', stats_operedup, 0, 0, },
156 {'P', stats_ports, 0, 0, },
157 {'q', stats_tresv, 1, 0, },
158 {'Q', stats_resv, 1, 0, },
159 {'r', stats_usage, 1, 0, },
160 {'R', stats_usage, 1, 0, },
161 {'t', stats_tstats, 1, 0, },
162 {'T', stats_tstats, 1, 0, },
163 {'u', stats_uptime, 0, 0, },
164 {'U', stats_shared, 1, 0, },
165 {'v', stats_servers, 0, 0, },
166 {'V', stats_servers, 0, 0, },
167 {'x', stats_tgecos, 1, 0, },
168 {'X', stats_gecos, 1, 0, },
169 {'y', stats_class, 0, 0, },
170 {'Y', stats_class, 0, 0, },
171 {'z', stats_memory, 1, 0, },
172 {'Z', stats_ziplinks, 1, 0, },
173 {'?', stats_servlinks, 0, 0, },
174 {(char) 0, (void (*)()) 0, 0, 0, }
175};
176
177/*
178 * m_stats by fl_
179 * parv[0] = sender prefix
180 * parv[1] = stat letter/command
181 * parv[2] = (if present) server/mask in stats L, or target
182 *
183 * This will search the tables for the appropriate stats letter,
184 * if found execute it.
185 */
186static int
187m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
188{
189 static time_t last_used = 0;
190 int i;
191 char statchar;
192
193 statchar = parv[1][0];
194
195 if(MyClient(source_p) && !IsOper(source_p))
196 {
197 /* Check the user is actually allowed to do /stats, and isnt flooding */
198 if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
199 {
200 /* safe enough to give this on a local connect only */
201 sendto_one(source_p, form_str(RPL_LOAD2HI),
202 me.name, source_p->name, "STATS");
203 sendto_one_numeric(source_p, RPL_ENDOFSTATS,
204 form_str(RPL_ENDOFSTATS), statchar);
205 return 0;
206 }
207 else
208 last_used = CurrentTime;
209 }
210
211 if(hunt_server (client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME)
212 return 0;
213
214 if((statchar != 'L') && (statchar != 'l'))
215 stats_spy(source_p, statchar, NULL);
216
217 for (i = 0; stats_cmd_table[i].handler; i++)
218 {
219 if(stats_cmd_table[i].letter == statchar)
220 {
221 /* The stats table says what privs are needed, so check --fl_ */
222 /* Called for remote clients and for local opers, so check need_admin
223 * and need_oper
224 */
ff74c93a 225 if(stats_cmd_table[i].need_oper && !IsOper(source_p))
212380e3 226 {
227 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
228 form_str (ERR_NOPRIVILEGES));
229 break;
230 }
ff74c93a
JT
231 if(stats_cmd_table[i].need_admin && !IsOperAdmin(source_p))
232 {
233 sendto_one(source_p, form_str(ERR_NOPRIVS),
234 me.name, source_p->name, "admin");
235 break;
236 }
212380e3 237
238 /* Blah, stats L needs the parameters, none of the others do.. */
239 if(statchar == 'L' || statchar == 'l')
240 stats_cmd_table[i].handler (source_p, parc, parv);
241 else
242 stats_cmd_table[i].handler (source_p);
243 }
244 }
245
246 /* Send the end of stats notice, and the stats_spy */
247 sendto_one_numeric(source_p, RPL_ENDOFSTATS,
248 form_str(RPL_ENDOFSTATS), statchar);
249
250 return 0;
251}
252
253static void
254stats_dns_servers (struct Client *source_p)
255{
256 report_dns_servers (source_p);
257}
258
259static void
260stats_delay(struct Client *source_p)
261{
262 struct nd_entry *nd;
b37021a4 263 struct DictionaryIter iter;
212380e3 264
b37021a4 265 DICTIONARY_FOREACH(nd, &iter, nd_dict)
212380e3 266 {
d1264ac8 267 sendto_one_notice(source_p, ":Delaying: %s for %ld",
212380e3 268 nd->name, (long) nd->expire);
269 }
212380e3 270}
271
272static void
273stats_hash(struct Client *source_p)
274{
275 hash_stats(source_p);
276}
277
278static void
279stats_connect(struct Client *source_p)
280{
281 static char buf[5];
282 struct server_conf *server_p;
283 char *s;
08d11e34 284 rb_dlink_node *ptr;
212380e3 285
286 if((ConfigFileEntry.stats_c_oper_only ||
287 (ConfigServerHide.flatten_links && !IsExemptShide(source_p))) &&
288 !IsOper(source_p))
289 {
290 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
291 form_str(ERR_NOPRIVILEGES));
292 return;
293 }
294
08d11e34 295 RB_DLINK_FOREACH(ptr, server_conf_list.head)
212380e3 296 {
297 server_p = ptr->data;
298
299 if(ServerConfIllegal(server_p))
300 continue;
301
302 buf[0] = '\0';
303 s = buf;
304
305 if(IsOper(source_p))
306 {
307 if(ServerConfAutoconn(server_p))
308 *s++ = 'A';
309 if(ServerConfTb(server_p))
310 *s++ = 'T';
311 if(ServerConfCompressed(server_p))
312 *s++ = 'Z';
313 }
314
315 if(!buf[0])
316 *s++ = '*';
317
318 *s = '\0';
319
320 sendto_one_numeric(source_p, RPL_STATSCLINE,
321 form_str(RPL_STATSCLINE),
322#ifndef HIDE_SERVERS_IPS
323 server_p->host,
324#else
325 "*@127.0.0.1",
326#endif
327 buf, server_p->name,
328 server_p->port, server_p->class_name);
329 }
330}
331
332/* stats_tdeny()
333 *
334 * input - client to report to
335 * output - none
336 * side effects - client is given temp dline list.
337 */
338static void
339stats_tdeny (struct Client *source_p)
340{
341 char *host, *pass, *user, *oper_reason;
342 struct AddressRec *arec;
343 struct ConfItem *aconf;
344 int i;
345
346 for (i = 0; i < ATABLE_SIZE; i++)
347 {
348 for (arec = atable[i]; arec; arec = arec->next)
349 {
350 if(arec->type == CONF_DLINE)
351 {
352 aconf = arec->aconf;
353
354 if(!(aconf->flags & CONF_FLAGS_TEMPORARY))
355 continue;
356
357 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
358
359 sendto_one_numeric(source_p, RPL_STATSDLINE,
360 form_str (RPL_STATSDLINE),
361 'd', host, pass,
362 oper_reason ? "|" : "",
363 oper_reason ? oper_reason : "");
364 }
365 }
366 }
367}
368
369/* stats_deny()
370 *
371 * input - client to report to
372 * output - none
373 * side effects - client is given dline list.
374 */
375static void
376stats_deny (struct Client *source_p)
377{
378 char *host, *pass, *user, *oper_reason;
379 struct AddressRec *arec;
380 struct ConfItem *aconf;
381 int i;
382
383 for (i = 0; i < ATABLE_SIZE; i++)
384 {
385 for (arec = atable[i]; arec; arec = arec->next)
386 {
387 if(arec->type == CONF_DLINE)
388 {
389 aconf = arec->aconf;
390
391 if(aconf->flags & CONF_FLAGS_TEMPORARY)
392 continue;
393
394 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
395
396 sendto_one_numeric(source_p, RPL_STATSDLINE,
397 form_str (RPL_STATSDLINE),
398 'D', host, pass,
399 oper_reason ? "|" : "",
400 oper_reason ? oper_reason : "");
401 }
402 }
403 }
404}
405
406
407/* stats_exempt()
408 *
409 * input - client to report to
410 * output - none
411 * side effects - client is given list of exempt blocks
412 */
413static void
414stats_exempt(struct Client *source_p)
415{
416 char *name, *host, *pass, *user, *classname;
417 struct AddressRec *arec;
418 struct ConfItem *aconf;
419 int i, port;
420
421 if(ConfigFileEntry.stats_e_disabled)
422 {
889b0321
JT
423 sendto_one_numeric(source_p, ERR_DISABLED,
424 form_str(ERR_DISABLED), "STATS e");
212380e3 425 return;
426 }
427
428 for (i = 0; i < ATABLE_SIZE; i++)
429 {
430 for (arec = atable[i]; arec; arec = arec->next)
431 {
432 if(arec->type == CONF_EXEMPTDLINE)
433 {
434 aconf = arec->aconf;
435 get_printable_conf (aconf, &name, &host, &pass,
436 &user, &port, &classname);
437
438 sendto_one_numeric(source_p, RPL_STATSDLINE,
439 form_str(RPL_STATSDLINE),
440 'e', host, pass, "", "");
441 }
442 }
443 }}
444
445
446static void
447stats_events (struct Client *source_p)
448{
449 show_events (source_p);
450}
451
452/* stats_pending_glines()
453 *
454 * input - client pointer
455 * output - none
456 * side effects - client is shown list of pending glines
457 */
458static void
459stats_pending_glines (struct Client *source_p)
460{
461 if(ConfigFileEntry.glines)
462 {
08d11e34 463 rb_dlink_node *pending_node;
212380e3 464 struct gline_pending *glp_ptr;
465 char timebuffer[MAX_DATE_STRING];
466 struct tm *tmptr;
467
08d11e34 468 RB_DLINK_FOREACH (pending_node, pending_glines.head)
212380e3 469 {
470 glp_ptr = pending_node->data;
471
472 tmptr = localtime (&glp_ptr->time_request1);
473 strftime (timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
474
475 sendto_one_notice(source_p,
476 ":1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
477 glp_ptr->oper_nick1,
478 glp_ptr->oper_user1, glp_ptr->oper_host1,
479 glp_ptr->oper_server1, timebuffer,
480 glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
481
482 if(glp_ptr->oper_nick2[0])
483 {
484 tmptr = localtime (&glp_ptr->time_request2);
485 strftime (timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
486 sendto_one_notice(source_p,
487 ":2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
488 glp_ptr->oper_nick2,
489 glp_ptr->oper_user2, glp_ptr->oper_host2,
490 glp_ptr->oper_server2, timebuffer,
491 glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
492 }
493 }
494
08d11e34 495 if(rb_dlink_list_length (&pending_glines) > 0)
212380e3 496 sendto_one_notice(source_p, ":End of Pending G-lines");
497 }
498 else
499 sendto_one_notice(source_p, ":This server does not support G-Lines");
500
501}
502
503/* stats_glines()
504 *
505 * input - client pointer
506 * output - none
507 * side effects - client is shown list of glines
508 */
509static void
510stats_glines (struct Client *source_p)
511{
512 if(ConfigFileEntry.glines)
513 {
08d11e34 514 rb_dlink_node *gline_node;
212380e3 515 struct ConfItem *kill_ptr;
516
08d11e34 517 RB_DLINK_FOREACH_PREV (gline_node, glines.tail)
212380e3 518 {
519 kill_ptr = gline_node->data;
520
521 sendto_one_numeric(source_p, RPL_STATSKLINE,
522 form_str(RPL_STATSKLINE), 'G',
523 kill_ptr->host ? kill_ptr->host : "*",
524 kill_ptr->user ? kill_ptr->user : "*",
525 kill_ptr->passwd ? kill_ptr->passwd : "No Reason",
526 kill_ptr->spasswd ? "|" : "",
527 kill_ptr->spasswd ? kill_ptr->spasswd : "");
528 }
529 }
530 else
531 sendto_one_notice(source_p, ":This server does not support G-Lines");
532}
533
534
535static void
536stats_hubleaf(struct Client *source_p)
537{
538 struct remote_conf *hub_p;
08d11e34 539 rb_dlink_node *ptr;
212380e3 540
541 if((ConfigFileEntry.stats_h_oper_only ||
542 (ConfigServerHide.flatten_links && !IsExemptShide(source_p))) &&
543 !IsOper(source_p))
544 {
545 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
546 form_str (ERR_NOPRIVILEGES));
547 return;
548 }
549
08d11e34 550 RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head)
212380e3 551 {
552 hub_p = ptr->data;
553
554 if(hub_p->flags & CONF_HUB)
555 sendto_one_numeric(source_p, RPL_STATSHLINE,
556 form_str(RPL_STATSHLINE),
557 hub_p->host, hub_p->server);
558 else
559 sendto_one_numeric(source_p, RPL_STATSLLINE,
560 form_str(RPL_STATSLLINE),
561 hub_p->host, hub_p->server);
562 }
563}
564
565
566static void
567stats_auth (struct Client *source_p)
568{
569 /* Oper only, if unopered, return ERR_NOPRIVS */
570 if((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper (source_p))
571 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
572 form_str (ERR_NOPRIVILEGES));
573
574 /* If unopered, Only return matching auth blocks */
575 else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p))
576 {
577 struct ConfItem *aconf;
578 char *name, *host, *pass, *user, *classname;
579 int port;
580
581 if(MyConnect (source_p))
582 aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL,
583 (struct sockaddr *)&source_p->localClient->ip,
584 CONF_CLIENT,
585 source_p->localClient->ip.ss_family,
586 source_p->username);
587 else
588 aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_CLIENT,
589 0, source_p->username);
590
591 if(aconf == NULL)
592 return;
593
594 get_printable_conf (aconf, &name, &host, &pass, &user, &port, &classname);
595
596 sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE),
597 name, show_iline_prefix(source_p, aconf, user),
598 host, port, classname);
599 }
600
601 /* Theyre opered, or allowed to see all auth blocks */
602 else
603 report_auth (source_p);
604}
605
606
607static void
608stats_tklines(struct Client *source_p)
609{
610 /* Oper only, if unopered, return ERR_NOPRIVS */
611 if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper (source_p))
612 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
613 form_str (ERR_NOPRIVILEGES));
614
615 /* If unopered, Only return matching klines */
616 else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper (source_p))
617 {
618 struct ConfItem *aconf;
619 char *host, *pass, *user, *oper_reason;
620
621 if(MyConnect (source_p))
622 aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL,
623 (struct sockaddr *)&source_p->localClient->ip,
624 CONF_KILL,
625 source_p->localClient->ip.ss_family,
626 source_p->username);
627 else
628 aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL,
629 0, source_p->username);
630
631 if(aconf == NULL)
632 return;
633
634 /* dont report a permanent kline as a tkline */
635 if((aconf->flags & CONF_FLAGS_TEMPORARY) == 0)
636 return;
637
638 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
639
640 sendto_one_numeric(source_p, RPL_STATSKLINE,
8eee9ee1
JT
641 form_str(RPL_STATSKLINE), aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K',
642 host, user, pass, oper_reason ? "|" : "",
212380e3 643 oper_reason ? oper_reason : "");
644 }
645 /* Theyre opered, or allowed to see all klines */
646 else
647 {
648 struct ConfItem *aconf;
08d11e34 649 rb_dlink_node *ptr;
212380e3 650 int i;
651 char *user, *host, *pass, *oper_reason;
652
653 for(i = 0; i < LAST_TEMP_TYPE; i++)
654 {
08d11e34 655 RB_DLINK_FOREACH(ptr, temp_klines[i].head)
212380e3 656 {
657 aconf = ptr->data;
658
659 get_printable_kline(source_p, aconf, &host, &pass,
660 &user, &oper_reason);
661
662 sendto_one_numeric(source_p, RPL_STATSKLINE,
663 form_str(RPL_STATSKLINE),
664 'k', host, user, pass,
665 oper_reason ? "|" : "",
666 oper_reason ? oper_reason : "");
667 }
668 }
669 }
670}
671
672static void
673stats_klines(struct Client *source_p)
674{
675 /* Oper only, if unopered, return ERR_NOPRIVS */
676 if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper (source_p))
677 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
678 form_str (ERR_NOPRIVILEGES));
679
680 /* If unopered, Only return matching klines */
681 else if((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper (source_p))
682 {
683 struct ConfItem *aconf;
684 char *host, *pass, *user, *oper_reason;
685
686 /* search for a kline */
687 if(MyConnect (source_p))
688 aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL,
689 (struct sockaddr *)&source_p->localClient->ip,
690 CONF_KILL,
691 source_p->localClient->ip.ss_family,
692 source_p->username);
693 else
694 aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL,
695 0, source_p->username);
696
697 if(aconf == NULL)
698 return;
699
212380e3 700 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
701
702 sendto_one_numeric(source_p, RPL_STATSKLINE, form_str(RPL_STATSKLINE),
8eee9ee1
JT
703 aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K',
704 host, user, pass, oper_reason ? "|" : "",
212380e3 705 oper_reason ? oper_reason : "");
706 }
707 /* Theyre opered, or allowed to see all klines */
708 else
709 report_Klines (source_p);
710}
711
712static void
713stats_messages(struct Client *source_p)
714{
715 report_messages(source_p);
716}
717
718static void
719stats_dnsbl(struct Client *source_p)
720{
08d11e34 721 rb_dlink_node *ptr;
212380e3 722 struct Blacklist *blptr;
723
08d11e34 724 RB_DLINK_FOREACH(ptr, blacklist_list.head)
212380e3 725 {
726 blptr = ptr->data;
727
728 /* use RPL_STATSDEBUG for now -- jilles */
729 sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s %s (%d)",
730 blptr->hits,
731 blptr->host,
732 blptr->status & CONF_ILLEGAL ? "disabled" : "active",
733 blptr->refcount);
734 }
735}
736
737static void
738stats_oper(struct Client *source_p)
739{
740 struct oper_conf *oper_p;
08d11e34 741 rb_dlink_node *ptr;
212380e3 742
743 if(!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only)
744 {
745 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
746 form_str (ERR_NOPRIVILEGES));
747 return;
748 }
749
08d11e34 750 RB_DLINK_FOREACH(ptr, oper_conf_list.head)
212380e3 751 {
752 oper_p = ptr->data;
753
754 sendto_one_numeric(source_p, RPL_STATSOLINE,
755 form_str(RPL_STATSOLINE),
756 oper_p->username, oper_p->host, oper_p->name,
757 IsOper(source_p) ? get_oper_privs(oper_p->flags) : "0", "-1");
758 }
759}
760
761
762/* stats_operedup()
763 *
764 * input - client pointer
765 * output - none
766 * side effects - client is shown a list of active opers
767 */
768static void
769stats_operedup (struct Client *source_p)
770{
771 struct Client *target_p;
08d11e34 772 rb_dlink_node *oper_ptr;
212380e3 773 unsigned int count = 0;
774
08d11e34 775 RB_DLINK_FOREACH (oper_ptr, oper_list.head)
212380e3 776 {
777 target_p = oper_ptr->data;
778
779 if(IsOperInvis(target_p) && !IsOper(source_p))
780 continue;
781
782 if(target_p->user->away)
783 continue;
784
785 count++;
786
787 sendto_one_numeric(source_p, RPL_STATSDEBUG,
788 "p :%s (%s@%s)",
789 target_p->name, target_p->username,
790 target_p->host);
791 }
792
793 sendto_one_numeric(source_p, RPL_STATSDEBUG,
794 "p :%u staff members", count);
795
796 stats_p_spy (source_p);
797}
798
799static void
800stats_ports (struct Client *source_p)
801{
802 if(!IsOper (source_p) && ConfigFileEntry.stats_P_oper_only)
803 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
804 form_str (ERR_NOPRIVILEGES));
805 else
806 show_ports (source_p);
807}
808
809static void
810stats_tresv(struct Client *source_p)
811{
812 struct ConfItem *aconf;
08d11e34 813 rb_dlink_node *ptr;
212380e3 814 int i;
815
08d11e34 816 RB_DLINK_FOREACH(ptr, resv_conf_list.head)
212380e3 817 {
818 aconf = ptr->data;
819 if(aconf->hold)
820 sendto_one_numeric(source_p, RPL_STATSQLINE,
821 form_str(RPL_STATSQLINE),
822 'q', aconf->port, aconf->name, aconf->passwd);
823 }
824
825 HASH_WALK(i, R_MAX, ptr, resvTable)
826 {
827 aconf = ptr->data;
828 if(aconf->hold)
829 sendto_one_numeric(source_p, RPL_STATSQLINE,
830 form_str(RPL_STATSQLINE),
831 'q', aconf->port, aconf->name, aconf->passwd);
832 }
833 HASH_WALK_END
834}
835
836
837static void
838stats_resv(struct Client *source_p)
839{
840 struct ConfItem *aconf;
08d11e34 841 rb_dlink_node *ptr;
212380e3 842 int i;
843
08d11e34 844 RB_DLINK_FOREACH(ptr, resv_conf_list.head)
212380e3 845 {
846 aconf = ptr->data;
847 if(!aconf->hold)
848 sendto_one_numeric(source_p, RPL_STATSQLINE,
849 form_str(RPL_STATSQLINE),
850 'Q', aconf->port, aconf->name, aconf->passwd);
851 }
852
853 HASH_WALK(i, R_MAX, ptr, resvTable)
854 {
855 aconf = ptr->data;
856 if(!aconf->hold)
857 sendto_one_numeric(source_p, RPL_STATSQLINE,
858 form_str(RPL_STATSQLINE),
859 'Q', aconf->port, aconf->name, aconf->passwd);
860 }
861 HASH_WALK_END
862}
863
864static void
865stats_usage (struct Client *source_p)
866{
867 struct rusage rus;
868 time_t secs;
869 time_t rup;
870#ifdef hz
871# define hzz hz
872#else
873# ifdef HZ
874# define hzz HZ
875# else
876 int hzz = 1;
877# endif
878#endif
879
880 if(getrusage(RUSAGE_SELF, &rus) == -1)
881 {
882 sendto_one_notice(source_p, ":Getruseage error: %s.",
883 strerror(errno));
884 return;
885 }
886 secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
887 if(0 == secs)
888 secs = 1;
889
890 rup = (CurrentTime - startup_time) * hzz;
891 if(0 == rup)
892 rup = 1;
893
894 sendto_one_numeric(source_p, RPL_STATSDEBUG,
895 "R :CPU Secs %d:%d User %d:%d System %d:%d",
896 (int) (secs / 60), (int) (secs % 60),
897 (int) (rus.ru_utime.tv_sec / 60),
898 (int) (rus.ru_utime.tv_sec % 60),
899 (int) (rus.ru_stime.tv_sec / 60),
900 (int) (rus.ru_stime.tv_sec % 60));
901 sendto_one_numeric(source_p, RPL_STATSDEBUG,
902 "R :RSS %ld ShMem %ld Data %ld Stack %ld",
903 rus.ru_maxrss, (rus.ru_ixrss / rup),
904 (rus.ru_idrss / rup), (rus.ru_isrss / rup));
905 sendto_one_numeric(source_p, RPL_STATSDEBUG,
906 "R :Swaps %d Reclaims %d Faults %d",
907 (int) rus.ru_nswap, (int) rus.ru_minflt, (int) rus.ru_majflt);
908 sendto_one_numeric(source_p, RPL_STATSDEBUG,
909 "R :Block in %d out %d",
910 (int) rus.ru_inblock, (int) rus.ru_oublock);
911 sendto_one_numeric(source_p, RPL_STATSDEBUG,
912 "R :Msg Rcv %d Send %d",
913 (int) rus.ru_msgrcv, (int) rus.ru_msgsnd);
914 sendto_one_numeric(source_p, RPL_STATSDEBUG,
915 "R :Signals %d Context Vol. %d Invol %d",
916 (int) rus.ru_nsignals, (int) rus.ru_nvcsw,
917 (int) rus.ru_nivcsw);
918}
919
920static void
921stats_tstats (struct Client *source_p)
922{
923 tstats (source_p);
924}
925
926static void
927stats_uptime (struct Client *source_p)
928{
929 time_t now;
930
931 now = CurrentTime - startup_time;
932 sendto_one_numeric(source_p, RPL_STATSUPTIME,
933 form_str (RPL_STATSUPTIME),
934 now / 86400, (now / 3600) % 24,
935 (now / 60) % 60, now % 60);
936 sendto_one_numeric(source_p, RPL_STATSCONN,
937 form_str (RPL_STATSCONN),
938 MaxConnectionCount, MaxClientCount,
939 Count.totalrestartcount);
940}
941
942struct shared_flags
943{
944 int flag;
945 char letter;
946};
947static struct shared_flags shared_flagtable[] =
948{
949 { SHARED_PKLINE, 'K' },
950 { SHARED_TKLINE, 'k' },
951 { SHARED_UNKLINE, 'U' },
952 { SHARED_PXLINE, 'X' },
953 { SHARED_TXLINE, 'x' },
954 { SHARED_UNXLINE, 'Y' },
955 { SHARED_PRESV, 'Q' },
956 { SHARED_TRESV, 'q' },
957 { SHARED_UNRESV, 'R' },
958 { SHARED_LOCOPS, 'L' },
959 { SHARED_REHASH, 'H' },
960 { 0, '\0'}
961};
962
963
964static void
965stats_shared (struct Client *source_p)
966{
967 struct remote_conf *shared_p;
08d11e34 968 rb_dlink_node *ptr;
212380e3 969 char buf[15];
970 char *p;
971 int i;
972
08d11e34 973 RB_DLINK_FOREACH(ptr, shared_conf_list.head)
212380e3 974 {
975 shared_p = ptr->data;
976
977 p = buf;
978
979 *p++ = 'c';
980
981 for(i = 0; shared_flagtable[i].flag != 0; i++)
982 {
983 if(shared_p->flags & shared_flagtable[i].flag)
984 *p++ = shared_flagtable[i].letter;
985 }
986
987 *p = '\0';
988
989 sendto_one_numeric(source_p, RPL_STATSULINE,
990 form_str(RPL_STATSULINE),
991 shared_p->server, shared_p->username,
992 shared_p->host, buf);
993 }
994
08d11e34 995 RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
212380e3 996 {
997 shared_p = ptr->data;
998
999 p = buf;
1000
1001 *p++ = 'C';
1002
1003 for(i = 0; shared_flagtable[i].flag != 0; i++)
1004 {
1005 if(shared_p->flags & shared_flagtable[i].flag)
1006 *p++ = shared_flagtable[i].letter;
1007 }
1008
1009 *p = '\0';
1010
1011 sendto_one_numeric(source_p, RPL_STATSULINE,
1012 form_str(RPL_STATSULINE),
1013 shared_p->server, "*", "*", buf);
1014 }
1015}
1016
1017/* stats_servers()
1018 *
1019 * input - client pointer
1020 * output - none
1021 * side effects - client is shown lists of who connected servers
1022 */
1023static void
1024stats_servers (struct Client *source_p)
1025{
1026 struct Client *target_p;
08d11e34 1027 rb_dlink_node *ptr;
212380e3 1028 time_t seconds;
1029 int days, hours, minutes;
1030 int j = 0;
1031
1032 if(ConfigServerHide.flatten_links && !IsOper(source_p) &&
1033 !IsExemptShide(source_p))
1034 {
1035 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
1036 form_str (ERR_NOPRIVILEGES));
1037 return;
1038 }
1039
08d11e34 1040 RB_DLINK_FOREACH (ptr, serv_list.head)
212380e3 1041 {
1042 target_p = ptr->data;
1043
1044 j++;
1045 seconds = CurrentTime - target_p->localClient->firsttime;
1046
1047 days = (int) (seconds / 86400);
1048 seconds %= 86400;
1049 hours = (int) (seconds / 3600);
1050 seconds %= 3600;
1051 minutes = (int) (seconds / 60);
1052 seconds %= 60;
1053
1054 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1055 "V :%s (%s!*@*) Idle: %d SendQ: %d "
1056 "Connected: %d day%s, %d:%02d:%02d",
1057 target_p->name,
1058 (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1059 (int) (CurrentTime - target_p->localClient->lasttime),
1060 (int) linebuf_len (&target_p->localClient->buf_sendq),
1061 days, (days == 1) ? "" : "s", hours, minutes,
1062 (int) seconds);
1063 }
1064
1065 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1066 "V :%d Server(s)", j);
1067}
1068
1069static void
1070stats_tgecos(struct Client *source_p)
1071{
1072 struct ConfItem *aconf;
08d11e34 1073 rb_dlink_node *ptr;
212380e3 1074
08d11e34 1075 RB_DLINK_FOREACH(ptr, xline_conf_list.head)
212380e3 1076 {
1077 aconf = ptr->data;
1078
1079 if(aconf->hold)
1080 sendto_one_numeric(source_p, RPL_STATSXLINE,
1081 form_str(RPL_STATSXLINE),
1082 'x', aconf->port, aconf->name,
1083 aconf->passwd);
1084 }
1085}
1086
1087static void
1088stats_gecos(struct Client *source_p)
1089{
1090 struct ConfItem *aconf;
08d11e34 1091 rb_dlink_node *ptr;
212380e3 1092
08d11e34 1093 RB_DLINK_FOREACH(ptr, xline_conf_list.head)
212380e3 1094 {
1095 aconf = ptr->data;
1096
1097 if(!aconf->hold)
1098 sendto_one_numeric(source_p, RPL_STATSXLINE,
1099 form_str(RPL_STATSXLINE),
1100 'X', aconf->port, aconf->name,
1101 aconf->passwd);
1102 }
1103}
1104
1105static void
1106stats_class(struct Client *source_p)
1107{
1108 if(ConfigFileEntry.stats_y_oper_only && !IsOper(source_p))
1109 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
1110 form_str (ERR_NOPRIVILEGES));
1111 else
1112 report_classes(source_p);
1113}
1114
1115static void
1116stats_memory (struct Client *source_p)
1117{
1118 count_memory (source_p);
1119}
1120
1121static void
1122stats_ziplinks (struct Client *source_p)
1123{
08d11e34 1124 rb_dlink_node *ptr;
212380e3 1125 struct Client *target_p;
1126 int sent_data = 0;
1127
08d11e34 1128 RB_DLINK_FOREACH (ptr, serv_list.head)
212380e3 1129 {
1130 target_p = ptr->data;
1131 if(IsCapable (target_p, CAP_ZIP))
1132 {
1133 /* we use memcpy(3) and a local copy of the structure to
1134 * work around a register use bug on GCC on the SPARC.
1135 * -jmallett, 04/27/2002
1136 */
1137 struct ZipStats zipstats;
1138 memcpy (&zipstats, &target_p->localClient->zipstats,
1139 sizeof (struct ZipStats));
1140 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1141 "Z :ZipLinks stats for %s send[%.2f%% compression "
1142 "(%lu kB data/%lu kB wire)] recv[%.2f%% compression "
1143 "(%lu kB data/%lu kB wire)]",
1144 target_p->name,
1145 zipstats.out_ratio, zipstats.outK, zipstats.outK_wire,
1146 zipstats.in_ratio, zipstats.inK, zipstats.inK_wire);
1147 sent_data++;
1148 }
1149 }
1150
1151 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1152 "Z :%u ziplink(s)", sent_data);
1153}
1154
1155static void
1156stats_servlinks (struct Client *source_p)
1157{
1158 static char Sformat[] = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
1159 long uptime, sendK, receiveK;
1160 struct Client *target_p;
08d11e34 1161 rb_dlink_node *ptr;
212380e3 1162 int j = 0;
1163
1164 if(ConfigServerHide.flatten_links && !IsOper (source_p) &&
1165 !IsExemptShide(source_p))
1166 {
1167 sendto_one_numeric(source_p, ERR_NOPRIVILEGES,
1168 form_str (ERR_NOPRIVILEGES));
1169 return;
1170 }
1171
1172 sendK = receiveK = 0;
1173
08d11e34 1174 RB_DLINK_FOREACH (ptr, serv_list.head)
212380e3 1175 {
1176 target_p = ptr->data;
1177
1178 j++;
1179 sendK += target_p->localClient->sendK;
1180 receiveK += target_p->localClient->receiveK;
1181
1182 sendto_one(source_p, Sformat,
1183 get_id(&me, source_p), RPL_STATSLINKINFO, get_id(source_p, source_p),
1184 get_server_name(target_p, SHOW_IP),
1185 (int) linebuf_len (&target_p->localClient->buf_sendq),
1186 (int) target_p->localClient->sendM,
1187 (int) target_p->localClient->sendK,
1188 (int) target_p->localClient->receiveM,
1189 (int) target_p->localClient->receiveK,
1190 CurrentTime - target_p->localClient->firsttime,
1191 (CurrentTime > target_p->localClient->lasttime) ?
1192 (CurrentTime - target_p->localClient->lasttime) : 0,
1193 IsOper (source_p) ? show_capabilities (target_p) : "TS");
1194 }
1195
1196 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1197 "? :%u total server(s)", j);
1198
1199 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1200 "? :Sent total : %7.2f %s",
1201 _GMKv (sendK), _GMKs (sendK));
1202 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1203 "? :Recv total : %7.2f %s",
1204 _GMKv (receiveK), _GMKs (receiveK));
1205
1206 uptime = (CurrentTime - startup_time);
1207
1208 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1209 "? :Server send: %7.2f %s (%4.1f K/s)",
1210 _GMKv (me.localClient->sendK),
1211 _GMKs (me.localClient->sendK),
1212 (float) ((float) me.localClient->sendK / (float) uptime));
1213 sendto_one_numeric(source_p, RPL_STATSDEBUG,
1214 "? :Server recv: %7.2f %s (%4.1f K/s)",
1215 _GMKv (me.localClient->receiveK),
1216 _GMKs (me.localClient->receiveK),
1217 (float) ((float) me.localClient->receiveK / (float) uptime));
1218}
1219
1220static void
1221stats_ltrace(struct Client *source_p, int parc, const char *parv[])
1222{
1223 int doall = 0;
1224 int wilds = 0;
1225 const char *name;
1226 char statchar = parv[1][0];
1227
1228 /* this is def targeted at us somehow.. */
1229 if(parc > 2 && !EmptyString(parv[2]))
1230 {
1231 /* directed at us generically? */
1232 if(match(parv[2], me.name) ||
1233 (!MyClient(source_p) && !irccmp(parv[2], me.id)))
1234 {
1235 name = me.name;
1236 doall = 1;
1237 }
1238 else
1239 {
1240 name = parv[2];
1241 wilds = strchr(name, '*') || strchr(name, '?');
1242 }
1243
1244 /* must be directed at a specific person thats not us */
1245 if(!doall && !wilds)
1246 {
1247 struct Client *target_p;
1248
1249 if(MyClient(source_p))
1250 target_p = find_named_person(name);
1251 else
1252 target_p = find_person(name);
1253
1254 if(target_p != NULL)
1255 {
1256 stats_spy(source_p, statchar, target_p->name);
1257 stats_l_client(source_p, target_p, statchar);
1258 }
1259 else
1260 sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
1261 form_str(ERR_NOSUCHSERVER),
1262 name);
1263
1264 return;
1265 }
1266 }
1267 else
1268 {
1269 name = me.name;
1270 doall = 1;
1271 }
1272
1273 stats_spy(source_p, statchar, name);
1274
1275 if(doall)
1276 {
1277 /* local opers get everyone */
1278 if(MyOper(source_p))
1279 {
1280 stats_l_list(source_p, name, doall, wilds, &unknown_list, statchar);
1281 stats_l_list(source_p, name, doall, wilds, &lclient_list, statchar);
1282 }
1283 else
1284 {
1285 /* they still need themselves if theyre local.. */
1286 if(MyClient(source_p))
1287 stats_l_client(source_p, source_p, statchar);
1288
1289 stats_l_list(source_p, name, doall, wilds, &local_oper_list, statchar);
1290 }
1291
1292 if (!ConfigServerHide.flatten_links || IsOper(source_p) ||
1293 IsExemptShide(source_p))
1294 stats_l_list(source_p, name, doall, wilds, &serv_list, statchar);
1295
1296 return;
1297 }
1298
1299 /* ok, at this point theyre looking for a specific client whos on
1300 * our server.. but it contains a wildcard. --fl
1301 */
1302 stats_l_list(source_p, name, doall, wilds, &lclient_list, statchar);
1303
1304 return;
1305}
1306
1307
1308static void
1309stats_l_list(struct Client *source_p, const char *name, int doall, int wilds,
08d11e34 1310 rb_dlink_list * list, char statchar)
212380e3 1311{
08d11e34 1312 rb_dlink_node *ptr;
212380e3 1313 struct Client *target_p;
1314
1315 /* send information about connections which match. note, we
1316 * dont need tests for IsInvisible(), because non-opers will
1317 * never get here for normal clients --fl
1318 */
08d11e34 1319 RB_DLINK_FOREACH(ptr, list->head)
212380e3 1320 {
1321 target_p = ptr->data;
1322
1323 if(!doall && wilds && !match(name, target_p->name))
1324 continue;
1325
1326 stats_l_client(source_p, target_p, statchar);
1327 }
1328}
1329
1330void
1331stats_l_client(struct Client *source_p, struct Client *target_p,
1332 char statchar)
1333{
1334 if(IsAnyServer(target_p))
1335 {
1336 sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat,
1337 get_server_name(target_p, SHOW_IP),
1338 (int) linebuf_len(&target_p->localClient->buf_sendq),
1339 (int) target_p->localClient->sendM,
1340 (int) target_p->localClient->sendK,
1341 (int) target_p->localClient->receiveM,
1342 (int) target_p->localClient->receiveK,
1343 CurrentTime - target_p->localClient->firsttime,
1344 (CurrentTime > target_p->localClient->lasttime) ?
1345 (CurrentTime - target_p->localClient->lasttime) : 0,
1346 IsOper(source_p) ? show_capabilities(target_p) : "-");
1347 }
1348
1349 else
1350 {
1351 sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat,
1352 show_ip(source_p, target_p) ?
1353 (IsUpper(statchar) ?
1354 get_client_name(target_p, SHOW_IP) :
1355 get_client_name(target_p, HIDE_IP)) :
1356 get_client_name(target_p, MASK_IP),
1357 (int) linebuf_len(&target_p->localClient->buf_sendq),
1358 (int) target_p->localClient->sendM,
1359 (int) target_p->localClient->sendK,
1360 (int) target_p->localClient->receiveM,
1361 (int) target_p->localClient->receiveK,
1362 CurrentTime - target_p->localClient->firsttime,
1363 (CurrentTime > target_p->localClient->lasttime) ?
1364 (CurrentTime - target_p->localClient->lasttime) : 0,
1365 "-");
1366 }
1367}
1368
b8127271
VY
1369static void\r
1370rb_dump_fd_callback(int fd, const char *desc, void *data)\r
1371{\r
1372 struct Client *source_p = data;\r
1373 sendto_one_numeric(source_p, RPL_STATSDEBUG, "F :fd %-3d desc '%s'", fd, desc);\r
1374}\r
1375\r
1376static void\r
1377stats_comm(struct Client *source_p)\r
1378{\r
1379 rb_dump_fd(rb_dump_fd_callback, source_p);\r
1380 send_pop_queue(source_p);\r
1381}
1382
212380e3 1383/*
1384 * stats_spy
1385 *
1386 * inputs - pointer to client doing the /stats
1387 * - char letter they are doing /stats on
1388 * output - none
1389 * side effects -
1390 * This little helper function reports to opers if configured.
1391 * personally, I don't see why opers need to see stats requests
1392 * at all. They are just "noise" to an oper, and users can't do
1393 * any damage with stats requests now anyway. So, why show them?
1394 * -Dianora
1395 */
1396static void
1397stats_spy(struct Client *source_p, char statchar, const char *name)
1398{
1399 hook_data_int data;
1400
1401 data.client = source_p;
1402 data.arg1 = name;
1403 data.arg2 = (int) statchar;
1404
1405 call_hook(doing_stats_hook, &data);
1406}
1407
1408/* stats_p_spy()
1409 *
1410 * input - pointer to client doing stats
1411 * ouput -
1412 * side effects - call hook doing_stats_p
1413 */
1414static void
1415stats_p_spy (struct Client *source_p)
1416{
1417 hook_data data;
1418
1419 data.client = source_p;
1420 data.arg1 = data.arg2 = NULL;
1421
1422 call_hook(doing_stats_p_hook, &data);
1423}
1424