| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
< |
#include "tools.h" /* dlink_node/dlink_list */ |
| 26 |
> |
#include "list.h" /* dlink_node/dlink_list */ |
| 27 |
> |
#include "balloc.h" |
| 28 |
|
#include "handlers.h" /* m_pass prototype */ |
| 29 |
|
#include "client.h" /* Client */ |
| 30 |
|
#include "common.h" /* TRUE/FALSE */ |
| 42 |
|
#include "s_conf.h" /* AccessItem, report_configured_links */ |
| 43 |
|
#include "s_misc.h" /* serv_info */ |
| 44 |
|
#include "s_serv.h" /* hunt_server */ |
| 44 |
– |
#include "s_stats.h" /* tstats */ |
| 45 |
|
#include "s_user.h" /* show_opers */ |
| 46 |
|
#include "event.h" /* events */ |
| 47 |
|
#include "dbuf.h" |
| 48 |
+ |
#include "hook.h" |
| 49 |
|
#include "parse.h" |
| 50 |
|
#include "modules.h" |
| 50 |
– |
#include "hook.h" |
| 51 |
|
#include "resv.h" /* report_resv */ |
| 52 |
|
#include "whowas.h" |
| 53 |
< |
#include "list.h" |
| 53 |
> |
#include "watch.h" |
| 54 |
|
|
| 55 |
< |
static void do_stats(struct Client *, int, char **); |
| 55 |
> |
static void do_stats(struct Client *, int, char *[]); |
| 56 |
|
static void m_stats(struct Client *, struct Client *, int, char *[]); |
| 57 |
|
static void mo_stats(struct Client *, struct Client *, int, char *[]); |
| 58 |
|
static void ms_stats(struct Client *, struct Client *, int, char *[]); |
| 62 |
|
{ m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore } |
| 63 |
|
}; |
| 64 |
|
|
| 65 |
– |
#ifndef STATIC_MODULES |
| 65 |
|
const char *_version = "$Revision$"; |
| 67 |
– |
static struct Callback *stats_cb; |
| 68 |
– |
|
| 69 |
– |
static void * |
| 70 |
– |
va_stats(va_list args) |
| 71 |
– |
{ |
| 72 |
– |
struct Client *source_p = va_arg(args, struct Client *); |
| 73 |
– |
int parc = va_arg(args, int); |
| 74 |
– |
char **parv = va_arg(args, char **); |
| 75 |
– |
|
| 76 |
– |
do_stats(source_p, parc, parv); |
| 77 |
– |
return NULL; |
| 78 |
– |
} |
| 66 |
|
|
| 67 |
|
void |
| 68 |
|
_modinit(void) |
| 69 |
|
{ |
| 83 |
– |
stats_cb = register_callback("doing_stats", va_stats); |
| 70 |
|
mod_add_cmd(&stats_msgtab); |
| 71 |
|
} |
| 72 |
|
|
| 74 |
|
_moddeinit(void) |
| 75 |
|
{ |
| 76 |
|
mod_del_cmd(&stats_msgtab); |
| 91 |
– |
uninstall_hook(stats_cb, va_stats); |
| 77 |
|
} |
| 93 |
– |
#endif |
| 78 |
|
|
| 79 |
|
static char *parse_stats_args(int, char **, int *, int *); |
| 80 |
|
static void stats_L(struct Client *, char *, int, int, char); |
| 81 |
< |
static void stats_L_list(struct Client *s, char *, int, int, dlink_list *, char); |
| 81 |
> |
static void stats_L_list(struct Client *, char *, int, int, dlink_list *, char); |
| 82 |
|
|
| 83 |
|
static void stats_dns_servers(struct Client *); |
| 84 |
|
static void stats_connect(struct Client *); |
| 99 |
|
static void stats_ports(struct Client *); |
| 100 |
|
static void stats_resv(struct Client *); |
| 101 |
|
static void stats_usage(struct Client *); |
| 102 |
+ |
static void stats_service(struct Client *); |
| 103 |
|
static void stats_tstats(struct Client *); |
| 104 |
|
static void stats_uptime(struct Client *); |
| 105 |
|
static void stats_shared(struct Client *); |
| 122 |
|
const unsigned int need_admin; |
| 123 |
|
} stats_cmd_table[] = { |
| 124 |
|
/* letter function need_oper need_admin */ |
| 125 |
< |
{ 'a', stats_dns_servers, 1, 1, }, |
| 126 |
< |
{ 'A', stats_dns_servers, 1, 1, }, |
| 127 |
< |
{ 'c', stats_connect, 1, 0, }, |
| 128 |
< |
{ 'C', stats_connect, 1, 0, }, |
| 129 |
< |
{ 'd', stats_tdeny, 1, 0, }, |
| 130 |
< |
{ 'D', stats_deny, 1, 0, }, |
| 131 |
< |
{ 'e', stats_exempt, 1, 0, }, |
| 132 |
< |
{ 'E', stats_events, 1, 1, }, |
| 133 |
< |
{ 'f', fd_dump, 1, 1, }, |
| 134 |
< |
{ 'F', fd_dump, 1, 1, }, |
| 135 |
< |
{ 'g', stats_pending_glines, 1, 0, }, |
| 136 |
< |
{ 'G', stats_glines, 1, 0, }, |
| 137 |
< |
{ 'h', stats_hooks, 1, 1, }, |
| 138 |
< |
{ 'H', stats_hubleaf, 1, 0, }, |
| 139 |
< |
{ 'i', stats_auth, 0, 0, }, |
| 140 |
< |
{ 'I', stats_auth, 0, 0, }, |
| 141 |
< |
{ 'k', stats_tklines, 0, 0, }, |
| 142 |
< |
{ 'K', stats_klines, 0, 0, }, |
| 143 |
< |
{ 'l', stats_ltrace, 1, 0, }, |
| 144 |
< |
{ 'L', stats_ltrace, 1, 0, }, |
| 145 |
< |
{ 'm', stats_messages, 0, 0, }, |
| 146 |
< |
{ 'M', stats_messages, 0, 0, }, |
| 147 |
< |
{ 'o', stats_oper, 0, 0, }, |
| 148 |
< |
{ 'O', stats_oper, 0, 0, }, |
| 149 |
< |
{ 'p', stats_operedup, 0, 0, }, |
| 150 |
< |
{ 'P', stats_ports, 0, 0, }, |
| 151 |
< |
{ 'q', stats_resv, 1, 0, }, |
| 152 |
< |
{ 'Q', stats_resv, 1, 0, }, |
| 153 |
< |
{ 'r', stats_usage, 1, 0, }, |
| 154 |
< |
{ 'R', stats_usage, 1, 0, }, |
| 155 |
< |
{ 't', stats_tstats, 1, 0, }, |
| 156 |
< |
{ 'T', stats_tstats, 1, 0, }, |
| 157 |
< |
{ 'u', stats_uptime, 0, 0, }, |
| 158 |
< |
{ 'U', stats_shared, 1, 0, }, |
| 159 |
< |
{ 'v', stats_servers, 1, 0, }, |
| 160 |
< |
{ 'V', stats_gdeny, 1, 0, }, |
| 161 |
< |
{ 'x', stats_gecos, 1, 0, }, |
| 162 |
< |
{ 'X', stats_gecos, 1, 0, }, |
| 163 |
< |
{ 'y', stats_class, 1, 0, }, |
| 164 |
< |
{ 'Y', stats_class, 1, 0, }, |
| 165 |
< |
{ 'z', stats_memory, 1, 0, }, |
| 166 |
< |
{ 'Z', stats_ziplinks, 1, 0, }, |
| 167 |
< |
{ '?', stats_servlinks, 0, 0, }, |
| 168 |
< |
{ '\0', (void(*)())0, 0, 0, } |
| 125 |
> |
{ 'a', stats_dns_servers, 1, 1 }, |
| 126 |
> |
{ 'A', stats_dns_servers, 1, 1 }, |
| 127 |
> |
{ 'c', stats_connect, 1, 0 }, |
| 128 |
> |
{ 'C', stats_connect, 1, 0 }, |
| 129 |
> |
{ 'd', stats_tdeny, 1, 0 }, |
| 130 |
> |
{ 'D', stats_deny, 1, 0 }, |
| 131 |
> |
{ 'e', stats_exempt, 1, 0 }, |
| 132 |
> |
{ 'E', stats_events, 1, 1 }, |
| 133 |
> |
{ 'f', fd_dump, 1, 1 }, |
| 134 |
> |
{ 'F', fd_dump, 1, 1 }, |
| 135 |
> |
{ 'g', stats_pending_glines, 1, 0 }, |
| 136 |
> |
{ 'G', stats_glines, 1, 0 }, |
| 137 |
> |
{ 'h', stats_hooks, 1, 1 }, |
| 138 |
> |
{ 'H', stats_hubleaf, 1, 0 }, |
| 139 |
> |
{ 'i', stats_auth, 0, 0 }, |
| 140 |
> |
{ 'I', stats_auth, 0, 0 }, |
| 141 |
> |
{ 'k', stats_tklines, 0, 0 }, |
| 142 |
> |
{ 'K', stats_klines, 0, 0 }, |
| 143 |
> |
{ 'l', stats_ltrace, 1, 0 }, |
| 144 |
> |
{ 'L', stats_ltrace, 1, 0 }, |
| 145 |
> |
{ 'm', stats_messages, 0, 0 }, |
| 146 |
> |
{ 'M', stats_messages, 0, 0 }, |
| 147 |
> |
{ 'o', stats_oper, 0, 0 }, |
| 148 |
> |
{ 'O', stats_oper, 0, 0 }, |
| 149 |
> |
{ 'p', stats_operedup, 0, 0 }, |
| 150 |
> |
{ 'P', stats_ports, 0, 0 }, |
| 151 |
> |
{ 'q', stats_resv, 1, 0 }, |
| 152 |
> |
{ 'Q', stats_resv, 1, 0 }, |
| 153 |
> |
{ 'r', stats_usage, 1, 0 }, |
| 154 |
> |
{ 'R', stats_usage, 1, 0 }, |
| 155 |
> |
{ 'S', stats_service, 1, 0 }, |
| 156 |
> |
{ 't', stats_tstats, 1, 0 }, |
| 157 |
> |
{ 'T', stats_tstats, 1, 0 }, |
| 158 |
> |
{ 'u', stats_uptime, 0, 0 }, |
| 159 |
> |
{ 'U', stats_shared, 1, 0 }, |
| 160 |
> |
{ 'v', stats_servers, 1, 0 }, |
| 161 |
> |
{ 'V', stats_gdeny, 1, 0 }, |
| 162 |
> |
{ 'x', stats_gecos, 1, 0 }, |
| 163 |
> |
{ 'X', stats_gecos, 1, 0 }, |
| 164 |
> |
{ 'y', stats_class, 1, 0 }, |
| 165 |
> |
{ 'Y', stats_class, 1, 0 }, |
| 166 |
> |
{ 'z', stats_memory, 1, 0 }, |
| 167 |
> |
{ 'Z', stats_ziplinks, 1, 0 }, |
| 168 |
> |
{ '?', stats_servlinks, 0, 0 }, |
| 169 |
> |
{ '\0', NULL, 0, 0 } |
| 170 |
|
}; |
| 171 |
|
|
| 172 |
|
const char *from, *to; |
| 173 |
|
|
| 174 |
|
static void |
| 175 |
< |
do_stats(struct Client *source_p, int parc, char **parv) |
| 175 |
> |
do_stats(struct Client *source_p, int parc, char *parv[]) |
| 176 |
|
{ |
| 177 |
+ |
const struct StatsStruct *tab = stats_cmd_table; |
| 178 |
|
char statchar = *parv[1]; |
| 192 |
– |
int i; |
| 179 |
|
|
| 180 |
|
if (statchar == '\0') |
| 181 |
|
{ |
| 184 |
|
return; |
| 185 |
|
} |
| 186 |
|
|
| 187 |
< |
for (i = 0; stats_cmd_table[i].handler; i++) |
| 187 |
> |
for (; tab->handler; ++tab) |
| 188 |
|
{ |
| 189 |
< |
if (stats_cmd_table[i].letter == statchar) |
| 189 |
> |
if (tab->letter == statchar) |
| 190 |
|
{ |
| 191 |
|
/* The stats table says what privs are needed, so check --fl_ */ |
| 192 |
< |
if ((stats_cmd_table[i].need_admin && !IsAdmin(source_p)) || |
| 193 |
< |
(stats_cmd_table[i].need_oper && !IsOper(source_p))) |
| 192 |
> |
if ((tab->need_admin && !IsAdmin(source_p)) || |
| 193 |
> |
(tab->need_oper && !IsOper(source_p))) |
| 194 |
|
{ |
| 195 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 196 |
|
from, to); |
| 199 |
|
|
| 200 |
|
/* Blah, stats L needs the parameters, none of the others do.. */ |
| 201 |
|
if (statchar == 'L' || statchar == 'l') |
| 202 |
< |
stats_cmd_table[i].handler(source_p, parc, parv); |
| 202 |
> |
{ |
| 203 |
> |
sendto_realops_flags(UMODE_SPY, L_ALL, |
| 204 |
> |
"STATS %c requested by %s (%s@%s) [%s] on %s", |
| 205 |
> |
statchar, source_p->name, source_p->username, |
| 206 |
> |
source_p->host, source_p->servptr->name, |
| 207 |
> |
parc > 2 ? parv[2] : "<no recipient>"); |
| 208 |
> |
tab->handler(source_p, parc, parv); |
| 209 |
> |
} |
| 210 |
|
else |
| 211 |
< |
stats_cmd_table[i].handler(source_p); |
| 211 |
> |
{ |
| 212 |
> |
sendto_realops_flags(UMODE_SPY, L_ALL, |
| 213 |
> |
"STATS %c requested by %s (%s@%s) [%s]", |
| 214 |
> |
statchar, source_p->name, source_p->username, |
| 215 |
> |
source_p->host, source_p->servptr->name); |
| 216 |
> |
tab->handler(source_p); |
| 217 |
> |
} |
| 218 |
|
|
| 219 |
|
break; |
| 220 |
|
} |
| 241 |
|
|
| 242 |
|
/* Is the stats meant for us? */ |
| 243 |
|
if (!ConfigFileEntry.disable_remote) |
| 244 |
< |
if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME) |
| 244 |
> |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
| 245 |
> |
parc, parv) != HUNTED_ISME) |
| 246 |
|
return; |
| 247 |
|
|
| 248 |
|
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 263 |
|
from, to); |
| 264 |
|
return; |
| 265 |
|
} |
| 266 |
– |
else |
| 267 |
– |
last_used = CurrentTime; |
| 266 |
|
|
| 267 |
< |
#ifdef STATIC_MODULES |
| 267 |
> |
last_used = CurrentTime; |
| 268 |
> |
|
| 269 |
|
do_stats(source_p, parc, parv); |
| 271 |
– |
#else |
| 272 |
– |
execute_callback(stats_cb, source_p, parc, parv); |
| 273 |
– |
#endif |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
/* |
| 297 |
|
to = source_p->name; |
| 298 |
|
} |
| 299 |
|
|
| 304 |
– |
#ifdef STATIC_MODULES |
| 300 |
|
do_stats(source_p, parc, parv); |
| 301 |
< |
#else |
| 302 |
< |
execute_callback(stats_cb, source_p, parc, parv); |
| 303 |
< |
#endif |
| 301 |
> |
} |
| 302 |
> |
|
| 303 |
> |
/* |
| 304 |
> |
* ms_stats - STATS message handler |
| 305 |
> |
* parv[0] = sender prefix |
| 306 |
> |
* parv[1] = statistics selector (defaults to Message frequency) |
| 307 |
> |
* parv[2] = server name (current server defaulted, if omitted) |
| 308 |
> |
*/ |
| 309 |
> |
static void |
| 310 |
> |
ms_stats(struct Client *client_p, struct Client *source_p, |
| 311 |
> |
int parc, char *parv[]) |
| 312 |
> |
{ |
| 313 |
> |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
| 314 |
> |
parc, parv) != HUNTED_ISME) |
| 315 |
> |
return; |
| 316 |
> |
|
| 317 |
> |
if (IsClient(source_p)) |
| 318 |
> |
mo_stats(client_p, source_p, parc, parv); |
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
/* |
| 328 |
|
static void |
| 329 |
|
send_usage(struct Client *source_p) |
| 330 |
|
{ |
| 321 |
– |
#ifndef _WIN32 |
| 331 |
|
struct rusage rus; |
| 332 |
|
time_t secs; |
| 333 |
|
time_t rup; |
| 379 |
|
sendto_one(source_p, ":%s %d %s R :Signals %d Context Vol. %d Invol %d", |
| 380 |
|
me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals, |
| 381 |
|
(int)rus.ru_nvcsw, (int)rus.ru_nivcsw); |
| 373 |
– |
#endif |
| 382 |
|
} |
| 383 |
|
|
| 384 |
|
static void |
| 387 |
|
const dlink_node *gptr = NULL; |
| 388 |
|
const dlink_node *dlink = NULL; |
| 389 |
|
|
| 390 |
< |
int local_client_conf_count = 0; /* local client conf links */ |
| 391 |
< |
int users_counted = 0; /* user structs */ |
| 390 |
> |
unsigned int local_client_conf_count = 0; /* local client conf links */ |
| 391 |
> |
unsigned int users_counted = 0; /* user structs */ |
| 392 |
|
|
| 393 |
< |
int channel_users = 0; /* XXX */ |
| 394 |
< |
int channel_invites = 0; |
| 395 |
< |
int channel_bans = 0; |
| 396 |
< |
int channel_except = 0; |
| 397 |
< |
int channel_invex = 0; |
| 398 |
< |
|
| 399 |
< |
int wwu = 0; /* whowas users */ |
| 400 |
< |
int class_count = 0; /* classes */ |
| 401 |
< |
int users_invited_count = 0; /* users invited */ |
| 402 |
< |
int aways_counted = 0; |
| 403 |
< |
int number_ips_stored; /* number of ip addresses hashed */ |
| 404 |
< |
|
| 405 |
< |
unsigned long channel_memory = 0; |
| 406 |
< |
size_t channel_ban_memory = 0; |
| 407 |
< |
size_t channel_except_memory = 0; |
| 400 |
< |
size_t channel_invex_memory = 0; |
| 393 |
> |
unsigned int channel_members = 0; |
| 394 |
> |
unsigned int channel_invites = 0; |
| 395 |
> |
unsigned int channel_bans = 0; |
| 396 |
> |
unsigned int channel_except = 0; |
| 397 |
> |
unsigned int channel_invex = 0; |
| 398 |
> |
|
| 399 |
> |
unsigned int wwu = 0; /* whowas users */ |
| 400 |
> |
unsigned int class_count = 0; /* classes */ |
| 401 |
> |
unsigned int aways_counted = 0; |
| 402 |
> |
unsigned int number_ips_stored; /* number of ip addresses hashed */ |
| 403 |
> |
|
| 404 |
> |
uint64_t channel_memory = 0; |
| 405 |
> |
uint64_t channel_ban_memory = 0; |
| 406 |
> |
uint64_t channel_except_memory = 0; |
| 407 |
> |
uint64_t channel_invex_memory = 0; |
| 408 |
|
|
| 409 |
|
unsigned int safelist_count = 0; |
| 410 |
< |
size_t safelist_memory = 0; |
| 410 |
> |
uint64_t safelist_memory = 0; |
| 411 |
> |
|
| 412 |
> |
uint64_t away_memory = 0; /* memory used by aways */ |
| 413 |
> |
uint64_t wwm = 0; /* whowas array memory used */ |
| 414 |
> |
uint64_t conf_memory = 0; /* memory used by conf lines */ |
| 415 |
> |
uint64_t mem_ips_stored; /* memory used by ip address hash */ |
| 416 |
|
|
| 417 |
< |
unsigned long away_memory = 0; /* memory used by aways */ |
| 418 |
< |
unsigned long wwm = 0; /* whowas array memory used */ |
| 407 |
< |
unsigned long conf_memory = 0; /* memory used by conf lines */ |
| 408 |
< |
unsigned long mem_ips_stored; /* memory used by ip address hash */ |
| 409 |
< |
|
| 410 |
< |
unsigned long client_hash_table_size = 0; |
| 411 |
< |
unsigned long channel_hash_table_size = 0; |
| 412 |
< |
unsigned long resv_hash_table_size = 0; |
| 413 |
< |
unsigned long id_hash_table_size = 0; |
| 414 |
< |
unsigned long total_channel_memory = 0; |
| 415 |
< |
unsigned long totww = 0; |
| 417 |
> |
uint64_t total_channel_memory = 0; |
| 418 |
> |
uint64_t totww = 0; |
| 419 |
|
|
| 420 |
|
unsigned int local_client_count = 0; |
| 421 |
|
unsigned int remote_client_count = 0; |
| 422 |
|
|
| 423 |
< |
unsigned int local_client_memory_used = 0; |
| 424 |
< |
unsigned int remote_client_memory_used = 0; |
| 423 |
> |
uint64_t local_client_memory_used = 0; |
| 424 |
> |
uint64_t remote_client_memory_used = 0; |
| 425 |
|
|
| 426 |
< |
unsigned long total_memory = 0; |
| 426 |
> |
uint64_t total_memory = 0; |
| 427 |
|
unsigned int topic_count = 0; |
| 428 |
|
|
| 429 |
< |
count_whowas_memory(&wwu, &wwm); |
| 429 |
> |
unsigned int watch_list_headers = 0; /* watchlist headers */ |
| 430 |
> |
unsigned int watch_list_entries = 0; /* watchlist entries */ |
| 431 |
> |
uint64_t watch_list_memory = 0; /* watchlist memory used */ |
| 432 |
> |
|
| 433 |
|
|
| 434 |
|
DLINK_FOREACH(gptr, global_client_list.head) |
| 435 |
|
{ |
| 439 |
|
{ |
| 440 |
|
++local_client_count; |
| 441 |
|
local_client_conf_count += dlink_list_length(&target_p->localClient->confs); |
| 442 |
+ |
watch_list_entries += dlink_list_length(&target_p->localClient->watches); |
| 443 |
|
} |
| 444 |
|
else |
| 445 |
|
++remote_client_count; |
| 447 |
|
if (IsClient(target_p)) |
| 448 |
|
{ |
| 449 |
|
++users_counted; |
| 443 |
– |
users_invited_count += dlink_list_length(&target_p->invited); |
| 450 |
|
|
| 451 |
|
if (target_p->away != NULL) |
| 452 |
|
{ |
| 461 |
|
sizeof(struct Channel); |
| 462 |
|
DLINK_FOREACH(gptr, global_channel_list.head) |
| 463 |
|
{ |
| 464 |
< |
struct Ban *actualBan; |
| 465 |
< |
struct Channel *chptr = gptr->data; |
| 464 |
> |
const struct Ban *actualBan; |
| 465 |
> |
const struct Channel *chptr = gptr->data; |
| 466 |
|
|
| 467 |
< |
channel_users += dlink_list_length(&chptr->members); |
| 467 |
> |
channel_members += dlink_list_length(&chptr->members); |
| 468 |
|
channel_invites += dlink_list_length(&chptr->invites); |
| 469 |
|
|
| 470 |
|
if (chptr->topic != NULL) |
| 471 |
|
++topic_count; |
| 472 |
|
|
| 473 |
< |
if ((channel_bans = dlink_list_length(&chptr->banlist))) |
| 474 |
< |
{ |
| 469 |
< |
channel_ban_memory = channel_bans * sizeof(struct Ban); |
| 473 |
> |
channel_bans += dlink_list_length(&chptr->banlist); |
| 474 |
> |
channel_ban_memory += dlink_list_length(&chptr->banlist) * sizeof(struct Ban); |
| 475 |
|
|
| 476 |
< |
DLINK_FOREACH(dlink, chptr->banlist.head) |
| 477 |
< |
{ |
| 478 |
< |
actualBan = dlink->data; |
| 479 |
< |
assert(actualBan->who); |
| 476 |
> |
DLINK_FOREACH(dlink, chptr->banlist.head) |
| 477 |
> |
{ |
| 478 |
> |
actualBan = dlink->data; |
| 479 |
> |
assert(actualBan->who); |
| 480 |
|
|
| 481 |
< |
channel_ban_memory += actualBan->len + 3; |
| 482 |
< |
channel_ban_memory += strlen(actualBan->who) + 1; |
| 478 |
< |
} |
| 481 |
> |
channel_ban_memory += actualBan->len + 1; |
| 482 |
> |
channel_ban_memory += strlen(actualBan->who) + 1; |
| 483 |
|
} |
| 484 |
|
|
| 485 |
< |
if ((channel_except = dlink_list_length(&chptr->exceptlist))) |
| 486 |
< |
{ |
| 483 |
< |
channel_except_memory = channel_except * sizeof(struct Ban); |
| 485 |
> |
channel_except += dlink_list_length(&chptr->exceptlist); |
| 486 |
> |
channel_except_memory += dlink_list_length(&chptr->exceptlist) * sizeof(struct Ban); |
| 487 |
|
|
| 488 |
< |
DLINK_FOREACH(dlink, chptr->exceptlist.head) |
| 489 |
< |
{ |
| 490 |
< |
actualBan = dlink->data; |
| 491 |
< |
assert(actualBan->who); |
| 488 |
> |
DLINK_FOREACH(dlink, chptr->exceptlist.head) |
| 489 |
> |
{ |
| 490 |
> |
actualBan = dlink->data; |
| 491 |
> |
assert(actualBan->who); |
| 492 |
|
|
| 493 |
< |
channel_except_memory += actualBan->len + 3; |
| 494 |
< |
channel_except_memory += strlen(actualBan->who) + 1; |
| 492 |
< |
} |
| 493 |
> |
channel_except_memory += actualBan->len + 1; |
| 494 |
> |
channel_except_memory += strlen(actualBan->who) + 1; |
| 495 |
|
} |
| 496 |
|
|
| 497 |
< |
if ((channel_invex = dlink_list_length(&chptr->invexlist))) |
| 498 |
< |
{ |
| 497 |
< |
channel_invex_memory = channel_invex * sizeof(struct Ban); |
| 497 |
> |
channel_invex += dlink_list_length(&chptr->invexlist); |
| 498 |
> |
channel_invex_memory += dlink_list_length(&chptr->invexlist) * sizeof(struct Ban); |
| 499 |
|
|
| 500 |
< |
DLINK_FOREACH(dlink, chptr->invexlist.head) |
| 501 |
< |
{ |
| 502 |
< |
actualBan = dlink->data; |
| 503 |
< |
assert(actualBan->who); |
| 500 |
> |
DLINK_FOREACH(dlink, chptr->invexlist.head) |
| 501 |
> |
{ |
| 502 |
> |
actualBan = dlink->data; |
| 503 |
> |
assert(actualBan->who); |
| 504 |
|
|
| 505 |
< |
channel_invex_memory += actualBan->len + 3; |
| 506 |
< |
channel_invex_memory += strlen(actualBan->who) + 1; |
| 506 |
< |
} |
| 505 |
> |
channel_invex_memory += actualBan->len + 1; |
| 506 |
> |
channel_invex_memory += strlen(actualBan->who) + 1; |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
|
| 512 |
|
safelist_memory = safelist_count * sizeof(struct ListTask); |
| 513 |
|
DLINK_FOREACH(gptr, listing_client_list.head) |
| 514 |
|
{ |
| 515 |
< |
struct Client *acptr = gptr->data; |
| 515 |
> |
const struct Client *acptr = gptr->data; |
| 516 |
|
|
| 517 |
|
DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head) |
| 518 |
|
safelist_memory += strlen(dlink->data); |
| 537 |
|
/* count up all classes */ |
| 538 |
|
class_count = dlink_list_length(&class_items); |
| 539 |
|
|
| 540 |
< |
sendto_one(source_p, ":%s %d %s z :Clients %u(%lu) Invites %u(%lu)", |
| 540 |
> |
count_whowas_memory(&wwu, &wwm); |
| 541 |
> |
watch_count_memory(&watch_list_headers, &watch_list_memory); |
| 542 |
> |
|
| 543 |
> |
sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%u)", |
| 544 |
> |
me.name, RPL_STATSDEBUG, source_p->name, watch_list_headers, |
| 545 |
> |
watch_list_memory, watch_list_entries, |
| 546 |
> |
watch_list_entries * sizeof(dlink_node) * 2); |
| 547 |
> |
|
| 548 |
> |
sendto_one(source_p, ":%s %d %s z :Clients %u(%u)", |
| 549 |
|
me.name, RPL_STATSDEBUG, source_p->name, users_counted, |
| 550 |
< |
(unsigned long)(users_counted * sizeof(struct Client)), |
| 543 |
< |
users_invited_count, (unsigned long)(users_invited_count * sizeof(dlink_node))); |
| 550 |
> |
(users_counted * sizeof(struct Client))); |
| 551 |
|
|
| 552 |
< |
sendto_one(source_p, ":%s %d %s z :User aways %u(%d)", |
| 552 |
> |
sendto_one(source_p, ":%s %d %s z :User aways %u(%llu)", |
| 553 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 554 |
< |
aways_counted, (int)away_memory); |
| 554 |
> |
aways_counted, away_memory); |
| 555 |
|
|
| 556 |
< |
sendto_one(source_p, ":%s %d %s z :Attached confs %u(%lu)", |
| 556 |
> |
sendto_one(source_p, ":%s %d %s z :Attached confs %u(%llu)", |
| 557 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 558 |
|
local_client_conf_count, |
| 559 |
< |
(unsigned long)(local_client_conf_count * sizeof(dlink_node))); |
| 553 |
< |
|
| 554 |
< |
/* XXX ConfigItemList fix */ |
| 555 |
< |
#if 0 |
| 556 |
< |
sendto_one(source_p, ":%s %d %s z :Conflines %lu(%d)", |
| 557 |
< |
me.name, RPL_STATSDEBUG, source_p->name, |
| 558 |
< |
dlink_list_length(&ConfigItemList), (int) conf_memory); |
| 559 |
< |
#endif |
| 559 |
> |
(unsigned long long)(local_client_conf_count * sizeof(dlink_node))); |
| 560 |
|
|
| 561 |
< |
sendto_one(source_p, ":%s %d %s z :Resv channels %lu(%lu) nicks %lu(%lu)", |
| 561 |
> |
sendto_one(source_p, ":%s %d %s z :Resv channels %u(%lu) nicks %u(%lu)", |
| 562 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 563 |
|
dlink_list_length(&resv_channel_list), |
| 564 |
|
dlink_list_length(&resv_channel_list) * sizeof(struct ResvChannel), |
| 565 |
|
dlink_list_length(&nresv_items), |
| 566 |
|
dlink_list_length(&nresv_items) * sizeof(struct MatchItem)); |
| 567 |
|
|
| 568 |
< |
sendto_one(source_p, ":%s %d %s z :Classes %u(%lu)", |
| 568 |
> |
sendto_one(source_p, ":%s %d %s z :Classes %u(%llu)", |
| 569 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 570 |
< |
class_count, (unsigned long)(class_count * sizeof(struct ClassItem))); |
| 570 |
> |
class_count, (unsigned long long)(class_count * sizeof(struct ClassItem))); |
| 571 |
|
|
| 572 |
< |
sendto_one(source_p, ":%s %d %s z :Channels %lu(%lu) Topics %u(%d)", |
| 572 |
> |
sendto_one(source_p, ":%s %d %s z :Channels %uu(%llu) Topics %u(%u)", |
| 573 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 574 |
|
dlink_list_length(&global_channel_list), |
| 575 |
|
channel_memory, topic_count, topic_count * |
| 576 |
|
(TOPICLEN + 1 + USERHOST_REPLYLEN)); |
| 577 |
|
|
| 578 |
< |
sendto_one(source_p, ":%s %d %s z :Bans %u(%u)", |
| 578 |
> |
sendto_one(source_p, ":%s %d %s z :Bans %u(%llu)", |
| 579 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 580 |
|
channel_bans, channel_ban_memory); |
| 581 |
|
|
| 582 |
< |
sendto_one(source_p, ":%s %d %s z :Exceptions %u(%u)", |
| 582 |
> |
sendto_one(source_p, ":%s %d %s z :Exceptions %u(%llu)", |
| 583 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 584 |
|
channel_except, channel_except_memory); |
| 585 |
|
|
| 586 |
< |
sendto_one(source_p, ":%s %d %s z :Invex %u(%u)", |
| 586 |
> |
sendto_one(source_p, ":%s %d %s z :Invex %u(%llu)", |
| 587 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 588 |
|
channel_invex, channel_invex_memory); |
| 589 |
|
|
| 590 |
< |
sendto_one(source_p, ":%s %d %s z :Channel members %u(%lu) invite %u(%lu)", |
| 591 |
< |
me.name, RPL_STATSDEBUG, source_p->name, channel_users, |
| 592 |
< |
(unsigned long)(channel_users * sizeof(struct Membership)), |
| 593 |
< |
channel_invites, (unsigned long)channel_invites * |
| 594 |
< |
sizeof(dlink_node)); |
| 590 |
> |
sendto_one(source_p, ":%s %d %s z :Channel members %u(%llu) invites %u(%llu)", |
| 591 |
> |
me.name, RPL_STATSDEBUG, source_p->name, channel_members, |
| 592 |
> |
(unsigned long long)(channel_members * sizeof(struct Membership)), |
| 593 |
> |
channel_invites, (unsigned long long)channel_invites * |
| 594 |
> |
sizeof(dlink_node) * 2); |
| 595 |
|
|
| 596 |
|
total_channel_memory = channel_memory + channel_ban_memory + |
| 597 |
< |
channel_users * sizeof(struct Membership) + |
| 598 |
< |
channel_invites * sizeof(dlink_node); |
| 597 |
> |
channel_members * sizeof(struct Membership) + |
| 598 |
> |
(channel_invites * sizeof(dlink_node)*2); |
| 599 |
|
|
| 600 |
< |
sendto_one(source_p, ":%s %d %s z :Safelist %u(%u)", |
| 600 |
> |
sendto_one(source_p, ":%s %d %s z :Safelist %u(%llu)", |
| 601 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 602 |
|
safelist_count, safelist_memory); |
| 603 |
|
|
| 604 |
< |
sendto_one(source_p, ":%s %d %s z :Whowas users %u(%lu)", |
| 604 |
> |
sendto_one(source_p, ":%s %d %s z :Whowas users %u(%llu)", |
| 605 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 606 |
< |
wwu, (unsigned long)(wwu * sizeof(struct Client))); |
| 606 |
> |
wwu, (unsigned long long)(wwu * sizeof(struct Client))); |
| 607 |
|
|
| 608 |
< |
sendto_one(source_p, ":%s %d %s z :Whowas array %u(%d)", |
| 608 |
> |
sendto_one(source_p, ":%s %d %s z :Whowas array %u(%llu)", |
| 609 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 610 |
< |
NICKNAMEHISTORYLENGTH, (int)wwm); |
| 610 |
> |
NICKNAMEHISTORYLENGTH, wwm); |
| 611 |
|
|
| 612 |
|
totww = wwu * sizeof(struct Client) + wwm; |
| 613 |
– |
/**** |
| 614 |
– |
client_hash_table_size = hash_get_client_table_size(); |
| 615 |
– |
channel_hash_table_size = hash_get_channel_table_size(); |
| 616 |
– |
resv_hash_table_size = hash_get_resv_table_size(); |
| 617 |
– |
id_hash_table_size = hash_get_id_table_size(); |
| 613 |
|
|
| 619 |
– |
sendto_one(source_p, ":%s %d %s z :Hash: client %u(%lu) chan %u(%lu) resv " |
| 620 |
– |
"%u(%lu) id %u(%lu)", |
| 621 |
– |
me.name, RPL_STATSDEBUG, source_p->name, |
| 622 |
– |
U_MAX, client_hash_table_size, |
| 623 |
– |
CH_MAX, channel_hash_table_size , R_MAX, |
| 624 |
– |
resv_hash_table_size, U_MAX, id_hash_table_size); |
| 625 |
– |
****/ |
| 614 |
|
count_ip_hash(&number_ips_stored,&mem_ips_stored); |
| 615 |
< |
sendto_one(source_p, ":%s %d %s z :iphash %u(%d)", |
| 615 |
> |
sendto_one(source_p, ":%s %d %s z :iphash %u(%llu)", |
| 616 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 617 |
< |
number_ips_stored, (int)mem_ips_stored); |
| 617 |
> |
number_ips_stored, mem_ips_stored); |
| 618 |
|
|
| 619 |
|
total_memory = totww + total_channel_memory + conf_memory + class_count * |
| 620 |
|
sizeof(struct ClassItem); |
| 621 |
< |
total_memory += client_hash_table_size; |
| 622 |
< |
total_memory += channel_hash_table_size; |
| 623 |
< |
total_memory += resv_hash_table_size; |
| 636 |
< |
total_memory += id_hash_table_size; |
| 637 |
< |
|
| 638 |
< |
sendto_one(source_p, ":%s %d %s z :Total: whowas %d channel %d conf %d", |
| 639 |
< |
me.name, RPL_STATSDEBUG, source_p->name, (int)totww, |
| 640 |
< |
(int)total_channel_memory, (int)conf_memory); |
| 621 |
> |
sendto_one(source_p, ":%s %d %s z :Total: whowas %llu channel %llu conf %llu", |
| 622 |
> |
me.name, RPL_STATSDEBUG, source_p->name, totww, |
| 623 |
> |
total_channel_memory, conf_memory); |
| 624 |
|
|
| 625 |
|
local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser)); |
| 626 |
|
total_memory += local_client_memory_used; |
| 627 |
< |
sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%d)", |
| 627 |
> |
sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %u(%llu)", |
| 628 |
|
me.name, RPL_STATSDEBUG, source_p->name, local_client_count, |
| 629 |
|
local_client_memory_used); |
| 630 |
|
|
| 631 |
|
remote_client_memory_used = remote_client_count * sizeof(struct Client); |
| 632 |
|
total_memory += remote_client_memory_used; |
| 633 |
< |
sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%d)", |
| 633 |
> |
sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %u(%llu)", |
| 634 |
|
me.name, RPL_STATSDEBUG, source_p->name, remote_client_count, |
| 635 |
|
remote_client_memory_used); |
| 636 |
|
|
| 637 |
|
block_heap_report_stats(source_p); |
| 638 |
|
|
| 639 |
|
sendto_one(source_p, |
| 640 |
< |
":%s %d %s z :TOTAL: %d Available: Current max RSS: %lu", |
| 640 |
> |
":%s %d %s z :TOTAL: %llu", |
| 641 |
|
me.name, RPL_STATSDEBUG, source_p->name, |
| 642 |
< |
(int)total_memory, get_maxrss()); |
| 642 |
> |
total_memory); |
| 643 |
|
} |
| 644 |
|
|
| 645 |
|
static void |
| 740 |
|
struct AccessItem *aconf; |
| 741 |
|
int i; |
| 742 |
|
|
| 743 |
+ |
if (ConfigFileEntry.stats_e_disabled) |
| 744 |
+ |
{ |
| 745 |
+ |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 746 |
+ |
from, to); |
| 747 |
+ |
return; |
| 748 |
+ |
} |
| 749 |
+ |
|
| 750 |
|
for (i = 0; i < ATABLE_SIZE; i++) |
| 751 |
|
{ |
| 752 |
|
for (arec = atable[i]; arec; arec=arec->next) |
| 780 |
|
static void |
| 781 |
|
stats_pending_glines(struct Client *source_p) |
| 782 |
|
{ |
| 783 |
< |
#ifdef GLINE_VOTING |
| 784 |
< |
dlink_node *pending_node; |
| 785 |
< |
struct gline_pending *glp_ptr; |
| 786 |
< |
char timebuffer[MAX_DATE_STRING]; |
| 797 |
< |
struct tm *tmptr; |
| 783 |
> |
const dlink_node *dn_ptr = NULL; |
| 784 |
> |
const struct gline_pending *glp_ptr = NULL; |
| 785 |
> |
char timebuffer[MAX_DATE_STRING] = { '\0' }; |
| 786 |
> |
struct tm *tmptr = NULL; |
| 787 |
|
|
| 788 |
|
if (!ConfigFileEntry.glines) |
| 789 |
|
{ |
| 792 |
|
return; |
| 793 |
|
} |
| 794 |
|
|
| 795 |
< |
if (dlink_list_length(&pending_glines) > 0) |
| 795 |
> |
if (dlink_list_length(&pending_glines[GLINE_PENDING_ADD_TYPE]) > 0) |
| 796 |
|
sendto_one(source_p, ":%s NOTICE %s :Pending G-lines", |
| 797 |
|
from, to); |
| 798 |
|
|
| 799 |
< |
DLINK_FOREACH(pending_node, pending_glines.head) |
| 799 |
> |
DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_ADD_TYPE].head) |
| 800 |
|
{ |
| 801 |
< |
glp_ptr = pending_node->data; |
| 802 |
< |
tmptr = localtime(&glp_ptr->time_request1); |
| 801 |
> |
glp_ptr = dn_ptr->data; |
| 802 |
> |
tmptr = localtime(&glp_ptr->vote_1.time_request); |
| 803 |
|
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr); |
| 804 |
|
|
| 805 |
|
sendto_one(source_p, |
| 806 |
|
":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]", |
| 807 |
< |
from, to, glp_ptr->oper_nick1, |
| 808 |
< |
glp_ptr->oper_user1, glp_ptr->oper_host1, |
| 809 |
< |
glp_ptr->oper_server1, timebuffer, |
| 810 |
< |
glp_ptr->user, glp_ptr->host, glp_ptr->reason1); |
| 807 |
> |
from, to, glp_ptr->vote_1.oper_nick, |
| 808 |
> |
glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host, |
| 809 |
> |
glp_ptr->vote_1.oper_server, timebuffer, |
| 810 |
> |
glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason); |
| 811 |
|
|
| 812 |
< |
if (glp_ptr->oper_nick2[0] != '\0') |
| 812 |
> |
if (glp_ptr->vote_2.oper_nick[0] != '\0') |
| 813 |
|
{ |
| 814 |
< |
tmptr = localtime(&glp_ptr->time_request2); |
| 814 |
> |
tmptr = localtime(&glp_ptr->vote_2.time_request); |
| 815 |
|
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr); |
| 816 |
|
sendto_one(source_p, |
| 817 |
|
":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]", |
| 818 |
< |
from, to, glp_ptr->oper_nick2, |
| 819 |
< |
glp_ptr->oper_user2, glp_ptr->oper_host2, |
| 820 |
< |
glp_ptr->oper_server2, timebuffer, |
| 821 |
< |
glp_ptr->user, glp_ptr->host, glp_ptr->reason2); |
| 818 |
> |
from, to, glp_ptr->vote_2.oper_nick, |
| 819 |
> |
glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host, |
| 820 |
> |
glp_ptr->vote_2.oper_server, timebuffer, |
| 821 |
> |
glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason); |
| 822 |
|
} |
| 823 |
|
} |
| 824 |
|
|
| 825 |
|
sendto_one(source_p, ":%s NOTICE %s :End of Pending G-lines", |
| 826 |
|
from, to); |
| 827 |
< |
#else |
| 828 |
< |
sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Line voting", |
| 827 |
> |
|
| 828 |
> |
if (dlink_list_length(&pending_glines[GLINE_PENDING_DEL_TYPE]) > 0) |
| 829 |
> |
sendto_one(source_p, ":%s NOTICE %s :Pending UNG-lines", |
| 830 |
> |
from, to); |
| 831 |
> |
|
| 832 |
> |
DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_DEL_TYPE].head) |
| 833 |
> |
{ |
| 834 |
> |
glp_ptr = dn_ptr->data; |
| 835 |
> |
tmptr = localtime(&glp_ptr->vote_1.time_request); |
| 836 |
> |
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr); |
| 837 |
> |
|
| 838 |
> |
sendto_one(source_p, |
| 839 |
> |
":%s NOTICE %s :1) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]", |
| 840 |
> |
from, to, glp_ptr->vote_1.oper_nick, |
| 841 |
> |
glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host, |
| 842 |
> |
glp_ptr->vote_1.oper_server, timebuffer, |
| 843 |
> |
glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason); |
| 844 |
> |
|
| 845 |
> |
if (glp_ptr->vote_2.oper_nick[0] != '\0') |
| 846 |
> |
{ |
| 847 |
> |
tmptr = localtime(&glp_ptr->vote_2.time_request); |
| 848 |
> |
strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr); |
| 849 |
> |
sendto_one(source_p, |
| 850 |
> |
":%s NOTICE %s :2) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]", |
| 851 |
> |
from, to, glp_ptr->vote_2.oper_nick, |
| 852 |
> |
glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host, |
| 853 |
> |
glp_ptr->vote_2.oper_server, timebuffer, |
| 854 |
> |
glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason); |
| 855 |
> |
|
| 856 |
> |
} |
| 857 |
> |
} |
| 858 |
> |
|
| 859 |
> |
sendto_one(source_p, ":%s NOTICE %s :End of Pending UNG-lines", |
| 860 |
|
from, to); |
| 841 |
– |
#endif /* GLINE VOTING */ |
| 861 |
|
} |
| 862 |
|
|
| 863 |
|
/* stats_glines() |
| 881 |
|
|
| 882 |
|
for (; i < ATABLE_SIZE; ++i) |
| 883 |
|
{ |
| 884 |
< |
for (arec = atable[i]; arec; arec=arec->next) |
| 884 |
> |
for (arec = atable[i]; arec; arec = arec->next) |
| 885 |
|
{ |
| 886 |
|
if (arec->type == CONF_GLINE) |
| 887 |
|
{ |
| 1021 |
|
struct AccessItem *aconf; |
| 1022 |
|
|
| 1023 |
|
/* search for a kline */ |
| 1024 |
< |
if(MyConnect(source_p)) |
| 1024 |
> |
if (MyConnect(source_p)) |
| 1025 |
|
aconf = find_conf_by_address(source_p->host, |
| 1026 |
|
&source_p->localClient->ip, |
| 1027 |
|
CONF_KILL, |
| 1031 |
|
aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL, |
| 1032 |
|
0, source_p->username, NULL); |
| 1033 |
|
|
| 1034 |
< |
if(aconf == NULL) |
| 1034 |
> |
if (aconf == NULL) |
| 1035 |
|
return; |
| 1036 |
|
|
| 1037 |
|
/* dont report a tkline as a kline */ |
| 1038 |
< |
if(aconf->flags & CONF_FLAGS_TEMPORARY) |
| 1038 |
> |
if (aconf->flags & CONF_FLAGS_TEMPORARY) |
| 1039 |
|
return; |
| 1040 |
|
|
| 1041 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), from, |
| 1090 |
|
(IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O', |
| 1091 |
|
oper_privs_as_string(target_p->localClient->operflags), |
| 1092 |
|
target_p->name, target_p->username, target_p->host, |
| 1093 |
< |
(int)(CurrentTime - target_p->localClient->last)); |
| 1093 |
> |
(int)(CurrentTime - target_p->localClient->last_privmsg)); |
| 1094 |
|
else |
| 1095 |
|
sendto_one(source_p, ":%s %d %s p :[%c] %s (%s@%s) Idle: %d", |
| 1096 |
|
from, RPL_STATSDEBUG, to, |
| 1097 |
|
IsAdmin(target_p) ? |
| 1098 |
|
(IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O', |
| 1099 |
|
target_p->name, target_p->username, target_p->host, |
| 1100 |
< |
(int)(CurrentTime - target_p->localClient->last)); |
| 1100 |
> |
(int)(CurrentTime - target_p->localClient->last_privmsg)); |
| 1101 |
|
} |
| 1102 |
|
|
| 1103 |
|
sendto_one(source_p, ":%s %d %s p :%lu OPER(s)", |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
static void |
| 1130 |
+ |
stats_service(struct Client *source_p) |
| 1131 |
+ |
{ |
| 1132 |
+ |
report_confitem_types(source_p, SERVICE_TYPE, 0); |
| 1133 |
+ |
} |
| 1134 |
+ |
|
| 1135 |
+ |
static void |
| 1136 |
|
stats_tstats(struct Client *source_p) |
| 1137 |
|
{ |
| 1138 |
< |
tstats(source_p); |
| 1138 |
> |
const struct Client *target_p = NULL; |
| 1139 |
> |
const dlink_node *ptr = NULL; |
| 1140 |
> |
struct ServerStatistics *sp; |
| 1141 |
> |
struct ServerStatistics tmp; |
| 1142 |
> |
|
| 1143 |
> |
sp = &tmp; |
| 1144 |
> |
memcpy(sp, &ServerStats, sizeof(struct ServerStatistics)); |
| 1145 |
> |
|
| 1146 |
> |
/* |
| 1147 |
> |
* must use the += operator. is_sv is not the number of currently |
| 1148 |
> |
* active server connections. Note the incrementation in |
| 1149 |
> |
* s_bsd.c:close_connection. |
| 1150 |
> |
*/ |
| 1151 |
> |
sp->is_sv += dlink_list_length(&serv_list); |
| 1152 |
> |
|
| 1153 |
> |
DLINK_FOREACH(ptr, serv_list.head) |
| 1154 |
> |
{ |
| 1155 |
> |
target_p = ptr->data; |
| 1156 |
> |
|
| 1157 |
> |
sp->is_sbs += target_p->localClient->send.bytes; |
| 1158 |
> |
sp->is_sbr += target_p->localClient->recv.bytes; |
| 1159 |
> |
sp->is_sti += CurrentTime - target_p->firsttime; |
| 1160 |
> |
} |
| 1161 |
> |
|
| 1162 |
> |
sp->is_cl += dlink_list_length(&local_client_list); |
| 1163 |
> |
|
| 1164 |
> |
DLINK_FOREACH(ptr, local_client_list.head) |
| 1165 |
> |
{ |
| 1166 |
> |
target_p = ptr->data; |
| 1167 |
> |
|
| 1168 |
> |
sp->is_cbs += target_p->localClient->send.bytes; |
| 1169 |
> |
sp->is_cbr += target_p->localClient->recv.bytes; |
| 1170 |
> |
sp->is_cti += CurrentTime - target_p->firsttime; |
| 1171 |
> |
} |
| 1172 |
> |
|
| 1173 |
> |
sp->is_ni += dlink_list_length(&unknown_list); |
| 1174 |
> |
|
| 1175 |
> |
sendto_one(source_p, ":%s %d %s T :accepts %u refused %u", |
| 1176 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref); |
| 1177 |
> |
sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u", |
| 1178 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf); |
| 1179 |
> |
sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u", |
| 1180 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni); |
| 1181 |
> |
sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u", |
| 1182 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt); |
| 1183 |
> |
sendto_one(source_p, ":%s %d %s T :numerics seen %u", |
| 1184 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_num); |
| 1185 |
> |
sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u", |
| 1186 |
> |
me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad); |
| 1187 |
> |
sendto_one(source_p, ":%s %d %s T :Client Server", |
| 1188 |
> |
me.name, RPL_STATSDEBUG, source_p->name); |
| 1189 |
> |
|
| 1190 |
> |
sendto_one(source_p, ":%s %d %s T :connected %u %u", |
| 1191 |
> |
me.name, RPL_STATSDEBUG, source_p->name, |
| 1192 |
> |
(unsigned int)sp->is_cl, |
| 1193 |
> |
(unsigned int)sp->is_sv); |
| 1194 |
> |
sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu", |
| 1195 |
> |
me.name, RPL_STATSDEBUG, source_p->name, |
| 1196 |
> |
sp->is_cbs, sp->is_sbs); |
| 1197 |
> |
sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu", |
| 1198 |
> |
me.name, RPL_STATSDEBUG, source_p->name, |
| 1199 |
> |
sp->is_cbr, sp->is_sbr); |
| 1200 |
> |
sendto_one(source_p, ":%s %d %s T :time connected %u %u", |
| 1201 |
> |
me.name, RPL_STATSDEBUG, source_p->name, |
| 1202 |
> |
(unsigned int)sp->is_cti, |
| 1203 |
> |
(unsigned int)sp->is_sti); |
| 1204 |
|
} |
| 1205 |
|
|
| 1206 |
|
static void |
| 1207 |
|
stats_uptime(struct Client *source_p) |
| 1208 |
|
{ |
| 1209 |
|
time_t now = CurrentTime - me.since; |
| 1210 |
+ |
|
| 1211 |
|
sendto_one(source_p, form_str(RPL_STATSUPTIME), from, to, |
| 1212 |
< |
now/86400, (now/3600)%24, (now/60)%60, now%60); |
| 1212 |
> |
now / 86400, (now / 3600) % 24, (now / 60) % 60, now % 60); |
| 1213 |
> |
|
| 1214 |
|
if (!ConfigFileEntry.disable_remote || IsOper(source_p)) |
| 1215 |
|
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
| 1216 |
< |
MaxConnectionCount, MaxClientCount, Count.totalrestartcount); |
| 1216 |
> |
Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount); |
| 1217 |
|
} |
| 1218 |
|
|
| 1219 |
|
static void |
| 1231 |
|
static void |
| 1232 |
|
stats_servers(struct Client *source_p) |
| 1233 |
|
{ |
| 1234 |
< |
struct Client *target_p; |
| 1143 |
< |
dlink_node *ptr; |
| 1144 |
< |
int j = 0; |
| 1234 |
> |
dlink_node *ptr = NULL; |
| 1235 |
|
|
| 1236 |
|
DLINK_FOREACH(ptr, serv_list.head) |
| 1237 |
|
{ |
| 1238 |
< |
target_p = ptr->data; |
| 1149 |
< |
|
| 1150 |
< |
j++; |
| 1238 |
> |
const struct Client *target_p = ptr->data; |
| 1239 |
|
|
| 1240 |
|
sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d", |
| 1241 |
< |
from, RPL_STATSDEBUG, to, |
| 1242 |
< |
target_p->name, |
| 1243 |
< |
(target_p->serv->by[0] ? target_p->serv->by : "Remote."), |
| 1156 |
< |
"*", "*", (int)(CurrentTime - target_p->lasttime)); |
| 1241 |
> |
from, RPL_STATSDEBUG, to, target_p->name, |
| 1242 |
> |
(target_p->serv->by[0] ? target_p->serv->by : "Remote."), |
| 1243 |
> |
"*", "*", (int)(CurrentTime - target_p->lasttime)); |
| 1244 |
|
} |
| 1245 |
|
|
| 1246 |
< |
sendto_one(source_p, ":%s %d %s v :%d Server(s)", |
| 1247 |
< |
from, RPL_STATSDEBUG, to, j); |
| 1246 |
> |
sendto_one(source_p, ":%s %d %s v :%u Server(s)", |
| 1247 |
> |
from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list)); |
| 1248 |
|
} |
| 1249 |
|
|
| 1250 |
|
static void |
| 1269 |
|
static void |
| 1270 |
|
stats_ziplinks(struct Client *source_p) |
| 1271 |
|
{ |
| 1272 |
< |
dlink_node *ptr; |
| 1186 |
< |
struct Client *target_p; |
| 1272 |
> |
dlink_node *ptr = NULL; |
| 1273 |
|
unsigned int sent_data = 0; |
| 1274 |
|
|
| 1275 |
|
DLINK_FOREACH(ptr, serv_list.head) |
| 1276 |
|
{ |
| 1277 |
< |
target_p = ptr->data; |
| 1277 |
> |
const struct Client *target_p = ptr->data; |
| 1278 |
|
|
| 1279 |
|
if (IsCapable(target_p, CAP_ZIP)) |
| 1280 |
|
{ |
| 1283 |
|
* -jmallett, 04/27/2002 |
| 1284 |
|
*/ |
| 1285 |
|
struct ZipStats zipstats; |
| 1286 |
< |
memcpy(&zipstats, &target_p->localClient->zipstats, sizeof (struct ZipStats)); |
| 1286 |
> |
|
| 1287 |
> |
memcpy(&zipstats, &target_p->localClient->zipstats, sizeof(zipstats)); |
| 1288 |
|
|
| 1289 |
|
sendto_one(source_p, ":%s %d %s Z :ZipLinks stats for %s send[%.2f%% " |
| 1290 |
< |
"compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% " |
| 1291 |
< |
"compression (%lu bytes data/%lu bytes wire)]", |
| 1290 |
> |
"compression (%llu bytes data/%llu bytes wire)] recv[%.2f%% " |
| 1291 |
> |
"compression (%llu bytes data/%llu bytes wire)]", |
| 1292 |
|
from, RPL_STATSDEBUG, to, target_p->name, |
| 1293 |
< |
zipstats.out_ratio, zipstats.out, zipstats.out_wire, |
| 1294 |
< |
zipstats.in_ratio, zipstats.in, zipstats.in_wire); |
| 1293 |
> |
zipstats.out_ratio, zipstats.out, zipstats.out_wire, |
| 1294 |
> |
zipstats.in_ratio, zipstats.in, zipstats.in_wire); |
| 1295 |
|
++sent_data; |
| 1296 |
|
} |
| 1297 |
|
} |
| 1305 |
|
{ |
| 1306 |
|
uint64_t sendB = 0, recvB = 0; |
| 1307 |
|
time_t uptime = 0; |
| 1308 |
< |
int j = 0; |
| 1222 |
< |
struct Client *target_p = NULL; |
| 1223 |
< |
dlink_node *ptr; |
| 1308 |
> |
dlink_node *ptr = NULL; |
| 1309 |
|
|
| 1310 |
|
if (ConfigServerHide.flatten_links && !IsOper(source_p)) |
| 1311 |
|
{ |
| 1316 |
|
|
| 1317 |
|
DLINK_FOREACH(ptr, serv_list.head) |
| 1318 |
|
{ |
| 1319 |
< |
target_p = ptr->data; |
| 1319 |
> |
struct Client *target_p = ptr->data; |
| 1320 |
|
|
| 1236 |
– |
++j; |
| 1321 |
|
sendB += target_p->localClient->send.bytes; |
| 1322 |
|
recvB += target_p->localClient->recv.bytes; |
| 1323 |
|
|
| 1339 |
|
recvB >>= 10; |
| 1340 |
|
|
| 1341 |
|
sendto_one(source_p, ":%s %d %s ? :%u total server(s)", |
| 1342 |
< |
from, RPL_STATSDEBUG, to, j); |
| 1342 |
> |
from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list)); |
| 1343 |
|
sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s", |
| 1344 |
|
from, RPL_STATSDEBUG, to, |
| 1345 |
< |
_GMKv((signed)sendB), _GMKs((signed)sendB)); |
| 1345 |
> |
_GMKv(sendB), _GMKs(sendB)); |
| 1346 |
|
sendto_one(source_p, ":%s %d %s ? :Recv total : %7.2f %s", |
| 1347 |
|
from, RPL_STATSDEBUG, to, |
| 1348 |
< |
_GMKv((signed)recvB), _GMKs((signed)recvB)); |
| 1348 |
> |
_GMKv(recvB), _GMKs(recvB)); |
| 1349 |
|
|
| 1350 |
|
uptime = (CurrentTime - me.since); |
| 1351 |
|
|
| 1352 |
|
sendto_one(source_p, ":%s %d %s ? :Server send: %7.2f %s (%4.1f K/s)", |
| 1353 |
|
from, RPL_STATSDEBUG, to, |
| 1354 |
< |
_GMKv((signed)(me.localClient->send.bytes>>10)), |
| 1355 |
< |
_GMKs((signed)(me.localClient->send.bytes>>10)), |
| 1356 |
< |
(float)((float)(((signed)me.localClient->send.bytes) >> 10) / |
| 1357 |
< |
(float)uptime)); |
| 1354 |
> |
_GMKv((me.localClient->send.bytes>>10)), |
| 1355 |
> |
_GMKs((me.localClient->send.bytes>>10)), |
| 1356 |
> |
(float)((float)((me.localClient->send.bytes) >> 10) / |
| 1357 |
> |
(float)uptime)); |
| 1358 |
|
sendto_one(source_p, ":%s %d %s ? :Server recv: %7.2f %s (%4.1f K/s)", |
| 1359 |
|
from, RPL_STATSDEBUG, to, |
| 1360 |
< |
_GMKv((signed)(me.localClient->recv.bytes>>10)), |
| 1361 |
< |
_GMKs((signed)(me.localClient->recv.bytes>>10)), |
| 1362 |
< |
(float)((float)(((signed)me.localClient->recv.bytes) >> 10) / |
| 1363 |
< |
(float)uptime)); |
| 1360 |
> |
_GMKv((me.localClient->recv.bytes>>10)), |
| 1361 |
> |
_GMKs((me.localClient->recv.bytes>>10)), |
| 1362 |
> |
(float)((float)((me.localClient->recv.bytes) >> 10) / |
| 1363 |
> |
(float)uptime)); |
| 1364 |
|
} |
| 1365 |
|
|
| 1366 |
|
static void |
| 1383 |
|
} |
| 1384 |
|
|
| 1385 |
|
/* |
| 1302 |
– |
* ms_stats - STATS message handler |
| 1303 |
– |
* parv[0] = sender prefix |
| 1304 |
– |
* parv[1] = statistics selector (defaults to Message frequency) |
| 1305 |
– |
* parv[2] = server name (current server defaulted, if omitted) |
| 1306 |
– |
*/ |
| 1307 |
– |
static void |
| 1308 |
– |
ms_stats(struct Client *client_p, struct Client *source_p, |
| 1309 |
– |
int parc, char *parv[]) |
| 1310 |
– |
{ |
| 1311 |
– |
if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME) |
| 1312 |
– |
return; |
| 1313 |
– |
|
| 1314 |
– |
if (IsClient(source_p)) |
| 1315 |
– |
mo_stats(client_p, source_p, parc, parv); |
| 1316 |
– |
} |
| 1317 |
– |
|
| 1318 |
– |
/* |
| 1386 |
|
* stats_L |
| 1387 |
|
* |
| 1388 |
|
* inputs - pointer to client to report to |