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