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