#include "hash.h"
#include "reject.h"
#include "whowas.h"
+#include "irc_radixtree.h"
+#include "sslproc.h"
-static int m_stats (struct Client *, struct Client *, int, const char **);
+static int m_stats (struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message stats_msgtab = {
- "STATS", 0, 0, 0, MFLG_SLOW,
+ "STATS", 0, 0, 0, 0,
{mg_unreg, {m_stats, 2}, {m_stats, 3}, mg_ignore, mg_ignore, {m_stats, 2}}
};
static void stats_l_client(struct Client *source_p, struct Client *target_p,
char statchar);
-static void stats_spy(struct Client *, char, const char *);
+static int stats_spy(struct Client *, char, const char *);
static void stats_p_spy(struct Client *);
/* Heres our struct for the stats table */
static void stats_ports(struct Client *);
static void stats_tresv(struct Client *);
static void stats_resv(struct Client *);
+static void stats_ssld(struct Client *);
static void stats_usage(struct Client *);
static void stats_tstats(struct Client *);
static void stats_uptime(struct Client *);
{'Q', stats_resv, 1, 0, },
{'r', stats_usage, 1, 0, },
{'R', stats_usage, 1, 0, },
+ {'s', stats_ssld, 1, 1, },
+ {'S', stats_ssld, 1, 1, },
{'t', stats_tstats, 1, 0, },
{'T', stats_tstats, 1, 0, },
{'u', stats_uptime, 0, 0, },
* if found execute it.
*/
static int
-m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_stats(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static time_t last_used = 0;
int i;
char statchar;
+ int did_stats = 0;
statchar = parv[1][0];
return 0;
if((statchar != 'L') && (statchar != 'l'))
- stats_spy(source_p, statchar, NULL);
+ did_stats = stats_spy(source_p, statchar, NULL);
+
+ /* if did_stats is true, a module grabbed this STATS request */
+ if (did_stats)
+ goto stats_out;
for (i = 0; stats_cmd_table[i].letter; i++)
{
}
}
+stats_out:
/* Send the end of stats notice, and the stats_spy */
sendto_one_numeric(source_p, RPL_ENDOFSTATS,
form_str(RPL_ENDOFSTATS), statchar);
}
}
+static void
+stats_hash_cb(const char *buf, void *client_p)
+{
+ sendto_one_numeric(client_p, RPL_STATSDEBUG, "B :%s", buf);
+}
+
static void
stats_hash(struct Client *source_p)
{
- hash_stats(source_p);
+ sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :%-30s %-15s %-10s %-10s %-10s %-10s",
+ "NAME", "TYPE", "OBJECTS", "DEPTH SUM", "AVG DEPTH", "MAX DEPTH");
+
+ irc_dictionary_stats_walk(stats_hash_cb, source_p);
+ irc_radixtree_stats_walk(stats_hash_cb, source_p);
}
static void
static void
stats_exempt(struct Client *source_p)
{
- char *name, *host, *pass, *user, *classname;
+ char *name, *host, *user, *classname;
+ const char *pass;
struct AddressRec *arec;
struct ConfItem *aconf;
int i, port;
else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p))
{
struct ConfItem *aconf;
- char *name, *host, *pass = "*", *user, *classname;
+ char *name, *host, *user, *classname;
+ const char *pass = "*";
int port;
if(MyConnect (source_p))
}
}
+/* report_Klines()
+ *
+ * inputs - Client to report to, mask
+ * outputs -
+ * side effects - Reports configured K-lines to client_p.
+ */
+static void
+report_Klines(struct Client *source_p)
+{
+ char *host, *pass, *user, *oper_reason;
+ struct AddressRec *arec;
+ struct ConfItem *aconf = NULL;
+ int i;
+
+ for (i = 0; i < ATABLE_SIZE; i++)
+ {
+ for (arec = atable[i]; arec; arec = arec->next)
+ {
+ if(arec->type == CONF_KILL)
+ {
+ aconf = arec->aconf;
+
+ /* its a tempkline, theyre reported elsewhere */
+ if(aconf->flags & CONF_FLAGS_TEMPORARY)
+ continue;
+
+ get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
+ sendto_one_numeric(source_p, RPL_STATSKLINE,
+ form_str(RPL_STATSKLINE),
+ 'K', host, user, pass,
+ oper_reason ? "|" : "",
+ oper_reason ? oper_reason : "");
+ }
+ }
+ }
+}
+
static void
stats_klines(struct Client *source_p)
{
stats_tresv(struct Client *source_p)
{
struct ConfItem *aconf;
+ struct irc_radixtree_iteration_state state;
rb_dlink_node *ptr;
int i;
'q', aconf->port, aconf->host, aconf->passwd);
}
- HASH_WALK(i, R_MAX, ptr, resvTable)
+ IRC_RADIXTREE_FOREACH(aconf, &state, resv_tree)
{
- aconf = ptr->data;
if(aconf->hold)
sendto_one_numeric(source_p, RPL_STATSQLINE,
form_str(RPL_STATSQLINE),
'q', aconf->port, aconf->host, aconf->passwd);
}
- HASH_WALK_END
}
stats_resv(struct Client *source_p)
{
struct ConfItem *aconf;
+ struct irc_radixtree_iteration_state state;
rb_dlink_node *ptr;
int i;
'Q', aconf->port, aconf->host, aconf->passwd);
}
- HASH_WALK(i, R_MAX, ptr, resvTable)
+ IRC_RADIXTREE_FOREACH(aconf, &state, resv_tree)
{
- aconf = ptr->data;
if(!aconf->hold)
sendto_one_numeric(source_p, RPL_STATSQLINE,
form_str(RPL_STATSQLINE),
'Q', aconf->port, aconf->host, aconf->passwd);
}
- HASH_WALK_END
+}
+
+static void
+stats_ssld_foreach(void *data, pid_t pid, int cli_count, enum ssld_status status)
+{
+ struct Client *source_p = data;
+
+ sendto_one_numeric(source_p, RPL_STATSDEBUG,
+ "S :%u %c %u",
+ pid,
+ status == SSLD_DEAD ? 'D' : (status == SSLD_SHUTDOWN ? 'S' : 'A'),
+ cli_count);
+}
+
+static void
+stats_ssld(struct Client *source_p)
+{
+#if 0
+ ssld_foreach_info(stats_ssld_foreach, source_p);
+#endif
}
static void
{ SHARED_TDLINE, 'd' },
{ SHARED_PDLINE, 'D' },
{ SHARED_UNDLINE, 'E' },
+ { SHARED_GRANT, 'G' },
+ { SHARED_DIE, 'I' },
{ 0, '\0'}
};
size_t total_memory = 0;
- count_whowas_memory(&ww, &wwm);
+ whowas_memory_usage(&ww, &wwm);
RB_DLINK_FOREACH(ptr, global_client_list.head)
{
* any damage with stats requests now anyway. So, why show them?
* -Dianora
*/
-static void
+static int
stats_spy(struct Client *source_p, char statchar, const char *name)
{
hook_data_int data;
data.client = source_p;
data.arg1 = name;
data.arg2 = (int) statchar;
+ data.result = 0;
call_hook(doing_stats_hook, &data);
+
+ return data.result;
}
/* stats_p_spy()