2 * IRC - Internet Relay Chat, ircd/m_stats.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
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 1, or (at your option)
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * m_functions execute protocol messages on this server:
29 * cptr is always NON-NULL, pointing to a *LOCAL* client
30 * structure (with an open socket connected!). This
31 * identifies the physical socket where the message
32 * originated (or which caused the m_function to be
33 * executed--some m_functions may call others...).
35 * sptr is the source of the message, defined by the
36 * prefix part of the message if present. If not
37 * or prefix not found, then sptr==cptr.
39 * (!IsServer(cptr)) => (cptr == sptr), because
40 * prefixes are taken *only* from servers...
43 * (sptr == cptr) => the message didn't
46 * (sptr != cptr && IsServer(sptr) means
47 * the prefix specified servername. (?)
49 * (sptr != cptr && !IsServer(sptr) means
50 * that message originated from a remote
55 * (!IsServer(sptr)) means that, sptr can safely
56 * taken as defining the target structure of the
57 * message in this server.
59 * *Always* true (if 'parse' and others are working correct):
61 * 1) sptr->from == cptr (note: cptr->from == cptr)
63 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
64 * *cannot* be a local connection, unless it's
65 * actually cptr!). [MyConnect(x) should probably
66 * be defined as (x == x->from) --msa ]
68 * parc number of variable parameter strings (if zero,
69 * parv is allowed to be NULL)
71 * parv a NULL terminated list of parameter pointers,
73 * parv[0], sender (prefix string), if not present
74 * this points to an empty string.
75 * parv[1]...parv[parc-1]
76 * pointers to additional parameters
77 * parv[parc] == NULL, *always*
79 * note: it is guaranteed that parv[0]..parv[parc-1] are all
84 * No need to include handlers.h here the signatures must match
85 * and we don't need to force a rebuild of all the handlers everytime
86 * we add a new one to the list. --Bleep
100 #include "ircd_alloc.h"
101 #include "ircd_chattr.h"
102 #include "ircd_reply.h"
103 #include "ircd_string.h"
105 #include "listener.h"
109 #include "numnicks.h"
110 #include "opercmds.h"
119 #include "userload.h"
127 * m_stats - generic message handler
129 * parv[0] = sender prefix
130 * parv[1] = statistics selector (defaults to Message frequency)
131 * parv[2] = target server (current server defaulted, if omitted)
132 * And 'stats l' and 'stats' L:
133 * parv[3] = server mask ("*" defaulted, if omitted)
135 * parv[3] = port mask (returns p-lines when its port is matched by this)
136 * Or for stats k,K,i and I:
137 * parv[3] = [user@]host.name (returns which K/I-lines match this)
138 * or [user@]host.mask (returns which K/I-lines are mmatched by this)
139 * (defaults to old reply if ommitted, when local or Oper)
140 * A remote mask (something containing wildcards) is only
141 * allowed for IRC Operators.
143 * parv[3] = time param
144 * parv[4] = time param
145 * (see report_memleak_stats() in runmalloc.c for details)
147 * This function is getting really ugly. -Ghostwolf
149 int m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
151 struct Message *mptr;
152 struct Client *acptr;
153 struct ConfItem *aconf;
154 char stat = parc > 1 ? parv[1][0] : '\0';
155 const char **infotext = statsinfo;
158 if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
166 int doall = 0, wilds = 0;
168 if (parc > 3 && *parv[3])
172 wilds = (*name == '*' || *name == '?');
173 for (p = name + 1; *p; ++p)
174 if ((*p == '*' || *p == '?') && p[-1] != '\\')
183 * Send info about connections which match, or all if the
184 * mask matches me.name. Only restrictions are on those who
185 * are invisible not being visible to 'foreigners' who use
186 * a wild card based search to list it.
188 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO, "Connection SendQ "
189 "SendM SendKBytes RcveM RcveKBytes :Open since");
190 for (i = 0; i <= HighestFd; i++)
192 if (!(acptr = LocalClientArray[i]))
194 /* Don't return clients when this is a request for `all' */
195 if (doall && IsUser(acptr))
197 /* Don't show invisible people to non opers unless they know the nick */
198 if (IsInvisible(acptr) && (doall || wilds) && !IsAnOper(acptr) && (acptr != sptr))
200 /* Only show the ones that match the given mask - if any */
201 if (!doall && wilds && match(name, acptr->name))
203 /* Skip all that do not match the specific query */
204 if (!(doall || wilds) && 0 != ircd_strcmp(name, acptr->name))
206 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO,
207 "%s %u %u %u %u %u :%Tu", acptr->name,
208 (int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
209 (int)acptr->sendK, (int)acptr->receiveM,
210 (int)acptr->receiveK, CurrentTime - acptr->firsttime);
216 report_configured_links(sptr, CONF_SERVER);
219 case 'g': /* send glines */
224 report_configured_links(sptr, CONF_HUB | CONF_LEAF);
229 case 'k': /* display CONF_IPKILL as well
233 char *user, *host, *p;
234 int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
237 report_configured_links(sptr, conf_status);
242 for (p = parv[3]; *p; p++)
250 if (*p == '?' || *p == '*')
259 if (conf_status == CONF_CLIENT)
261 user = 0; /* Not used, but to avoid compiler warning. */
267 if ((host = strchr(parv[3], '@')))
278 for (aconf = GlobalConfList; aconf; aconf = aconf->next)
280 if ((aconf->status & conf_status))
282 if (conf_status == CONF_KLINE)
284 if ((!wilds && ((user || aconf->host[1]) &&
285 !match(aconf->host, host) &&
286 (!user || !match(aconf->name, user)))) ||
287 (wilds && !mmatch(host, aconf->host) &&
288 (!user || !mmatch(user, aconf->name))))
290 send_reply(sptr, RPL_STATSKLINE,
291 (aconf->status & CONF_KILL) ? 'K' : 'k', aconf->host,
292 aconf->passwd, aconf->name, aconf->port,
293 get_conf_class(aconf));
298 else if (conf_status == CONF_CLIENT)
300 if ((!wilds && (!match(aconf->host, host) ||
301 !match(aconf->name, host))) ||
302 (wilds && (!mmatch(host, aconf->host) ||
303 !mmatch(host, aconf->name))))
305 send_reply(sptr, RPL_STATSILINE, 'I', aconf->host, aconf->name,
306 aconf->port, get_conf_class(aconf));
317 send_reply(sptr, RPL_STATMEMTOT, fda_get_byte_count(),
318 fda_get_block_count());
323 sendto_one(sptr, rpl_str(RPL_STATMEMTOT), /* XXX DEAD */
324 me.name, parv[0], get_mem_size(), get_alloc_cnt());
327 report_memleak_stats(sptr, parc, parv);
329 #if !defined(MEMSIZESTATS) && !defined(MEMLEAKSTATS)
330 sendto_one(sptr, ":%s NOTICE %s :stats M : Memory allocation monitoring " /* XXX DEAD */
331 "is not enabled on this server", me.name, parv[0]);
336 for (mptr = msgtab; mptr->cmd; mptr++)
338 send_reply(sptr, RPL_STATSCOMMANDS, mptr->cmd, mptr->count,
343 report_configured_links(sptr, CONF_OPS);
348 * show listener ports
349 * show hidden ports to opers, if there are more than 3 parameters,
350 * interpret the fourth parameter as the port number.
352 show_ports(sptr, 0, (parc > 3) ? atoi(parv[3]) : 0, 100);
357 send_usage(sptr, parv[0]);
361 report_configured_links(sptr, CONF_CRULEALL);
364 report_configured_links(sptr, CONF_CRULE);
367 tstats(sptr, parv[0]);
370 report_configured_links(sptr, CONF_TLINES);
373 report_configured_links(sptr, CONF_UWORLD);
379 nowr = CurrentTime - me.since;
380 send_reply(sptr, RPL_STATSUPTIME, nowr / 86400, (nowr / 3600) % 24,
381 (nowr / 60) % 60, nowr % 60);
382 send_reply(sptr, RPL_STATSCONN, max_connection_count, max_client_count);
392 send_listinfo(sptr, parv[0]);
397 report_classes(sptr);
401 count_memory(sptr, parv[0]);
406 sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s", sptr, *infotext++);
409 send_reply(sptr, RPL_ENDOFSTATS, stat);
414 * ms_stats - server message handler
416 * parv[0] = sender prefix
417 * parv[1] = statistics selector (defaults to Message frequency)
418 * parv[2] = target server (current server defaulted, if omitted)
419 * And 'stats l' and 'stats' L:
420 * parv[3] = server mask ("*" defaulted, if omitted)
422 * parv[3] = port mask (returns p-lines when its port is matched by this)
423 * Or for stats k,K,i and I:
424 * parv[3] = [user@]host.name (returns which K/I-lines match this)
425 * or [user@]host.mask (returns which K/I-lines are mmatched by this)
426 * (defaults to old reply if ommitted, when local or Oper)
427 * A remote mask (something containing wildcards) is only
428 * allowed for IRC Operators.
430 * parv[3] = time param
431 * parv[4] = time param
432 * (see report_memleak_stats() in runmalloc.c for details)
434 * This function is getting really ugly. -Ghostwolf
436 int ms_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
438 struct Message *mptr;
439 struct Client *acptr;
440 struct ConfItem *aconf;
441 char stat = parc > 1 ? parv[1][0] : '\0';
444 if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
452 int doall = 0, wilds = 0;
454 if (parc > 3 && *parv[3])
458 wilds = (*name == '*' || *name == '?');
459 for (p = name + 1; *p; ++p)
460 if ((*p == '*' || *p == '?') && p[-1] != '\\')
469 * Send info about connections which match, or all if the
470 * mask matches me.name. Only restrictions are on those who
471 * are invisible not being visible to 'foreigners' who use
472 * a wild card based search to list it.
474 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO, "Connection SendQ "
475 "SendM SendKBytes RcveM RcveKBytes :Open since");
476 for (i = 0; i <= HighestFd; i++)
478 if (!(acptr = LocalClientArray[i]))
480 /* Don't return clients when this is a request for `all' */
481 if (doall && IsUser(acptr))
483 /* Don't show invisible people to unauthorized people when using
484 * wildcards -- Is this still needed now /stats is oper only ?
485 * Not here, because ms_stats is specifically a remote command,
486 * thus the check was removed. -Ghostwolf */
487 /* Only show the ones that match the given mask - if any */
488 if (!doall && wilds && match(name, acptr->name))
490 /* Skip all that do not match the specific query */
491 if (!(doall || wilds) && 0 != ircd_strcmp(name, acptr->name))
493 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO,
494 "%s %u %u %u %u %u :%Tu", acptr->name,
495 (int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
496 (int)acptr->sendK, (int)acptr->receiveM,
497 (int)acptr->receiveK, CurrentTime - acptr->firsttime);
503 report_configured_links(sptr, CONF_SERVER);
506 case 'g': /* send glines */
511 report_configured_links(sptr, CONF_HUB | CONF_LEAF);
516 case 'k': /* display CONF_IPKILL as well
520 char *user, *host, *p;
521 int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
522 if (IsOper(sptr) && parc < 4)
524 report_configured_links(sptr, conf_status);
527 if (parc < 4 || *parv[3] == '\0')
528 return need_more_params(sptr,
529 (conf_status & CONF_KLINE) ? "STATS K" : "STATS I");
532 for (p = parv[3]; *p; p++)
540 if (*p == '?' || *p == '*')
554 if (conf_status == CONF_CLIENT)
556 user = 0; /* Not used, but to avoid compiler warning. */
562 if ((host = strchr(parv[3], '@')))
573 for (aconf = GlobalConfList; aconf; aconf = aconf->next)
575 if ((aconf->status & conf_status))
577 if (conf_status == CONF_KLINE)
579 if ((!wilds && ((user || aconf->host[1]) &&
580 !match(aconf->host, host) &&
581 (!user || !match(aconf->name, user)))) ||
582 (wilds && !mmatch(host, aconf->host) &&
583 (!user || !mmatch(user, aconf->name))))
585 send_reply(sptr, RPL_STATSKLINE,
586 (aconf->status & CONF_KILL) ? 'K' : 'k', aconf->host,
587 aconf->passwd, aconf->name, aconf->port,
588 get_conf_class(aconf));
593 else if (conf_status == CONF_CLIENT)
595 if ((!wilds && (!match(aconf->host, host) ||
596 !match(aconf->name, host))) ||
597 (wilds && (!mmatch(host, aconf->host) ||
598 !mmatch(host, aconf->name))))
600 send_reply(sptr, RPL_STATSILINE, 'I', aconf->host, aconf->name,
601 aconf->port, get_conf_class(aconf));
612 send_reply(sptr, RPL_STATMEMTOT, fda_get_byte_count(),
613 fda_get_block_count());
618 sendto_one(sptr, rpl_str(RPL_STATMEMTOT), /* XXX DEAD */
619 me.name, parv[0], get_mem_size(), get_alloc_cnt());
622 report_memleak_stats(sptr, parc, parv);
624 #if !defined(MEMSIZESTATS) && !defined(MEMLEAKSTATS)
625 sendto_one(sptr, ":%s NOTICE %s :stats M : Memory allocation monitoring " /* XXX DEAD */
626 "is not enabled on this server", me.name, parv[0]);
631 for (mptr = msgtab; mptr->cmd; mptr++)
633 send_reply(sptr, RPL_STATSCOMMANDS, mptr->cmd, mptr->count,
638 report_configured_links(sptr, CONF_OPS);
643 * show listener ports
644 * show hidden ports to opers, if there are more than 3 parameters,
645 * interpret the fourth parameter as the port number, limit non-local
646 * or non-oper results to 8 ports.
648 show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0, IsOper(sptr) ? 100 : 8);
653 send_usage(sptr, parv[0]);
657 report_configured_links(sptr, CONF_CRULEALL);
660 report_configured_links(sptr, CONF_CRULE);
663 tstats(sptr, parv[0]);
666 report_configured_links(sptr, CONF_TLINES);
669 report_configured_links(sptr, CONF_UWORLD);
675 nowr = CurrentTime - me.since;
676 send_reply(sptr, RPL_STATSUPTIME, nowr / 86400, (nowr / 3600) % 24,
677 (nowr / 60) % 60, nowr % 60);
678 send_reply(sptr, RPL_STATSCONN, max_connection_count, max_client_count);
688 send_listinfo(sptr, parv[0]);
693 report_classes(sptr);
697 count_memory(sptr, parv[0]);
703 send_reply(sptr, RPL_ENDOFSTATS, stat);
708 * mo_stats - oper message handler
710 * parv[0] = sender prefix
711 * parv[1] = statistics selector (defaults to Message frequency)
712 * parv[2] = target server (current server defaulted, if omitted)
713 * And 'stats l' and 'stats' L:
714 * parv[3] = server mask ("*" defaulted, if omitted)
716 * parv[3] = port mask (returns p-lines when its port is matched by this)
717 * Or for stats k,K,i and I:
718 * parv[3] = [user@]host.name (returns which K/I-lines match this)
719 * or [user@]host.mask (returns which K/I-lines are mmatched by this)
720 * (defaults to old reply if ommitted, when local or Oper)
721 * A remote mask (something containing wildcards) is only
722 * allowed for IRC Operators.
724 * parv[3] = time param
725 * parv[4] = time param
726 * (see report_memleak_stats() in runmalloc.c for details)
728 * This function is getting really ugly. -Ghostwolf
730 int mo_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
732 struct Message *mptr;
733 struct Client *acptr;
734 struct ConfItem *aconf;
735 char stat = parc > 1 ? parv[1][0] : '\0';
736 const char **infotext = statsinfo;
739 if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
747 int doall = 0, wilds = 0;
749 if (parc > 3 && *parv[3])
753 wilds = (*name == '*' || *name == '?');
754 for (p = name + 1; *p; ++p)
755 if ((*p == '*' || *p == '?') && p[-1] != '\\')
764 * Send info about connections which match, or all if the
765 * mask matches me.name. Only restrictions are on those who
766 * are invisible not being visible to 'foreigners' who use
767 * a wild card based search to list it.
769 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO, "Connection SendQ "
770 "SendM SendKBytes RcveM RcveKBytes :Open since");
771 for (i = 0; i <= HighestFd; i++)
773 if (!(acptr = LocalClientArray[i]))
775 /* Don't return clients when this is a request for `all' */
776 if (doall && IsUser(acptr))
778 /* Only show the ones that match the given mask - if any */
779 if (!doall && wilds && match(name, acptr->name))
781 /* Skip all that do not match the specific query */
782 if (!(doall || wilds) && 0 != ircd_strcmp(name, acptr->name))
784 send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO,
785 "%s %u %u %u %u %u :%Tu", acptr->name,
786 (int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
787 (int)acptr->sendK, (int)acptr->receiveM,
788 (int)acptr->receiveK, CurrentTime - acptr->firsttime);
794 report_configured_links(sptr, CONF_SERVER);
797 case 'g': /* send glines */
802 report_configured_links(sptr, CONF_HUB | CONF_LEAF);
807 case 'k': /* display CONF_IPKILL as well
811 char *user, *host, *p;
812 int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
815 report_configured_links(sptr, conf_status);
820 for (p = parv[3]; *p; p++)
828 if (*p == '?' || *p == '*')
837 if (conf_status == CONF_CLIENT)
839 user = 0; /* Not used, but to avoid compiler warning. */
845 if ((host = strchr(parv[3], '@')))
856 for (aconf = GlobalConfList; aconf; aconf = aconf->next)
858 if ((aconf->status & conf_status))
860 if (conf_status == CONF_KLINE)
862 if ((!wilds && ((user || aconf->host[1]) &&
863 !match(aconf->host, host) &&
864 (!user || !match(aconf->name, user)))) ||
865 (wilds && !mmatch(host, aconf->host) &&
866 (!user || !mmatch(user, aconf->name))))
868 send_reply(sptr, RPL_STATSKLINE,
869 (aconf->status & CONF_KILL) ? 'K' : 'k', aconf->host,
870 aconf->passwd, aconf->name, aconf->port,
871 get_conf_class(aconf));
876 else if (conf_status == CONF_CLIENT)
878 if ((!wilds && (!match(aconf->host, host) ||
879 !match(aconf->name, host))) ||
880 (wilds && (!mmatch(host, aconf->host) ||
881 !mmatch(host, aconf->name))))
883 send_reply(sptr, RPL_STATSILINE, 'I', aconf->host, aconf->name,
884 aconf->port, get_conf_class(aconf));
895 send_reply(sptr, RPL_STATMEMTOT, fda_get_byte_count(),
896 fda_get_block_count());
901 sendto_one(sptr, rpl_str(RPL_STATMEMTOT), /* XXX DEAD */
902 me.name, parv[0], get_mem_size(), get_alloc_cnt());
905 report_memleak_stats(sptr, parc, parv);
907 #if !defined(MEMSIZESTATS) && !defined(MEMLEAKSTATS)
908 sendto_one(sptr, ":%s NOTICE %s :stats M : Memory allocation monitoring " /* XXX DEAD */
909 "is not enabled on this server", me.name, parv[0]);
914 for (mptr = msgtab; mptr->cmd; mptr++)
916 send_reply(sptr, RPL_STATSCOMMANDS, mptr->cmd, mptr->count,
921 report_configured_links(sptr, CONF_OPS);
926 * show listener ports
927 * show hidden ports to opers, if there are more than 3 parameters,
928 * interpret the fourth parameter as the port number, limit non-local
929 * or non-oper results to 8 ports.
931 show_ports(sptr, 1, (parc > 3) ? atoi(parv[3]) : 0, 100);
936 send_usage(sptr, parv[0]);
940 report_configured_links(sptr, CONF_CRULEALL);
943 report_configured_links(sptr, CONF_CRULE);
946 tstats(sptr, parv[0]);
949 report_configured_links(sptr, CONF_TLINES);
952 report_configured_links(sptr, CONF_UWORLD);
958 nowr = CurrentTime - me.since;
959 send_reply(sptr, RPL_STATSUPTIME, nowr / 86400, (nowr / 3600) % 24,
960 (nowr / 60) % 60, nowr % 60);
961 send_reply(sptr, RPL_STATSCONN, max_connection_count, max_client_count);
971 send_listinfo(sptr, parv[0]);
976 report_classes(sptr);
980 count_memory(sptr, parv[0]);
985 sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s", sptr, *infotext++);
988 send_reply(sptr, RPL_ENDOFSTATS, stat);
996 * parv[0] = sender prefix
997 * parv[1] = statistics selector (defaults to Message frequency)
998 * parv[2] = target server (current server defaulted, if omitted)
999 * And 'stats l' and 'stats' L:
1000 * parv[3] = server mask ("*" defaulted, if omitted)
1002 * parv[3] = port mask (returns p-lines when its port is matched by this)
1003 * Or for stats k,K,i and I:
1004 * parv[3] = [user@]host.name (returns which K/I-lines match this)
1005 * or [user@]host.mask (returns which K/I-lines are mmatched by this)
1006 * (defaults to old reply if ommitted, when local or Oper)
1007 * A remote mask (something containing wildcards) is only
1008 * allowed for IRC Operators.
1010 * parv[3] = time param
1011 * parv[4] = time param
1012 * (see report_memleak_stats() in runmalloc.c for details)
1014 * This function is getting really ugly. -Ghostwolf
1016 int m_stats(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
1018 static char Sformat[] = ":%s %d %s Connection SendQ SendM SendKBytes "
1019 "RcveM RcveKBytes :Open since";
1020 static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :" TIME_T_FMT;
1021 struct Message *mptr;
1022 struct Client *acptr;
1023 struct Gline* gline;
1024 struct ConfItem *aconf;
1025 char stat = parc > 1 ? parv[1][0] : '\0';
1028 /* m_stats is so obnoxiously full of special cases that the different
1029 * hunt_server() possiblites were becoming very messy. It now uses a
1030 * switch() so as to be easier to read and update as params change.
1035 /* open to all, standard # of params */
1039 if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv) /* XXX DEAD */
1045 /* open to all, varying # of params */
1055 if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv) /* XXX DEAD */
1061 if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv) /* XXX DEAD */
1068 /* oper only, varying # of params */
1075 if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv) /* XXX DEAD */
1081 if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s %s :%s", 2, parc, /* XXX DEAD */
1082 parv) != HUNTED_ISME)
1085 else if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv) /* XXX DEAD */
1091 /* oper only, standard # of params */
1094 if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv) /* XXX DEAD */
1106 int doall = 0, wilds = 0;
1108 if (parc > 3 && *parv[3])
1112 wilds = (*name == '*' || *name == '?');
1113 for (p = name + 1; *p; ++p)
1114 if ((*p == '*' || *p == '?') && p[-1] != '\\')
1123 * Send info about connections which match, or all if the
1124 * mask matches me.name. Only restrictions are on those who
1125 * are invisible not being visible to 'foreigners' who use
1126 * a wild card based search to list it.
1128 sendto_one(sptr, Sformat, me.name, RPL_STATSLINKINFO, parv[0]); /* XXX DEAD */
1129 for (i = 0; i <= HighestFd; i++)
1131 if (!(acptr = LocalClientArray[i]))
1133 /* Don't return clients when this is a request for `all' */
1134 if (doall && IsUser(acptr))
1136 /* Don't show invisible people to unauthorized people when using
1137 * wildcards -- Is this still needed now /stats is oper only ? */
1138 if (IsInvisible(acptr) && (doall || wilds) &&
1139 !(MyConnect(sptr) && IsOper(sptr)) &&
1140 !IsAnOper(acptr) && (acptr != sptr))
1142 /* Only show the ones that match the given mask - if any */
1143 if (!doall && wilds && match(name, acptr->name))
1145 /* Skip all that do not match the specific query */
1146 if (!(doall || wilds) && 0 != ircd_strcmp(name, acptr->name))
1148 sendto_one(sptr, Lformat, me.name, RPL_STATSLINKINFO, parv[0], /* XXX DEAD */
1150 (int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
1151 (int)acptr->sendK, (int)acptr->receiveM, (int)acptr->receiveK,
1152 CurrentTime - acptr->firsttime);
1158 report_configured_links(sptr, CONF_SERVER);
1161 case 'g': /* send glines */
1162 gline_remove_expired(TStime());
1163 for (gline = GlobalGlineList; gline; gline = gline->next) {
1164 sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name, /* XXX DEAD */
1165 sptr->name, 'G', gline->name, gline->host,
1166 gline->expire, gline->reason);
1171 report_configured_links(sptr, CONF_HUB | CONF_LEAF);
1176 case 'k': /* display CONF_IPKILL as well
1177 as CONF_KILL -Kev */
1180 char *user, *host, *p;
1181 int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
1182 if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
1184 report_configured_links(sptr, conf_status);
1187 if (parc < 4 || *parv[3] == '\0')
1188 return need_more_params(sptr,
1189 (conf_status & CONF_KLINE) ? "STATS K" : "STATS I");
1192 for (p = parv[3]; *p; p++)
1200 if (*p == '?' || *p == '*')
1206 if (!(MyConnect(sptr) || IsOper(sptr)))
1214 if (conf_status == CONF_CLIENT)
1216 user = 0; /* Not used, but to avoid compiler warning. */
1222 if ((host = strchr(parv[3], '@')))
1233 for (aconf = GlobalConfList; aconf; aconf = aconf->next)
1235 if ((aconf->status & conf_status))
1237 if (conf_status == CONF_KLINE)
1239 if ((!wilds && ((user || aconf->host[1]) &&
1240 !match(aconf->host, host) &&
1241 (!user || !match(aconf->name, user)))) ||
1242 (wilds && !mmatch(host, aconf->host) &&
1243 (!user || !mmatch(user, aconf->name))))
1245 sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, /* XXX DEAD */
1246 sptr->name, 'K', aconf->host, aconf->passwd, aconf->name,
1247 aconf->port, get_conf_class(aconf));
1252 else if (conf_status == CONF_CLIENT)
1254 if ((!wilds && (!match(aconf->host, host) ||
1255 !match(aconf->name, host))) ||
1256 (wilds && (!mmatch(host, aconf->host) ||
1257 !mmatch(host, aconf->name))))
1259 sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name, /* XXX DEAD */
1260 sptr->name, 'I', aconf->host, aconf->name,
1261 aconf->port, get_conf_class(aconf));
1271 #if !defined(NDEBUG)
1272 sendto_one(sptr, rpl_str(RPL_STATMEMTOT), /* XXX DEAD */
1273 me.name, parv[0], fda_get_byte_count(), fda_get_block_count());
1278 sendto_one(sptr, rpl_str(RPL_STATMEMTOT), /* XXX DEAD */
1279 me.name, parv[0], get_mem_size(), get_alloc_cnt());
1282 report_memleak_stats(sptr, parc, parv);
1284 #if !defined(MEMSIZESTATS) && !defined(MEMLEAKSTATS)
1285 sendto_one(sptr, ":%s NOTICE %s :stats M : Memory allocation monitoring " /* XXX DEAD */
1286 "is not enabled on this server", me.name, parv[0]);
1291 for (mptr = msgtab; mptr->cmd; mptr++)
1293 sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS), /* XXX DEAD */
1294 me.name, parv[0], mptr->cmd, mptr->count, mptr->bytes);
1298 report_configured_links(sptr, CONF_OPS);
1303 * show listener ports
1304 * show hidden ports to opers, if there are more than 3 parameters,
1305 * interpret the fourth parameter as the port number, limit non-local
1306 * or non-oper results to 8 ports.
1308 show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0,
1309 (MyUser(sptr) || IsOper(sptr)) ? 100 : 8);
1314 send_usage(sptr, parv[0]);
1318 report_configured_links(sptr, CONF_CRULEALL);
1321 report_configured_links(sptr, CONF_CRULE);
1324 tstats(sptr, parv[0]);
1327 report_configured_links(sptr, CONF_TLINES);
1330 report_configured_links(sptr, CONF_UWORLD);
1336 nowr = CurrentTime - me.since;
1337 sendto_one(sptr, rpl_str(RPL_STATSUPTIME), me.name, parv[0], /* XXX DEAD */
1338 nowr / 86400, (nowr / 3600) % 24, (nowr / 60) % 60, nowr % 60);
1339 sendto_one(sptr, rpl_str(RPL_STATSCONN), me.name, parv[0], /* XXX DEAD */
1340 max_connection_count, max_client_count);
1350 send_listinfo(sptr, parv[0]);
1355 report_classes(sptr);
1359 count_memory(sptr, parv[0]);
1365 sendto_one(sptr, rpl_str(RPL_ENDOFSTATS), me.name, parv[0], stat); /* XXX DEAD */