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