#include "s_serv.h" /* hunt_server */
#include "s_stats.h"
#include "s_user.h" /* show_opers */
-#include "blacklist.h" /* dnsbl stuff */
#include "parse.h"
#include "modules.h"
#include "hook.h"
#include "whowas.h"
#include "rb_radixtree.h"
#include "sslproc.h"
+#include "s_assert.h"
static const char stats_desc[] =
"Provides the STATS command to inspect various server/network information";
static void stats_comm(struct Client *);
static void stats_capability(struct Client *);
+#define HANDLER_NORM(fn, oper, admin) { { .handler = fn }, false, oper, admin }
+#define HANDLER_PARV(fn, oper, admin) { { .handler_parv = fn }, true, oper, admin }
+
/* This table contains the possible stats items, in order:
* stats letter, function to call, operonly? adminonly? --fl_
*
* --Elizafox
*/
static struct stats_cmd stats_cmd_table[256] = {
-/* letter handler/handler_parv parv oper admin */
- ['a'] = { { stats_dns_servers }, false, true, true, },
- ['A'] = { { stats_dns_servers }, false, true, true, },
- ['b'] = { { stats_delay }, false, true, true, },
- ['B'] = { { stats_hash }, false, true, true, },
- ['c'] = { { stats_connect }, false, false, false, },
- ['C'] = { { stats_capability }, false, true, false, },
- ['d'] = { { stats_tdeny }, false, true, false, },
- ['D'] = { { stats_deny }, false, true, false, },
- ['e'] = { { stats_exempt }, false, true, false, },
- ['E'] = { { stats_events }, false, true, true, },
- ['f'] = { { stats_comm }, false, true, true, },
- ['F'] = { { stats_comm }, false, true, true, },
- ['g'] = { { stats_prop_klines }, false, true, false, },
- ['h'] = { { stats_hubleaf }, false, false, false, },
- ['H'] = { { stats_hubleaf }, false, false, false, },
- ['i'] = { { stats_auth }, false, false, false, },
- ['I'] = { { stats_auth }, false, false, false, },
- ['k'] = { { stats_tklines }, false, false, false, },
- ['K'] = { { stats_klines }, false, false, false, },
- ['l'] = { { .handler_parv = stats_ltrace }, true, false, false, },
- ['L'] = { { .handler_parv = stats_ltrace }, true, false, false, },
- ['m'] = { { stats_messages }, false, false, false, },
- ['M'] = { { stats_messages }, false, false, false, },
- ['n'] = { { stats_dnsbl }, false, false, false, },
- ['o'] = { { stats_oper }, false, false, false, },
- ['O'] = { { stats_privset }, false, true, false, },
- ['p'] = { { stats_operedup }, false, false, false, },
- ['P'] = { { stats_ports }, false, false, false, },
- ['q'] = { { stats_tresv }, false, true, false, },
- ['Q'] = { { stats_resv }, false, true, false, },
- ['r'] = { { stats_usage }, false, true, false, },
- ['R'] = { { stats_usage }, false, true, false, },
- ['s'] = { { stats_ssld }, false, true, true, },
- ['S'] = { { stats_ssld }, false, true, true, },
- ['t'] = { { stats_tstats }, false, true, false, },
- ['T'] = { { stats_tstats }, false, true, false, },
- ['u'] = { { stats_uptime }, false, false, false, },
- ['U'] = { { stats_shared }, false, true, false, },
- ['v'] = { { stats_servers }, false, false, false, },
- ['V'] = { { stats_servers }, false, false, false, },
- ['x'] = { { stats_tgecos }, false, true, false, },
- ['X'] = { { stats_gecos }, false, true, false, },
- ['y'] = { { stats_class }, false, false, false, },
- ['Y'] = { { stats_class }, false, false, false, },
- ['z'] = { { stats_memory }, false, true, false, },
- ['Z'] = { { stats_ziplinks }, false, true, false, },
- ['?'] = { { stats_servlinks }, false, false, false, },
+/* letter handler oper admin */
+ ['a'] = HANDLER_NORM(stats_dns_servers, true, true),
+ ['A'] = HANDLER_NORM(stats_dns_servers, true, true),
+ ['b'] = HANDLER_NORM(stats_delay, true, true),
+ ['B'] = HANDLER_NORM(stats_hash, true, true),
+ ['c'] = HANDLER_NORM(stats_connect, false, false),
+ ['C'] = HANDLER_NORM(stats_capability, true, false),
+ ['d'] = HANDLER_NORM(stats_tdeny, true, false),
+ ['D'] = HANDLER_NORM(stats_deny, true, false),
+ ['e'] = HANDLER_NORM(stats_exempt, true, false),
+ ['E'] = HANDLER_NORM(stats_events, true, true),
+ ['f'] = HANDLER_NORM(stats_comm, true, true),
+ ['F'] = HANDLER_NORM(stats_comm, true, true),
+ ['g'] = HANDLER_NORM(stats_prop_klines, true, false),
+ ['h'] = HANDLER_NORM(stats_hubleaf, false, false),
+ ['H'] = HANDLER_NORM(stats_hubleaf, false, false),
+ ['i'] = HANDLER_NORM(stats_auth, false, false),
+ ['I'] = HANDLER_NORM(stats_auth, false, false),
+ ['k'] = HANDLER_NORM(stats_tklines, false, false),
+ ['K'] = HANDLER_NORM(stats_klines, false, false),
+ ['l'] = HANDLER_PARV(stats_ltrace, false, false),
+ ['L'] = HANDLER_PARV(stats_ltrace, false, false),
+ ['m'] = HANDLER_NORM(stats_messages, false, false),
+ ['M'] = HANDLER_NORM(stats_messages, false, false),
+ ['n'] = HANDLER_NORM(stats_dnsbl, false, false),
+ ['o'] = HANDLER_NORM(stats_oper, false, false),
+ ['O'] = HANDLER_NORM(stats_privset, true, false),
+ ['p'] = HANDLER_NORM(stats_operedup, false, false),
+ ['P'] = HANDLER_NORM(stats_ports, false, false),
+ ['q'] = HANDLER_NORM(stats_tresv, true, false),
+ ['Q'] = HANDLER_NORM(stats_resv, true, false),
+ ['r'] = HANDLER_NORM(stats_usage, true, false),
+ ['R'] = HANDLER_NORM(stats_usage, true, false),
+ ['s'] = HANDLER_NORM(stats_ssld, true, true),
+ ['S'] = HANDLER_NORM(stats_ssld, true, true),
+ ['t'] = HANDLER_NORM(stats_tstats, true, false),
+ ['T'] = HANDLER_NORM(stats_tstats, true, false),
+ ['u'] = HANDLER_NORM(stats_uptime, false, false),
+ ['U'] = HANDLER_NORM(stats_shared, true, false),
+ ['v'] = HANDLER_NORM(stats_servers, false, false),
+ ['V'] = HANDLER_NORM(stats_servers, false, false),
+ ['x'] = HANDLER_NORM(stats_tgecos, true, false),
+ ['X'] = HANDLER_NORM(stats_gecos, true, false),
+ ['y'] = HANDLER_NORM(stats_class, false, false),
+ ['Y'] = HANDLER_NORM(stats_class, false, false),
+ ['z'] = HANDLER_NORM(stats_memory, true, false),
+ ['Z'] = HANDLER_NORM(stats_ziplinks, true, false),
+ ['?'] = HANDLER_NORM(stats_servlinks, false, false),
};
/*
static void
stats_connect(struct Client *source_p)
{
- static char buf[5];
+ static char buf[BUFSIZE];
struct server_conf *server_p;
char *s;
rb_dlink_node *ptr;
{
if(ServerConfAutoconn(server_p))
*s++ = 'A';
+ if(ServerConfSCTP(server_p))
+ *s++ = 'M';
if(ServerConfSSL(server_p))
*s++ = 'S';
if(ServerConfTb(server_p))
form_str(RPL_STATSCLINE),
"*@127.0.0.1",
buf, server_p->name,
- server_p->port, server_p->class_name);
+ server_p->port, server_p->class_name,
+ server_p->certfp ? server_p->certfp : "*");
}
}
get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
sendto_one_numeric(source_p, RPL_STATSKLINE,
- form_str(RPL_STATSKLINE), aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K',
+ form_str(RPL_STATSKLINE), (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
host, user, pass, oper_reason ? "|" : "",
oper_reason ? oper_reason : "");
}
get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
sendto_one_numeric(source_p, RPL_STATSKLINE, form_str(RPL_STATSKLINE),
- aconf->flags & CONF_FLAGS_TEMPORARY ? 'k' : 'K',
+ (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
host, user, pass, oper_reason ? "|" : "",
oper_reason ? oper_reason : "");
}
{
rb_dictionary_iter iter;
struct Message *msg;
- struct alias_entry *amsg;
RB_DICTIONARY_FOREACH(msg, &iter, cmd_dict)
{
msg->cmd, msg->count,
msg->bytes, msg->rcount);
}
-
- RB_DICTIONARY_FOREACH(amsg, &iter, alias_dict)
- {
- s_assert(amsg->name != NULL);
- sendto_one_numeric(source_p, RPL_STATSCOMMANDS,
- form_str(RPL_STATSCOMMANDS),
- amsg->name, amsg->hits, 0L, 0);
- }
}
static void
stats_dnsbl(struct Client *source_p)
{
- rb_dlink_node *ptr;
- struct Blacklist *blptr;
+ rb_dictionary_iter iter;
+ struct BlacklistStats *stats;
- RB_DLINK_FOREACH(ptr, blacklist_list.head)
- {
- blptr = ptr->data;
+ if(bl_stats == NULL)
+ return;
+ RB_DICTIONARY_FOREACH(stats, &iter, bl_stats)
+ {
/* use RPL_STATSDEBUG for now -- jilles */
- sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s %s (%d)",
- blptr->hits,
- blptr->host,
- blptr->status & CONF_ILLEGAL ? "disabled" : "active",
- blptr->refcount);
+ sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s",
+ stats->hits, (const char *)iter.cur->key);
}
}
{
target_p = oper_ptr->data;
- if(IsOperInvis(target_p) && !IsOper(source_p))
+ if(!SeesOper(target_p, source_p))
continue;
if(target_p->user->away)