ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_stats.c
Revision: 5531
Committed: Wed Feb 11 18:15:09 2015 UTC (9 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 52569 byte(s)
Log Message:
- m_stats.c: explicitely use 'unsigned int' instead of just 'unsigned' when casting
  variables to be used with the %u conversion specifiers

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 5347 * Copyright (c) 1997-2015 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_stats.c
23     * \brief Includes required functions for processing the STATS command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 2820 #include "list.h"
29     #include "client.h"
30     #include "irc_string.h"
31     #include "ircd.h"
32     #include "listener.h"
33 michael 3321 #include "gline.h"
34 michael 1632 #include "conf.h"
35 michael 1644 #include "conf_class.h"
36 adx 30 #include "hostmask.h"
37 michael 2820 #include "numeric.h"
38     #include "send.h"
39     #include "fdlist.h"
40     #include "s_bsd.h"
41 michael 3347 #include "misc.h"
42     #include "server.h"
43     #include "user.h"
44 michael 2820 #include "event.h"
45 adx 30 #include "dbuf.h"
46     #include "parse.h"
47     #include "modules.h"
48 michael 2820 #include "resv.h"
49 adx 30 #include "whowas.h"
50 michael 884 #include "watch.h"
51 michael 3322 #include "res.h"
52 michael 2150 #include "motd.h"
53 michael 4325 #include "ipcache.h"
54 adx 30
55    
56 michael 1922 static const struct shared_flags
57     {
58     const unsigned int type;
59     const unsigned char letter;
60     } flag_table[] = {
61     { SHARED_KLINE, 'K' },
62     { SHARED_UNKLINE, 'U' },
63     { SHARED_XLINE, 'X' },
64     { SHARED_UNXLINE, 'Y' },
65     { SHARED_RESV, 'Q' },
66     { SHARED_UNRESV, 'R' },
67     { SHARED_LOCOPS, 'L' },
68     { SHARED_DLINE, 'D' },
69     { SHARED_UNDLINE, 'E' },
70     { 0, '\0' }
71     };
72    
73 adx 30 /*
74 michael 1922 * inputs - pointer to client requesting confitem report
75     * - ConfType to report
76     * output - none
77     * side effects -
78     */
79     static void
80     report_confitem_types(struct Client *source_p, enum maskitem_type type)
81     {
82 michael 4815 const dlink_node *node = NULL;
83 michael 4032 const struct MaskItem *conf = NULL;
84 michael 2691 char buf[IRCD_BUFSIZE];
85 michael 1922 char *p = NULL;
86    
87     switch (type)
88     {
89 michael 4034 case CONF_XLINE:
90 michael 4815 DLINK_FOREACH(node, xconf_items.head)
91 michael 4034 {
92 michael 4815 conf = node->data;
93 michael 4034 sendto_one_numeric(source_p, &me, RPL_STATSXLINE,
94     conf->until ? 'x': 'X', conf->count,
95     conf->name, conf->reason);
96     }
97 michael 1922
98 michael 4034 break;
99 michael 1922
100 michael 4034 case CONF_ULINE:
101 michael 4815 DLINK_FOREACH(node, uconf_items.head)
102 michael 4034 {
103 michael 4815 conf = node->data;
104 michael 4034 p = buf;
105 michael 1922
106 michael 4034 *p++ = 'c';
107 michael 1922
108 michael 4034 for (const struct shared_flags *shared = flag_table; shared->type; ++shared)
109     if (shared->type & conf->flags)
110     *p++ = shared->letter;
111     else
112     *p++ = ToLower(shared->letter);
113 michael 1922
114 michael 4034 *p = '\0';
115 michael 3285
116 michael 4034 sendto_one_numeric(source_p, &me, RPL_STATSULINE, conf->name,
117     conf->user ? conf->user: "*",
118     conf->host ? conf->host: "*", buf);
119     }
120 michael 1922
121 michael 4815 DLINK_FOREACH(node, cluster_items.head)
122 michael 4034 {
123 michael 4815 conf = node->data;
124 michael 4034 p = buf;
125 michael 1922
126 michael 4034 *p++ = 'C';
127 michael 1922
128 michael 4034 for (const struct shared_flags *shared = flag_table; shared->type; ++shared)
129     if (shared->type & conf->flags)
130     *p++ = shared->letter;
131     else
132     *p++ = ToLower(shared->letter);
133 michael 1922
134 michael 4034 *p = '\0';
135 michael 3285
136 michael 4034 sendto_one_numeric(source_p, &me, RPL_STATSULINE, conf->name, "*", "*", buf);
137     }
138 michael 1922
139 michael 4034 break;
140 michael 1922
141 michael 4034 case CONF_OPER:
142 michael 4815 DLINK_FOREACH(node, oconf_items.head)
143 michael 4034 {
144 michael 4815 conf = node->data;
145 michael 1922
146 michael 4034 /* Don't allow non opers to see oper privs */
147     if (HasUMode(source_p, UMODE_OPER))
148     sendto_one_numeric(source_p, &me, RPL_STATSOLINE, 'O', conf->user, conf->host,
149     conf->name, oper_privs_as_string(conf->port),
150     conf->class->name);
151     else
152     sendto_one_numeric(source_p, &me, RPL_STATSOLINE, 'O', conf->user, conf->host,
153     conf->name, "0", conf->class->name);
154     }
155 michael 1922
156 michael 4034 break;
157 michael 1922
158 michael 4034 case CONF_SERVICE:
159 michael 4815 DLINK_FOREACH(node, service_items.head)
160 michael 4034 {
161 michael 4815 conf = node->data;
162 michael 4034 sendto_one_numeric(source_p, &me, RPL_STATSSERVICE, 'S', "*", conf->name, 0, 0);
163     }
164 michael 1922
165 michael 4034 break;
166 michael 1922
167 michael 4034 case CONF_SERVER:
168 michael 4815 DLINK_FOREACH(node, server_items.head)
169 michael 4034 {
170     p = buf;
171 michael 4815 conf = node->data;
172 michael 1922
173 michael 4034 buf[0] = '\0';
174 michael 1922
175 michael 4034 if (IsConfAllowAutoConn(conf))
176     *p++ = 'A';
177     if (IsConfSSL(conf))
178     *p++ = 'S';
179     if (buf[0] == '\0')
180     *p++ = '*';
181    
182     *p = '\0';
183    
184     /*
185     * Allow admins to see actual ips unless hide_server_ips is enabled
186     */
187     if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
188     sendto_one_numeric(source_p, &me, RPL_STATSCLINE, 'C', conf->host,
189     buf, conf->name, conf->port,
190     conf->class->name);
191 michael 1922 else
192 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSCLINE, 'C',
193 michael 4034 "*@127.0.0.1", buf, conf->name, conf->port,
194     conf->class->name);
195     }
196 michael 1922
197 michael 4034 break;
198    
199     default:
200     break;
201 michael 1922 }
202     }
203    
204 michael 1927 /* report_resv()
205     *
206     * inputs - pointer to client pointer to report to.
207     * output - NONE
208     * side effects - report all resvs to client.
209     */
210     static void
211     report_resv(struct Client *source_p)
212     {
213 michael 4815 const dlink_node *node = NULL;
214 michael 1927
215 michael 4815 DLINK_FOREACH(node, cresv_items.head)
216 michael 1927 {
217 michael 4815 const struct MaskItem *conf = node->data;
218 michael 3109
219     sendto_one_numeric(source_p, &me, RPL_STATSQLINE,
220     conf->until ? 'q' : 'Q', conf->count,
221     conf->name, conf->reason);
222 michael 1927 }
223    
224 michael 4815 DLINK_FOREACH(node, nresv_items.head)
225 michael 1927 {
226 michael 4815 const struct MaskItem *conf = node->data;
227 michael 3109
228     sendto_one_numeric(source_p, &me, RPL_STATSQLINE,
229     conf->until ? 'q' : 'Q', conf->count,
230     conf->name, conf->reason);
231 michael 1927 }
232     }
233    
234 michael 1922 /*
235 adx 30 * This is part of the STATS replies. There is no offical numeric for this
236 michael 4298 * since this isn't an official command, in much the same way as HASH isn't.
237 adx 30 * It is also possible that some systems wont support this call or have
238     * different field names for "struct rusage".
239     * -avalon
240     */
241     static void
242 michael 1457 stats_usage(struct Client *source_p, int parc, char *parv[])
243 adx 30 {
244     struct rusage rus;
245     time_t secs;
246     time_t rup;
247     #ifdef hz
248     # define hzz hz
249     #else
250     # ifdef HZ
251     # define hzz HZ
252     # else
253     int hzz = 1;
254     # endif
255     #endif
256    
257     if (getrusage(RUSAGE_SELF, &rus) == -1)
258     {
259 michael 3110 sendto_one_notice(source_p, &me, ":Getruseage error: %s",
260     strerror(errno));
261 adx 30 return;
262     }
263    
264     secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
265    
266     if (secs == 0)
267     secs = 1;
268    
269 michael 4588 rup = (CurrentTime - me.connection->since) * hzz;
270 adx 30
271     if (rup == 0)
272     rup = 1;
273    
274 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
275     "R :CPU Secs %d:%02d User %d:%02d System %d:%02d",
276     (int)(secs/60), (int)(secs%60),
277     (int)(rus.ru_utime.tv_sec/60), (int)(rus.ru_utime.tv_sec%60),
278     (int)(rus.ru_stime.tv_sec/60), (int)(rus.ru_stime.tv_sec%60));
279     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
280     "R :RSS %ld ShMem %ld Data %ld Stack %ld",
281     rus.ru_maxrss,
282     (rus.ru_ixrss / rup), (rus.ru_idrss / rup),
283     (rus.ru_isrss / rup));
284     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
285     "R :Swaps %d Reclaims %d Faults %d",
286     (int)rus.ru_nswap,
287     (int)rus.ru_minflt, (int)rus.ru_majflt);
288     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
289     "R :Block in %d out %d",
290     (int)rus.ru_inblock,
291     (int)rus.ru_oublock);
292     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
293     "R :Msg Rcv %d Send %d",
294     (int)rus.ru_msgrcv,
295     (int)rus.ru_msgsnd);
296     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
297     "R :Signals %d Context Vol. %d Invol %d",
298     (int)rus.ru_nsignals,
299     (int)rus.ru_nvcsw, (int)rus.ru_nivcsw);
300 adx 30 }
301    
302     static void
303 michael 1457 stats_memory(struct Client *source_p, int parc, char *parv[])
304 adx 30 {
305     const dlink_node *gptr = NULL;
306     const dlink_node *dlink = NULL;
307    
308 michael 948 unsigned int local_client_conf_count = 0; /* local client conf links */
309     unsigned int users_counted = 0; /* user structs */
310 adx 30
311 michael 1017 unsigned int channel_members = 0;
312 michael 948 unsigned int channel_invites = 0;
313     unsigned int channel_bans = 0;
314     unsigned int channel_except = 0;
315     unsigned int channel_invex = 0;
316 adx 30
317 michael 948 unsigned int wwu = 0; /* whowas users */
318     unsigned int class_count = 0; /* classes */
319     unsigned int aways_counted = 0;
320 michael 4329 unsigned int number_ips_stored = 0; /* number of ip addresses hashed */
321 adx 30
322 michael 948 uint64_t channel_memory = 0;
323     uint64_t channel_ban_memory = 0;
324     uint64_t channel_except_memory = 0;
325     uint64_t channel_invex_memory = 0;
326 adx 30
327     unsigned int safelist_count = 0;
328 michael 948 uint64_t safelist_memory = 0;
329 adx 30
330 michael 948 uint64_t wwm = 0; /* whowas array memory used */
331     uint64_t conf_memory = 0; /* memory used by conf lines */
332 michael 4329 uint64_t mem_ips_stored = 0; /* memory used by ip address hash */
333 adx 30
334 michael 948 uint64_t total_channel_memory = 0;
335     uint64_t totww = 0;
336 adx 30
337     unsigned int local_client_count = 0;
338     unsigned int remote_client_count = 0;
339    
340 michael 948 uint64_t local_client_memory_used = 0;
341     uint64_t remote_client_memory_used = 0;
342 adx 30
343 michael 948 uint64_t total_memory = 0;
344 adx 30 unsigned int topic_count = 0;
345    
346 michael 1017 unsigned int watch_list_headers = 0; /* watchlist headers */
347     unsigned int watch_list_entries = 0; /* watchlist entries */
348     uint64_t watch_list_memory = 0; /* watchlist memory used */
349 michael 884
350 adx 30
351     DLINK_FOREACH(gptr, global_client_list.head)
352     {
353 michael 4032 const struct Client *target_p = gptr->data;
354 adx 30
355     if (MyConnect(target_p))
356     {
357     ++local_client_count;
358 michael 4588 local_client_conf_count += dlink_list_length(&target_p->connection->confs);
359     watch_list_entries += dlink_list_length(&target_p->connection->watches);
360 adx 30 }
361     else
362     ++remote_client_count;
363    
364     if (IsClient(target_p))
365     {
366     ++users_counted;
367    
368 michael 1483 if (target_p->away[0])
369 adx 30 ++aways_counted;
370     }
371     }
372    
373     /* Count up all channels, ban lists, except lists, Invex lists */
374 michael 3944 channel_memory = dlink_list_length(&channel_list) *
375 adx 30 sizeof(struct Channel);
376 michael 3944 DLINK_FOREACH(gptr, channel_list.head)
377 adx 30 {
378 michael 948 const struct Ban *actualBan;
379     const struct Channel *chptr = gptr->data;
380 adx 30
381 michael 1017 channel_members += dlink_list_length(&chptr->members);
382 adx 30 channel_invites += dlink_list_length(&chptr->invites);
383    
384 michael 1203 if (chptr->topic[0])
385 adx 30 ++topic_count;
386    
387 michael 1017 channel_bans += dlink_list_length(&chptr->banlist);
388     channel_ban_memory += dlink_list_length(&chptr->banlist) * sizeof(struct Ban);
389    
390     DLINK_FOREACH(dlink, chptr->banlist.head)
391 adx 30 {
392 michael 1017 actualBan = dlink->data;
393     assert(actualBan->who);
394 adx 30
395 michael 1017 channel_ban_memory += actualBan->len + 1;
396     channel_ban_memory += strlen(actualBan->who) + 1;
397 adx 30 }
398    
399 michael 1017 channel_except += dlink_list_length(&chptr->exceptlist);
400     channel_except_memory += dlink_list_length(&chptr->exceptlist) * sizeof(struct Ban);
401    
402     DLINK_FOREACH(dlink, chptr->exceptlist.head)
403 adx 30 {
404 michael 1017 actualBan = dlink->data;
405     assert(actualBan->who);
406 adx 30
407 michael 1017 channel_except_memory += actualBan->len + 1;
408     channel_except_memory += strlen(actualBan->who) + 1;
409 adx 30 }
410    
411 michael 1017 channel_invex += dlink_list_length(&chptr->invexlist);
412     channel_invex_memory += dlink_list_length(&chptr->invexlist) * sizeof(struct Ban);
413    
414     DLINK_FOREACH(dlink, chptr->invexlist.head)
415 adx 30 {
416 michael 1017 actualBan = dlink->data;
417     assert(actualBan->who);
418 adx 30
419 michael 1017 channel_invex_memory += actualBan->len + 1;
420     channel_invex_memory += strlen(actualBan->who) + 1;
421 adx 30 }
422     }
423    
424     if ((safelist_count = dlink_list_length(&listing_client_list)))
425     {
426     safelist_memory = safelist_count * sizeof(struct ListTask);
427     DLINK_FOREACH(gptr, listing_client_list.head)
428     {
429 michael 948 const struct Client *acptr = gptr->data;
430 adx 30
431 michael 4588 DLINK_FOREACH(dlink, acptr->connection->list_task->show_mask.head)
432 adx 30 safelist_memory += strlen(dlink->data);
433    
434 michael 4588 DLINK_FOREACH(dlink, acptr->connection->list_task->hide_mask.head)
435 adx 30 safelist_memory += strlen(dlink->data);
436     }
437     }
438    
439     #if 0
440     /* XXX THIS has to be fixed !!!! -db */
441     /* count up all config items */
442     DLINK_FOREACH(dlink, ConfigItemList.head)
443     {
444     aconf = dlink->data;
445     conf_memory += aconf->host ? strlen(aconf->host)+1 : 0;
446     conf_memory += aconf->passwd ? strlen(aconf->passwd)+1 : 0;
447     conf_memory += aconf->name ? strlen(aconf->name)+1 : 0;
448     conf_memory += sizeof(struct AccessItem);
449     }
450     #endif
451     /* count up all classes */
452 michael 1644 class_count = dlink_list_length(class_get_list());
453 adx 30
454 michael 2297 whowas_count_memory(&wwu, &wwm);
455 michael 1017 watch_count_memory(&watch_list_headers, &watch_list_memory);
456 michael 884
457 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
458     "z :WATCH headers %u(%llu) entries %d(%u)",
459     watch_list_headers,
460     watch_list_memory, watch_list_entries,
461     watch_list_entries * sizeof(dlink_node) * 2);
462 michael 884
463 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
464     "z :Clients %u(%u)",
465     users_counted,
466     (users_counted * sizeof(struct Client)));
467 adx 30
468 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
469     "z :User aways %u", aways_counted);
470 adx 30
471 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
472     "z :Attached confs %u(%llu)",
473     local_client_conf_count,
474     (unsigned long long)(local_client_conf_count * sizeof(dlink_node)));
475 adx 30
476 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
477     "z :Resv channels %u(%lu) nicks %u(%lu)",
478     dlink_list_length(&cresv_items),
479     dlink_list_length(&cresv_items) * sizeof(struct MaskItem),
480     dlink_list_length(&nresv_items),
481     dlink_list_length(&nresv_items) * sizeof(struct MaskItem));
482 adx 30
483 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
484     "z :Classes %u(%llu)",
485     class_count, (unsigned long long)(class_count * sizeof(struct ClassItem)));
486 adx 30
487 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
488     "z :Channels %u(%llu) Topics %u(%u)",
489 michael 3944 dlink_list_length(&channel_list),
490 michael 3573 channel_memory, topic_count, topic_count *
491     (TOPICLEN + 1 + USERHOST_REPLYLEN));
492 adx 30
493 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
494     "z :Bans %u(%llu)",
495     channel_bans, channel_ban_memory);
496 adx 30
497 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
498     "z :Exceptions %u(%llu)",
499     channel_except, channel_except_memory);
500 adx 30
501 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
502     "z :Invex %u(%llu)",
503     channel_invex, channel_invex_memory);
504 adx 30
505 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
506     "z :Channel members %u(%llu) invites %u(%llu)",
507     channel_members,
508     (unsigned long long)(channel_members * sizeof(struct Membership)),
509     channel_invites, (unsigned long long)channel_invites * sizeof(dlink_node) * 2);
510 adx 30
511     total_channel_memory = channel_memory + channel_ban_memory +
512 michael 1017 channel_members * sizeof(struct Membership) +
513 michael 884 (channel_invites * sizeof(dlink_node)*2);
514 adx 30
515 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
516     "z :Safelist %u(%llu)",
517     safelist_count, safelist_memory);
518 adx 30
519 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
520     "z :Whowas users %u(%llu)",
521     wwu, (unsigned long long)(wwu * sizeof(struct Client)));
522 adx 30
523 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
524     "z :Whowas array %u(%llu)",
525     NICKNAMEHISTORYLENGTH, wwm);
526 adx 30
527     totww = wwu * sizeof(struct Client) + wwm;
528    
529 michael 2150 motd_memory_count(source_p);
530 michael 4325 ipcache_get_stats(&number_ips_stored, &mem_ips_stored);
531 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
532     "z :iphash %u(%llu)",
533     number_ips_stored, mem_ips_stored);
534 adx 30
535     total_memory = totww + total_channel_memory + conf_memory + class_count *
536     sizeof(struct ClassItem);
537 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
538     "z :Total: whowas %llu channel %llu conf %llu",
539     totww, total_channel_memory, conf_memory);
540 adx 30
541 michael 4576 local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct Connection));
542 adx 30 total_memory += local_client_memory_used;
543 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
544     "z :Local client Memory in use: %u(%llu)",
545     local_client_count, local_client_memory_used);
546 adx 30
547     remote_client_memory_used = remote_client_count * sizeof(struct Client);
548     total_memory += remote_client_memory_used;
549 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
550     "z :Remote client Memory in use: %u(%llu)",
551     remote_client_count, remote_client_memory_used);
552 adx 30
553 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
554     "z :TOTAL: %llu",
555     me.name, RPL_STATSDEBUG, source_p->name,
556     total_memory);
557 adx 30 }
558    
559     static void
560 michael 4479 stats_dns_servers(struct Client *source_p, int parc, char *parv[])
561 adx 30 {
562     report_dns_servers(source_p);
563     }
564    
565     static void
566 michael 1457 stats_connect(struct Client *source_p, int parc, char *parv[])
567 adx 30 {
568 michael 1632 report_confitem_types(source_p, CONF_SERVER);
569 adx 30 }
570    
571     /* stats_deny()
572     *
573     * input - client to report to
574     * output - none
575     * side effects - client is given dline list.
576     */
577     static void
578 michael 1457 stats_deny(struct Client *source_p, int parc, char *parv[])
579 adx 30 {
580 michael 4032 const struct MaskItem *conf = NULL;
581 michael 4815 const dlink_node *node = NULL;
582 adx 30
583 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
584 adx 30 {
585 michael 4815 DLINK_FOREACH(node, atable[i].head)
586 adx 30 {
587 michael 4815 const struct AddressRec *arec = node->data;
588 michael 1367
589 michael 1632 if (arec->type != CONF_DLINE)
590     continue;
591 adx 30
592 michael 1632 conf = arec->conf;
593 adx 30
594 michael 4034 /* Don't report a tdline as a dline */
595 michael 1649 if (conf->until)
596 michael 1632 continue;
597 adx 30
598 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'D', conf->host, conf->reason);
599 adx 30 }
600     }
601     }
602    
603     /* stats_tdeny()
604     *
605     * input - client to report to
606     * output - none
607     * side effects - client is given dline list.
608     */
609     static void
610 michael 1457 stats_tdeny(struct Client *source_p, int parc, char *parv[])
611 adx 30 {
612 michael 4032 const struct MaskItem *conf = NULL;
613 michael 4815 const dlink_node *node = NULL;
614 adx 30
615 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
616 adx 30 {
617 michael 4815 DLINK_FOREACH(node, atable[i].head)
618 adx 30 {
619 michael 4815 const struct AddressRec *arec = node->data;
620 michael 1367
621 michael 1632 if (arec->type != CONF_DLINE)
622     continue;
623 adx 30
624 michael 1632 conf = arec->conf;
625 adx 30
626 michael 4034 /* Don't report a permanent dline as a tdline */
627 michael 1649 if (!conf->until)
628 michael 1632 continue;
629 adx 30
630 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'd', conf->host, conf->reason);
631 adx 30 }
632     }
633     }
634    
635     /* stats_exempt()
636     *
637     * input - client to report to
638     * output - none
639     * side effects - client is given list of exempt blocks
640     */
641     static void
642 michael 1457 stats_exempt(struct Client *source_p, int parc, char *parv[])
643 adx 30 {
644 michael 4034 const struct MaskItem *conf = NULL;
645 michael 4815 const dlink_node *node = NULL;
646 adx 30
647 michael 4340 if (ConfigGeneral.stats_e_disabled)
648 michael 584 {
649 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
650 michael 584 return;
651     }
652    
653 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
654 adx 30 {
655 michael 4815 DLINK_FOREACH(node, atable[i].head)
656 adx 30 {
657 michael 4815 const struct AddressRec *arec = node->data;
658 michael 1367
659 michael 1632 if (arec->type != CONF_EXEMPT)
660     continue;
661 adx 30
662 michael 1632 conf = arec->conf;
663 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'e', conf->host, "");
664 adx 30 }
665     }
666     }
667    
668     static void
669 michael 1457 stats_events(struct Client *source_p, int parc, char *parv[])
670 adx 30 {
671     show_events(source_p);
672     }
673    
674     /* stats_pending_glines()
675     *
676     * input - client pointer
677     * output - none
678     * side effects - client is shown list of pending glines
679     */
680     static void
681 michael 1457 stats_pending_glines(struct Client *source_p, int parc, char *parv[])
682 adx 30 {
683 michael 4815 const dlink_node *node = NULL;
684 michael 988 const struct gline_pending *glp_ptr = NULL;
685 michael 3246 char timebuffer[MAX_DATE_STRING] = "";
686 michael 958 struct tm *tmptr = NULL;
687 adx 30
688 michael 4340 if (!ConfigGeneral.glines)
689 adx 30 {
690 michael 3110 sendto_one_notice(source_p, &me, ":This server does not support G-Lines");
691 adx 30 return;
692     }
693    
694 michael 3246 if (dlink_list_length(&pending_glines[GLINE_PENDING_ADD_TYPE]))
695 michael 3110 sendto_one_notice(source_p, &me, ":Pending G-lines");
696 adx 30
697 michael 4815 DLINK_FOREACH(node, pending_glines[GLINE_PENDING_ADD_TYPE].head)
698 adx 30 {
699 michael 4815 glp_ptr = node->data;
700 michael 958 tmptr = localtime(&glp_ptr->vote_1.time_request);
701 adx 30 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
702    
703 michael 3110 sendto_one_notice(source_p, &me, ":1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
704     glp_ptr->vote_1.oper_nick,
705     glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
706     glp_ptr->vote_1.oper_server, timebuffer,
707     glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
708 adx 30
709 michael 3246 if (glp_ptr->vote_2.oper_nick[0])
710 adx 30 {
711 michael 958 tmptr = localtime(&glp_ptr->vote_2.time_request);
712 adx 30 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
713 michael 3110
714     sendto_one_notice(source_p, &me, ":2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
715     glp_ptr->vote_2.oper_nick,
716     glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
717     glp_ptr->vote_2.oper_server, timebuffer,
718     glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
719 adx 30 }
720     }
721    
722 michael 3110 sendto_one_notice(source_p, &me, ":End of Pending G-lines");
723 michael 958
724 michael 3246 if (dlink_list_length(&pending_glines[GLINE_PENDING_DEL_TYPE]))
725 michael 3110 sendto_one_notice(source_p, &me, ":Pending UNG-lines");
726 michael 958
727 michael 4815 DLINK_FOREACH(node, pending_glines[GLINE_PENDING_DEL_TYPE].head)
728 michael 958 {
729 michael 4815 glp_ptr = node->data;
730 michael 958 tmptr = localtime(&glp_ptr->vote_1.time_request);
731     strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
732    
733 michael 3110 sendto_one_notice(source_p, &me, ":1) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
734     glp_ptr->vote_1.oper_nick,
735     glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
736     glp_ptr->vote_1.oper_server, timebuffer,
737     glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
738 michael 958
739 michael 3246 if (glp_ptr->vote_2.oper_nick[0])
740 michael 958 {
741     tmptr = localtime(&glp_ptr->vote_2.time_request);
742     strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
743    
744 michael 3110 sendto_one_notice(source_p, &me, ":2) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
745     glp_ptr->vote_2.oper_nick,
746     glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
747     glp_ptr->vote_2.oper_server, timebuffer,
748     glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
749    
750 michael 958 }
751     }
752    
753 michael 3110 sendto_one_notice(source_p, &me, ":End of Pending UNG-lines");
754 adx 30 }
755    
756     /* stats_glines()
757     *
758     * input - client pointer
759     * output - none
760     * side effects - client is shown list of glines
761     */
762     static void
763 michael 1457 stats_glines(struct Client *source_p, int parc, char *parv[])
764 adx 30 {
765 michael 4815 const dlink_node *node = NULL;
766 adx 30
767 michael 4340 if (!ConfigGeneral.glines)
768 adx 30 {
769 michael 3110 sendto_one_notice(source_p, &me, ":This server does not support G-Lines");
770 adx 30 return;
771     }
772    
773 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
774 adx 30 {
775 michael 4815 DLINK_FOREACH(node, atable[i].head)
776 adx 30 {
777 michael 4815 const struct AddressRec *arec = node->data;
778 michael 1367
779 adx 30 if (arec->type == CONF_GLINE)
780     {
781 michael 1632 const struct MaskItem *conf = arec->conf;
782 adx 30
783 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'G',
784     conf->host ? conf->host : "*",
785     conf->user ? conf->user : "*",
786 michael 4666 conf->reason);
787 michael 3109
788 adx 30 }
789     }
790     }
791     }
792    
793     static void
794 michael 1457 stats_hubleaf(struct Client *source_p, int parc, char *parv[])
795 adx 30 {
796 michael 4815 const dlink_node *node = NULL, *dptr = NULL;
797 michael 2118
798 michael 4815 DLINK_FOREACH(node, server_items.head)
799 michael 2118 {
800 michael 4815 const struct MaskItem *conf = node->data;
801 michael 2118
802     DLINK_FOREACH(dptr, conf->hub_list.head)
803 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSHLINE, 'H', dptr->data, conf->name, 0, "*");
804 michael 2118 }
805    
806 michael 4815 DLINK_FOREACH(node, server_items.head)
807 michael 2118 {
808 michael 4815 const struct MaskItem *conf = node->data;
809 michael 2118
810     DLINK_FOREACH(dptr, conf->leaf_list.head)
811 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLLINE, 'L', dptr->data, conf->name, 0, "*");
812 michael 2118 }
813 adx 30 }
814    
815 michael 1372 /*
816     * show_iline_prefix()
817     *
818     * inputs - pointer to struct Client requesting output
819 michael 2820 * - pointer to struct MaskItem
820 michael 1372 * - name to which iline prefix will be prefixed to
821     * output - pointer to static string with prefixes listed in ascii form
822     * side effects - NONE
823     */
824     static const char *
825 michael 1632 show_iline_prefix(const struct Client *sptr, const struct MaskItem *conf)
826 michael 1372 {
827 michael 1715 static char prefix_of_host[USERLEN + 15];
828 michael 1372 char *prefix_ptr = prefix_of_host;
829    
830 michael 1715 if (IsConfWebIRC(conf))
831     *prefix_ptr++ = '<';
832 michael 1632 if (IsNoTilde(conf))
833 michael 1372 *prefix_ptr++ = '-';
834 michael 1632 if (IsNeedIdentd(conf))
835 michael 1372 *prefix_ptr++ = '+';
836 michael 1632 if (!IsNeedPassword(conf))
837 michael 1372 *prefix_ptr++ = '&';
838 michael 1632 if (IsConfExemptResv(conf))
839 michael 1372 *prefix_ptr++ = '$';
840 michael 1632 if (IsConfDoSpoofIp(conf))
841 michael 1372 *prefix_ptr++ = '=';
842 michael 1632 if (MyOper(sptr) && IsConfExemptKline(conf))
843 michael 1372 *prefix_ptr++ = '^';
844 michael 1632 if (MyOper(sptr) && IsConfExemptGline(conf))
845 michael 1372 *prefix_ptr++ = '_';
846 michael 1632 if (MyOper(sptr) && IsConfExemptLimits(conf))
847 michael 1372 *prefix_ptr++ = '>';
848 michael 1632 if (IsConfCanFlood(conf))
849 michael 1372 *prefix_ptr++ = '|';
850    
851 michael 1632 strlcpy(prefix_ptr, conf->user, USERLEN+1);
852 michael 1372
853     return prefix_of_host;
854     }
855    
856 adx 30 static void
857 michael 3156 report_auth(struct Client *source_p, int parc, char *parv[])
858 michael 1372 {
859 michael 4032 const struct MaskItem *conf = NULL;
860 michael 4815 const dlink_node *node = NULL;
861 michael 1372
862 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
863 michael 1372 {
864 michael 4815 DLINK_FOREACH(node, atable[i].head)
865 michael 1372 {
866 michael 4815 const struct AddressRec *arec = node->data;
867 michael 1372
868 michael 1632 if (arec->type != CONF_CLIENT)
869     continue;
870 michael 1372
871 michael 1632 conf = arec->conf;
872 michael 1372
873 michael 3156 if (!MyOper(source_p) && IsConfDoSpoofIp(conf))
874 michael 1632 continue;
875 michael 1372
876 michael 1632 /* We are doing a partial list, based on what matches the u@h of the
877     * sender, so prepare the strings for comparing --fl_
878     */
879 michael 4967 sendto_one_numeric(source_p, &me, RPL_STATSILINE, 'I',
880     conf->name == NULL ? "*" : conf->name,
881     show_iline_prefix(source_p, conf),
882     conf->host, conf->port,
883     conf->class->name);
884 michael 1372 }
885     }
886     }
887    
888     static void
889 michael 1457 stats_auth(struct Client *source_p, int parc, char *parv[])
890 adx 30 {
891     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
892 michael 4340 if (ConfigGeneral.stats_i_oper_only == 2 && !HasUMode(source_p, UMODE_OPER))
893 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
894 adx 30
895 michael 4034 /* If unopered, only return matching auth blocks */
896 michael 4340 else if (ConfigGeneral.stats_i_oper_only == 1 && !HasUMode(source_p, UMODE_OPER))
897 adx 30 {
898 michael 4034 const struct MaskItem *conf = NULL;
899 adx 30
900     if (MyConnect(source_p))
901 michael 1632 conf = find_conf_by_address(source_p->host,
902 michael 4588 &source_p->connection->ip, CONF_CLIENT,
903     source_p->connection->aftype,
904 michael 2820 source_p->username,
905 michael 4588 source_p->connection->password, 1);
906 adx 30 else
907 michael 4034 conf = find_conf_by_address(source_p->host, NULL, CONF_CLIENT, 0,
908     source_p->username, NULL, 1);
909 adx 30
910 michael 1632 if (conf == NULL)
911 adx 30 return;
912    
913 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSILINE,
914     'I', "*", show_iline_prefix(source_p, conf),
915     conf->host, conf->port,
916 michael 4037 conf->class->name);
917 adx 30 }
918 michael 4034 else /* They are opered, or allowed to see all auth blocks */
919 michael 1457 report_auth(source_p, 0, NULL);
920 adx 30 }
921    
922 michael 1372 /* report_Klines()
923     * Inputs: Client to report to,
924     * type(==0 for perm, !=0 for temporary)
925 michael 2820 * mask
926 michael 1372 * Output: None
927 michael 3156 * Side effects: Reports configured K(or k)-lines to source_p.
928 michael 1372 */
929 adx 30 static void
930 michael 3156 report_Klines(struct Client *source_p, int tkline)
931 michael 1372 {
932 michael 4032 const struct MaskItem *conf = NULL;
933 michael 4815 const dlink_node *node = NULL;
934 michael 1921 char c = '\0';
935 michael 1372
936     if (tkline)
937 michael 1921 c = 'k';
938 michael 1372 else
939 michael 1921 c = 'K';
940 michael 1372
941 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
942 michael 1372 {
943 michael 4815 DLINK_FOREACH(node, atable[i].head)
944 michael 1372 {
945 michael 4815 const struct AddressRec *arec = node->data;
946 michael 1372
947 michael 1632 if (arec->type != CONF_KLINE)
948     continue;
949 michael 1628
950 michael 1632 conf = arec->conf;
951 michael 1372
952 michael 1650 if ((!tkline && conf->until) ||
953     (tkline && !conf->until))
954 michael 1632 continue;
955    
956 michael 4570 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, c, conf->host, conf->user,
957     conf->reason);
958 michael 1372 }
959     }
960     }
961    
962     static void
963 michael 1457 stats_tklines(struct Client *source_p, int parc, char *parv[])
964 adx 30 {
965     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
966 michael 4340 if (ConfigGeneral.stats_k_oper_only == 2 && !HasUMode(source_p, UMODE_OPER))
967 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
968 adx 30
969 michael 4034 /* If unopered, only return matching klines */
970 michael 4340 else if (ConfigGeneral.stats_k_oper_only == 1 && !HasUMode(source_p, UMODE_OPER))
971 adx 30 {
972 michael 4032 const struct MaskItem *conf = NULL;
973 adx 30
974     if (MyConnect(source_p))
975 michael 1632 conf = find_conf_by_address(source_p->host,
976 michael 4588 &source_p->connection->ip, CONF_KLINE,
977     source_p->connection->aftype,
978 michael 2820 source_p->username, NULL, 1);
979 adx 30 else
980 michael 4034 conf = find_conf_by_address(source_p->host, NULL, CONF_KLINE, 0,
981     source_p->username, NULL, 1);
982 adx 30
983 michael 1632 if (!conf)
984 adx 30 return;
985    
986 michael 4034 /* Don't report a permanent kline as a tkline */
987 michael 1649 if (!conf->until)
988 adx 30 return;
989    
990 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'k',
991     conf->host, conf->user, conf->reason);
992 adx 30 }
993 michael 4034 else /* They are opered, or allowed to see all klines */
994 adx 30 report_Klines(source_p, 1);
995     }
996    
997     static void
998 michael 1457 stats_klines(struct Client *source_p, int parc, char *parv[])
999 adx 30 {
1000     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
1001 michael 4340 if (ConfigGeneral.stats_k_oper_only == 2 && !HasUMode(source_p, UMODE_OPER))
1002 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1003 adx 30
1004 michael 4034 /* If unopered, only return matching klines */
1005 michael 4340 else if (ConfigGeneral.stats_k_oper_only == 1 && !HasUMode(source_p, UMODE_OPER))
1006 adx 30 {
1007 michael 4032 const struct MaskItem *conf = NULL;
1008 adx 30
1009 michael 4034 /* Search for a kline */
1010 michael 560 if (MyConnect(source_p))
1011 michael 1632 conf = find_conf_by_address(source_p->host,
1012 michael 4588 &source_p->connection->ip, CONF_KLINE,
1013     source_p->connection->aftype,
1014 michael 2820 source_p->username, NULL, 0);
1015 adx 30 else
1016 michael 4034 conf = find_conf_by_address(source_p->host, NULL, CONF_KLINE, 0,
1017     source_p->username, NULL, 0);
1018 adx 30
1019 michael 1632 if (!conf)
1020 adx 30 return;
1021    
1022 michael 4034 /* Don't report a tkline as a kline */
1023 michael 1649 if (conf->until)
1024 adx 30 return;
1025 michael 2820
1026 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'K',
1027     conf->host, conf->user, conf->reason);
1028 adx 30 }
1029 michael 4034 else /* They are opered, or allowed to see all klines */
1030 adx 30 report_Klines(source_p, 0);
1031     }
1032    
1033     static void
1034 michael 1457 stats_messages(struct Client *source_p, int parc, char *parv[])
1035 adx 30 {
1036 michael 5026 if (!HasUMode(source_p, UMODE_OPER) && ConfigGeneral.stats_m_oper_only)
1037     sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1038     else
1039     report_messages(source_p);
1040 adx 30 }
1041    
1042     static void
1043 michael 1457 stats_oper(struct Client *source_p, int parc, char *parv[])
1044 adx 30 {
1045 michael 4340 if (!HasUMode(source_p, UMODE_OPER) && ConfigGeneral.stats_o_oper_only)
1046 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1047 adx 30 else
1048 michael 1632 report_confitem_types(source_p, CONF_OPER);
1049 adx 30 }
1050    
1051     /* stats_operedup()
1052     *
1053     * input - client pointer
1054     * output - none
1055     * side effects - client is shown a list of active opers
1056     */
1057     static void
1058 michael 1457 stats_operedup(struct Client *source_p, int parc, char *parv[])
1059 adx 30 {
1060 michael 4815 const dlink_node *node = NULL;
1061 michael 3511 unsigned int opercount = 0;
1062 michael 3516 char buf[IRCD_BUFSIZE] = "";
1063 adx 30
1064 michael 4815 DLINK_FOREACH(node, oper_list.head)
1065 adx 30 {
1066 michael 4815 const struct Client *target_p = node->data;
1067 adx 30
1068 michael 1294 if (HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER))
1069 adx 30 continue;
1070    
1071 michael 3516 if (HasUMode(source_p, UMODE_OPER) || !HasUMode(target_p, UMODE_HIDEIDLE))
1072     snprintf(buf, sizeof(buf), "%u", idle_time_get(source_p, target_p));
1073     else
1074     strlcpy(buf, "n/a", sizeof(buf));
1075    
1076 michael 1219 if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER))
1077 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1078     "p :[%c][%s] %s (%s@%s) Idle: %s",
1079     HasUMode(target_p, UMODE_ADMIN) ? 'A' : 'O',
1080 michael 4588 oper_privs_as_string(target_p->connection->operflags),
1081 michael 3573 target_p->name, target_p->username, target_p->host, buf);
1082 adx 30 else
1083 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1084     "p :[%c] %s (%s@%s) Idle: %s",
1085     HasUMode(target_p, UMODE_ADMIN) ? 'A' : 'O',
1086     target_p->name, target_p->username, target_p->host, buf);
1087 michael 3511 ++opercount;
1088 adx 30 }
1089    
1090 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1091     "p :%u OPER(s)", opercount);
1092 adx 30 }
1093    
1094     static void
1095 michael 1457 stats_ports(struct Client *source_p, int parc, char *parv[])
1096 adx 30 {
1097 michael 4340 if (!HasUMode(source_p, UMODE_OPER) && ConfigGeneral.stats_P_oper_only)
1098 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1099 adx 30 else
1100     show_ports(source_p);
1101     }
1102    
1103     static void
1104 michael 1457 stats_resv(struct Client *source_p, int parc, char *parv[])
1105 adx 30 {
1106     report_resv(source_p);
1107     }
1108    
1109     static void
1110 michael 1457 stats_service(struct Client *source_p, int parc, char *parv[])
1111 adx 30 {
1112 michael 1632 report_confitem_types(source_p, CONF_SERVICE);
1113 michael 1175 }
1114    
1115     static void
1116 michael 1457 stats_tstats(struct Client *source_p, int parc, char *parv[])
1117 adx 30 {
1118 michael 4815 const dlink_node *node = NULL;
1119 michael 896 struct ServerStatistics tmp;
1120 michael 1842 struct ServerStatistics *sp = &tmp;
1121 michael 896
1122     memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
1123    
1124     /*
1125     * must use the += operator. is_sv is not the number of currently
1126     * active server connections. Note the incrementation in
1127     * s_bsd.c:close_connection.
1128     */
1129 michael 4213 sp->is_sv += dlink_list_length(&local_server_list);
1130 michael 896
1131 michael 4815 DLINK_FOREACH(node, local_server_list.head)
1132 michael 896 {
1133 michael 4815 const struct Client *target_p = node->data;
1134 michael 896
1135 michael 4588 sp->is_sbs += target_p->connection->send.bytes;
1136     sp->is_sbr += target_p->connection->recv.bytes;
1137     sp->is_sti += CurrentTime - target_p->connection->firsttime;
1138 michael 896 }
1139    
1140     sp->is_cl += dlink_list_length(&local_client_list);
1141    
1142 michael 4815 DLINK_FOREACH(node, local_client_list.head)
1143 michael 896 {
1144 michael 4815 const struct Client *target_p = node->data;
1145 michael 896
1146 michael 4588 sp->is_cbs += target_p->connection->send.bytes;
1147     sp->is_cbr += target_p->connection->recv.bytes;
1148     sp->is_cti += CurrentTime - target_p->connection->firsttime;
1149 michael 896 }
1150    
1151     sp->is_ni += dlink_list_length(&unknown_list);
1152    
1153 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1154 michael 4040 "t :accepts %u refused %u",
1155 michael 3573 sp->is_ac, sp->is_ref);
1156     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1157 michael 4040 "t :unknown commands %u prefixes %u",
1158 michael 3573 sp->is_unco, sp->is_unpf);
1159     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1160 michael 4040 "t :nick collisions %u unknown closes %u",
1161 michael 3573 sp->is_kill, sp->is_ni);
1162     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1163 michael 4040 "t :wrong direction %u empty %u",
1164 michael 3573 sp->is_wrdi, sp->is_empt);
1165     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1166 michael 4040 "t :numerics seen %u",
1167 michael 3573 sp->is_num);
1168     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1169 michael 4040 "t :auth successes %u fails %u",
1170 michael 3573 sp->is_asuc, sp->is_abad);
1171     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1172 michael 4040 "t :Client Server");
1173 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1174 michael 4040 "t :connected %u %u",
1175 michael 3573 (unsigned int)sp->is_cl,
1176     (unsigned int)sp->is_sv);
1177     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1178 michael 4040 "t :bytes sent %llu %llu",
1179 michael 3573 sp->is_cbs, sp->is_sbs);
1180     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1181 michael 4040 "t :bytes recv %llu %llu",
1182 michael 3573 sp->is_cbr, sp->is_sbr);
1183     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1184 michael 4040 "t :time connected %u %u",
1185 michael 3573 (unsigned int)sp->is_cti,
1186     (unsigned int)sp->is_sti);
1187 adx 30 }
1188    
1189     static void
1190 michael 1457 stats_uptime(struct Client *source_p, int parc, char *parv[])
1191 adx 30 {
1192 michael 4340 if (!HasUMode(source_p, UMODE_OPER) && ConfigGeneral.stats_u_oper_only)
1193 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1194 michael 2269 else
1195     {
1196 michael 4588 time_t now = CurrentTime - me.connection->since;
1197 michael 1148
1198 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSUPTIME, now / 86400,
1199     (now / 3600) % 24, (now / 60) % 60, now % 60);
1200 michael 1148
1201 michael 2269 if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER))
1202 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con,
1203     Count.max_loc_cli, Count.totalrestartcount);
1204 michael 2269 }
1205 adx 30 }
1206    
1207     static void
1208 michael 1457 stats_shared(struct Client *source_p, int parc, char *parv[])
1209 adx 30 {
1210 michael 1632 report_confitem_types(source_p, CONF_ULINE);
1211 adx 30 }
1212    
1213     /* stats_servers()
1214     *
1215     * input - client pointer
1216     * output - none
1217     * side effects - client is shown lists of who connected servers
1218     */
1219     static void
1220 michael 1457 stats_servers(struct Client *source_p, int parc, char *parv[])
1221 adx 30 {
1222 michael 4815 const dlink_node *node = NULL;
1223 adx 30
1224 michael 4815 DLINK_FOREACH(node, local_server_list.head)
1225 adx 30 {
1226 michael 4815 const struct Client *target_p = node->data;
1227 adx 30
1228 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1229     "v :%s (%s!%s@%s) Idle: %d",
1230     target_p->name,
1231     (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1232 michael 4588 "*", "*", (int)(CurrentTime - target_p->connection->lasttime));
1233 adx 30 }
1234    
1235 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1236 michael 4213 "v :%u Server(s)",
1237     dlink_list_length(&local_server_list));
1238 adx 30 }
1239    
1240     static void
1241 michael 1457 stats_gecos(struct Client *source_p, int parc, char *parv[])
1242 adx 30 {
1243 michael 1632 report_confitem_types(source_p, CONF_XLINE);
1244 adx 30 }
1245    
1246     static void
1247 michael 1457 stats_class(struct Client *source_p, int parc, char *parv[])
1248 adx 30 {
1249 michael 4815 const dlink_node *node = NULL;
1250 michael 2116
1251 michael 4815 DLINK_FOREACH(node, class_get_list()->head)
1252 michael 2116 {
1253 michael 4815 const struct ClassItem *class = node->data;
1254 michael 2116
1255 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSYLINE, 'Y',
1256     class->name, class->ping_freq,
1257     class->con_freq,
1258     class->max_total, class->max_sendq,
1259     class->max_recvq,
1260     class->ref_count,
1261     class->number_per_cidr, class->cidr_bitlen_ipv4,
1262     class->number_per_cidr, class->cidr_bitlen_ipv6,
1263     class->active ? "active" : "disabled");
1264 michael 2116 }
1265 adx 30 }
1266    
1267     static void
1268 michael 1457 stats_servlinks(struct Client *source_p, int parc, char *parv[])
1269 adx 30 {
1270     uint64_t sendB = 0, recvB = 0;
1271     time_t uptime = 0;
1272 michael 4815 dlink_node *node = NULL;
1273 adx 30
1274 michael 1219 if (ConfigServerHide.flatten_links && !HasUMode(source_p, UMODE_OPER))
1275 adx 30 {
1276 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1277 adx 30 return;
1278     }
1279    
1280 michael 4815 DLINK_FOREACH(node, local_server_list.head)
1281 adx 30 {
1282 michael 4815 struct Client *target_p = node->data;
1283 adx 30
1284 michael 1851 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
1285     if (!HasUMode(source_p, UMODE_OPER))
1286     continue;
1287    
1288 michael 4588 sendB += target_p->connection->send.bytes;
1289     recvB += target_p->connection->recv.bytes;
1290 adx 30
1291     /* ":%s 211 %s %s %u %u %llu %u %llu :%u %u %s" */
1292 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1293 michael 1219 get_client_name(target_p, HasUMode(source_p, UMODE_ADMIN) ? SHOW_IP : MASK_IP),
1294 michael 4588 dbuf_length(&target_p->connection->buf_sendq),
1295     target_p->connection->send.messages,
1296     target_p->connection->send.bytes >> 10,
1297     target_p->connection->recv.messages,
1298     target_p->connection->recv.bytes >> 10,
1299 michael 5531 (unsigned int)(CurrentTime - target_p->connection->firsttime),
1300     (CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since) : 0,
1301 michael 1219 HasUMode(source_p, UMODE_OPER) ? show_capabilities(target_p) : "TS");
1302 adx 30 }
1303    
1304     sendB >>= 10;
1305     recvB >>= 10;
1306    
1307 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT, "? :%u total server(s)",
1308 michael 4213 dlink_list_length(&local_server_list));
1309 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT, "? :Sent total: %7.2f %s",
1310     _GMKv(sendB), _GMKs(sendB));
1311     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT, "? :Recv total: %7.2f %s",
1312     _GMKv(recvB), _GMKs(recvB));
1313 adx 30
1314 michael 4588 uptime = (CurrentTime - me.connection->since);
1315 adx 30
1316 michael 3573 sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1317     "? :Server send: %7.2f %s (%4.1f K/s)",
1318 michael 4588 _GMKv((me.connection->send.bytes>>10)),
1319     _GMKs((me.connection->send.bytes>>10)),
1320     (float)((float)((me.connection->send.bytes) >> 10) /
1321 michael 3573 (float)uptime));
1322     sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
1323     "? :Server recv: %7.2f %s (%4.1f K/s)",
1324 michael 4588 _GMKv((me.connection->recv.bytes>>10)),
1325     _GMKs((me.connection->recv.bytes>>10)),
1326     (float)((float)((me.connection->recv.bytes) >> 10) /
1327 michael 3573 (float)uptime));
1328 adx 30 }
1329    
1330 michael 1457 /* parse_stats_args()
1331     *
1332     * inputs - arg count
1333     * - args
1334     * - doall flag
1335     * - wild card or not
1336     * output - pointer to name to use
1337     * side effects -
1338     * common parse routine for m_stats args
1339 michael 2820 *
1340 michael 1457 */
1341 michael 4755 static const char *
1342 michael 3114 parse_stats_args(struct Client *source_p, int parc, char *parv[], int *doall, int *wilds)
1343 adx 30 {
1344 michael 1457 if (parc > 2)
1345 adx 30 {
1346 michael 4755 const char *name = parv[2];
1347 adx 30
1348 michael 3114 if (!irccmp(name, ID_or_name(&me, source_p)))
1349 michael 1457 *doall = 2;
1350 michael 3114 else if (!match(name, ID_or_name(&me, source_p)))
1351 michael 1457 *doall = 1;
1352    
1353     *wilds = has_wildcards(name);
1354    
1355     return name;
1356 adx 30 }
1357    
1358 michael 1457 return NULL;
1359 adx 30 }
1360    
1361     static void
1362 michael 4755 stats_L_list(struct Client *source_p, const char *name, int doall, int wilds,
1363     dlink_list *list, const char statchar)
1364 adx 30 {
1365 michael 4815 dlink_node *node = NULL;
1366 adx 30
1367     /*
1368 michael 4034 * Send info about connections which match, or all if the
1369     * mask matches from. Only restrictions are on those who
1370 adx 30 * are invisible not being visible to 'foreigners' who use
1371     * a wild card based search to list it.
1372     */
1373 michael 4815 DLINK_FOREACH(node, list->head)
1374 adx 30 {
1375 michael 4815 struct Client *target_p = node->data;
1376 adx 30
1377 michael 1219 if (HasUMode(target_p, UMODE_INVISIBLE) && (doall || wilds) &&
1378 michael 1457 !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) &&
1379     !HasUMode(target_p, UMODE_OPER) && (target_p != source_p))
1380 adx 30 continue;
1381 michael 4034
1382 michael 1652 if (!doall && wilds && match(name, target_p->name))
1383 adx 30 continue;
1384 michael 4034
1385 adx 30 if (!(doall || wilds) && irccmp(name, target_p->name))
1386     continue;
1387    
1388 michael 4034 /*
1389     * This basically shows ips for our opers if it's not a server/admin, or
1390 michael 4298 * it's one of our admins.
1391 michael 4034 */
1392 michael 3655 if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER) &&
1393     (HasUMode(source_p, UMODE_ADMIN) ||
1394     (!IsServer(target_p) && !HasUMode(target_p, UMODE_ADMIN) &&
1395     !IsHandshake(target_p) && !IsConnecting(target_p))))
1396 adx 30 {
1397 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1398 adx 30 (IsUpper(statchar)) ?
1399     get_client_name(target_p, SHOW_IP) :
1400     get_client_name(target_p, HIDE_IP),
1401 michael 4588 dbuf_length(&target_p->connection->buf_sendq),
1402     target_p->connection->send.messages,
1403     target_p->connection->send.bytes>>10,
1404     target_p->connection->recv.messages,
1405     target_p->connection->recv.bytes>>10,
1406 michael 5531 (unsigned int)(CurrentTime - target_p->connection->firsttime),
1407     (CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since) : 0,
1408 adx 30 IsServer(target_p) ? show_capabilities(target_p) : "-");
1409     }
1410     else
1411     {
1412 michael 4967 /* If it's a server, mask the real IP */
1413     if (IsServer(target_p) || IsHandshake(target_p) || IsConnecting(target_p))
1414 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1415 michael 1457 get_client_name(target_p, MASK_IP),
1416 michael 4588 dbuf_length(&target_p->connection->buf_sendq),
1417     target_p->connection->send.messages,
1418     target_p->connection->send.bytes>>10,
1419     target_p->connection->recv.messages,
1420     target_p->connection->recv.bytes>>10,
1421 michael 5531 (unsigned int)(CurrentTime - target_p->connection->firsttime),
1422     (CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since):0,
1423 michael 1457 IsServer(target_p) ? show_capabilities(target_p) : "-");
1424 adx 30 else /* show the real IP */
1425 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1426 michael 1457 (IsUpper(statchar)) ?
1427     get_client_name(target_p, SHOW_IP) :
1428     get_client_name(target_p, HIDE_IP),
1429 michael 4588 dbuf_length(&target_p->connection->buf_sendq),
1430     target_p->connection->send.messages,
1431     target_p->connection->send.bytes>>10,
1432     target_p->connection->recv.messages,
1433     target_p->connection->recv.bytes>>10,
1434 michael 5531 (unsigned int)(CurrentTime - target_p->connection->firsttime),
1435     (CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since):0,
1436 michael 1457 IsServer(target_p) ? show_capabilities(target_p) : "-");
1437 adx 30 }
1438     }
1439     }
1440    
1441 michael 1457 /*
1442     * stats_L
1443 adx 30 *
1444 michael 1457 * inputs - pointer to client to report to
1445     * - doall flag
1446     * - wild card or not
1447     * output - NONE
1448     * side effects -
1449     */
1450     static void
1451 michael 4755 stats_L(struct Client *source_p, const char *name, int doall,
1452     int wilds, const char statchar)
1453 michael 1457 {
1454     stats_L_list(source_p, name, doall, wilds, &unknown_list, statchar);
1455     stats_L_list(source_p, name, doall, wilds, &local_client_list, statchar);
1456 michael 4213 stats_L_list(source_p, name, doall, wilds, &local_server_list, statchar);
1457 michael 1457 }
1458    
1459     static void
1460     stats_ltrace(struct Client *source_p, int parc, char *parv[])
1461     {
1462     int doall = 0;
1463     int wilds = 0;
1464 michael 4755 const char *name = NULL;
1465 michael 1457
1466 michael 3246 if ((name = parse_stats_args(source_p, parc, parv, &doall, &wilds)))
1467 michael 1457 {
1468 michael 4755 const char statchar = *parv[1];
1469 michael 1457 stats_L(source_p, name, doall, wilds, statchar);
1470     }
1471     else
1472 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "STATS");
1473 michael 1457 }
1474    
1475     static const struct StatsStruct
1476     {
1477     const unsigned char letter;
1478 michael 4479 void (*handler)(struct Client *, int, char *[]);
1479 michael 1457 const unsigned int need_oper;
1480     const unsigned int need_admin;
1481     } stats_cmd_table[] = {
1482 michael 4034 /* letter function need_oper need_admin */
1483     { 'a', stats_dns_servers, 1, 1 },
1484     { 'A', stats_dns_servers, 1, 1 },
1485     { 'c', stats_connect, 1, 0 },
1486     { 'C', stats_connect, 1, 0 },
1487     { 'd', stats_tdeny, 1, 0 },
1488     { 'D', stats_deny, 1, 0 },
1489     { 'e', stats_exempt, 1, 0 },
1490     { 'E', stats_events, 1, 1 },
1491     { 'f', fd_dump, 1, 1 },
1492     { 'F', fd_dump, 1, 1 },
1493     { 'g', stats_pending_glines, 1, 0 },
1494     { 'G', stats_glines, 1, 0 },
1495 michael 4142 { 'h', stats_hubleaf, 1, 1 },
1496 michael 4034 { 'H', stats_hubleaf, 1, 0 },
1497     { 'i', stats_auth, 0, 0 },
1498     { 'I', stats_auth, 0, 0 },
1499     { 'k', stats_tklines, 0, 0 },
1500     { 'K', stats_klines, 0, 0 },
1501     { 'l', stats_ltrace, 1, 0 },
1502     { 'L', stats_ltrace, 1, 0 },
1503     { 'm', stats_messages, 0, 0 },
1504     { 'M', stats_messages, 0, 0 },
1505     { 'o', stats_oper, 0, 0 },
1506     { 'O', stats_oper, 0, 0 },
1507     { 'p', stats_operedup, 0, 0 },
1508     { 'P', stats_ports, 0, 0 },
1509     { 'q', stats_resv, 1, 0 },
1510     { 'Q', stats_resv, 1, 0 },
1511     { 'r', stats_usage, 1, 0 },
1512     { 'R', stats_usage, 1, 0 },
1513     { 's', stats_service, 1, 0 },
1514     { 'S', stats_service, 1, 0 },
1515     { 't', stats_tstats, 1, 0 },
1516     { 'T', motd_report, 1, 0 },
1517     { 'u', stats_uptime, 0, 0 },
1518     { 'U', stats_shared, 1, 0 },
1519     { 'v', stats_servers, 1, 0 },
1520     { 'x', stats_gecos, 1, 0 },
1521     { 'X', stats_gecos, 1, 0 },
1522     { 'y', stats_class, 1, 0 },
1523     { 'Y', stats_class, 1, 0 },
1524     { 'z', stats_memory, 1, 0 },
1525     { '?', stats_servlinks, 0, 0 },
1526     { '\0', NULL, 0, 0 }
1527 michael 1457 };
1528    
1529     static void
1530     do_stats(struct Client *source_p, int parc, char *parv[])
1531     {
1532     const char statchar = *parv[1];
1533    
1534     if (statchar == '\0')
1535     {
1536 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFSTATS, '*');
1537 michael 1457 return;
1538     }
1539    
1540 michael 3283 for (const struct StatsStruct *tab = stats_cmd_table; tab->handler; ++tab)
1541 michael 1457 {
1542     if (tab->letter == statchar)
1543     {
1544     /* The stats table says what privs are needed, so check --fl_ */
1545     if ((tab->need_admin && !HasUMode(source_p, UMODE_ADMIN)) ||
1546     (tab->need_oper && !HasUMode(source_p, UMODE_OPER)))
1547     {
1548 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1549 michael 1457 break;
1550     }
1551    
1552 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
1553 michael 1532 "STATS %c requested by %s (%s@%s) [%s]",
1554 michael 1457 statchar, source_p->name, source_p->username,
1555     source_p->host, source_p->servptr->name);
1556     tab->handler(source_p, parc, parv);
1557     break;
1558     }
1559     }
1560    
1561 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFSTATS, statchar);
1562 michael 1457 }
1563    
1564     /*
1565     * m_stats()
1566 michael 3096 * parv[0] = command
1567 michael 1457 * parv[1] = stat letter/command
1568     * parv[2] = (if present) server/mask in stats L
1569 adx 30 */
1570 michael 2820 static int
1571 michael 3156 m_stats(struct Client *source_p, int parc, char *parv[])
1572 adx 30 {
1573 michael 1457 static time_t last_used = 0;
1574 adx 30
1575 michael 4298 /* Check the user is actually allowed to do /stats, and isn't flooding */
1576 michael 4340 if ((last_used + ConfigGeneral.pace_wait) > CurrentTime)
1577 michael 1457 {
1578 michael 4759 sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "STATS");
1579 michael 2820 return 0;
1580 michael 1457 }
1581 adx 30
1582 michael 1457 last_used = CurrentTime;
1583 adx 30
1584 michael 2341 /* Is the stats meant for us? */
1585     if (!ConfigServerHide.disable_remote_commands)
1586 michael 4034 if (hunt_server(source_p, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME)
1587 michael 2820 return 0;
1588 michael 2341
1589 michael 1457 do_stats(source_p, parc, parv);
1590 michael 2820 return 0;
1591 michael 1457 }
1592    
1593     /*
1594 michael 3219 * ms_stats()
1595 michael 3096 * parv[0] = command
1596 michael 1457 * parv[1] = stat letter/command
1597     * parv[2] = (if present) server/mask in stats L, or target
1598     */
1599 michael 2820 static int
1600 michael 3219 ms_stats(struct Client *source_p, int parc, char *parv[])
1601 michael 1457 {
1602 michael 4034 if (hunt_server(source_p, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME)
1603 michael 2820 return 0;
1604 michael 1457
1605     do_stats(source_p, parc, parv);
1606 michael 2820 return 0;
1607 adx 30 }
1608 michael 1230
1609 michael 2820 static struct Message stats_msgtab =
1610     {
1611 michael 4545 "STATS", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
1612 michael 3219 { m_unregistered, m_stats, ms_stats, m_ignore, ms_stats, m_ignore }
1613 michael 1230 };
1614    
1615     static void
1616     module_init(void)
1617     {
1618     mod_add_cmd(&stats_msgtab);
1619     }
1620    
1621     static void
1622     module_exit(void)
1623     {
1624     mod_del_cmd(&stats_msgtab);
1625     }
1626    
1627 michael 2820 struct module module_entry =
1628     {
1629 michael 1230 .node = { NULL, NULL, NULL },
1630     .name = NULL,
1631     .version = "$Revision$",
1632     .handle = NULL,
1633     .modinit = module_init,
1634     .modexit = module_exit,
1635     .flags = 0
1636     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision