ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_stats.c
Revision: 2297
Committed: Wed Jun 19 11:57:38 2013 UTC (10 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 54443 byte(s)
Log Message:
- whowas.c: renamed count_whowas_memory() to whowas_count_memory()
- watch_count_memory(), whowas_count_memory(): constification, renamed
  variables, removed unused variables

File Contents

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

Properties

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