diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-04-30 15:10:13 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-04-30 15:10:13 +0000 |
commit | 7ba5d74ff6ca48eb7d3c1cd1e3c826c807f392a1 (patch) | |
tree | ac9b96b41fd72d4827fcc71e0f09134d5d1cde4c /modules | |
parent | d26de8291af33189524cf17ae3ec730aadba6c0c (diff) |
- Moved report_confitem_types() to m_stats.c
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@1923 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'modules')
-rw-r--r-- | modules/m_stats.c | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/modules/m_stats.c b/modules/m_stats.c index 6395d53..fcd996d 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -52,6 +52,199 @@ const char *from, *to; +static const struct shared_flags +{ + const unsigned int type; + const unsigned char letter; +} flag_table[] = { + { SHARED_KLINE, 'K' }, + { SHARED_UNKLINE, 'U' }, + { SHARED_XLINE, 'X' }, + { SHARED_UNXLINE, 'Y' }, + { SHARED_RESV, 'Q' }, + { SHARED_UNRESV, 'R' }, + { SHARED_LOCOPS, 'L' }, + { SHARED_DLINE, 'D' }, + { SHARED_UNDLINE, 'E' }, + { 0, '\0' } +}; + +/* + * inputs - pointer to client requesting confitem report + * - ConfType to report + * output - none + * side effects - + */ +static void +report_confitem_types(struct Client *source_p, enum maskitem_type type) +{ + dlink_node *ptr = NULL, *dptr = NULL; + struct MaskItem *conf = NULL; + const struct ClassItem *class = NULL; + const struct shared_flags *shared = NULL; + char buf[12]; + char *p = NULL; + + switch (type) + { + case CONF_XLINE: + DLINK_FOREACH(ptr, xconf_items.head) + { + conf = ptr->data; + + sendto_one(source_p, form_str(RPL_STATSXLINE), + me.name, source_p->name, + conf->until ? 'x': 'X', conf->count, + conf->name, conf->reason); + } + break; + + case CONF_ULINE: + shared = flag_table; + DLINK_FOREACH(ptr, uconf_items.head) + { + conf = ptr->data; + + p = buf; + + *p++ = 'c'; + for (; shared->type; ++shared) + if (shared->type & conf->flags) + *p++ = shared->letter; + else + *p++ = ToLower(shared->letter); + + sendto_one(source_p, form_str(RPL_STATSULINE), + me.name, source_p->name, conf->name, + conf->user?conf->user: "*", + conf->host?conf->host: "*", buf); + } + + shared = flag_table; + DLINK_FOREACH(ptr, cluster_items.head) + { + conf = ptr->data; + + p = buf; + + *p++ = 'C'; + for (; shared->type; ++shared) + if (shared->type & conf->flags) + *p++ = shared->letter; + else + *p++ = ToLower(shared->letter); + + sendto_one(source_p, form_str(RPL_STATSULINE), + me.name, source_p->name, conf->name, + "*", "*", buf); + } + + break; + + case CONF_OPER: + DLINK_FOREACH(ptr, oconf_items.head) + { + conf = ptr->data; + + /* Don't allow non opers to see oper privs */ + if (HasUMode(source_p, UMODE_OPER)) + sendto_one(source_p, form_str(RPL_STATSOLINE), + me.name, source_p->name, 'O', conf->user, conf->host, + conf->name, oper_privs_as_string(conf->port), + conf->class ? conf->class->name : "<default>"); + else + sendto_one(source_p, form_str(RPL_STATSOLINE), + me.name, source_p->name, 'O', conf->user, conf->host, + conf->name, "0", + conf->class ? conf->class->name : "<default>"); + } + break; + + case CONF_CLASS: + DLINK_FOREACH(ptr, class_get_list()->head) + { + class = ptr->data; + sendto_one(source_p, form_str(RPL_STATSYLINE), + me.name, source_p->name, 'Y', + class->name, class->ping_freq, + class->con_freq, + class->max_total, class->max_sendq, + class->max_recvq, + class->ref_count, + class->number_per_cidr, class->cidr_bitlen_ipv4, + class->number_per_cidr, class->cidr_bitlen_ipv6, + class->active ? "active" : "disabled"); + } + break; + + case CONF_SERVICE: + DLINK_FOREACH(ptr, service_items.head) + { + conf = ptr->data; + sendto_one(source_p, form_str(RPL_STATSSERVICE), + me.name, source_p->name, 'S', "*", conf->name, 0, 0); + } + break; + + case CONF_SERVER: + DLINK_FOREACH(ptr, server_items.head) + { + p = buf; + conf = ptr->data; + + buf[0] = '\0'; + + if (IsConfAllowAutoConn(conf)) + *p++ = 'A'; + if (IsConfSSL(conf)) + *p++ = 'S'; + if (buf[0] == '\0') + *p++ = '*'; + + *p = '\0'; + + /* + * Allow admins to see actual ips unless hide_server_ips is enabled + */ + if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) + sendto_one(source_p, form_str(RPL_STATSCLINE), + me.name, source_p->name, 'C', conf->host, + buf, conf->name, conf->port, + conf->class ? conf->class->name : "<default>"); + else + sendto_one(source_p, form_str(RPL_STATSCLINE), + me.name, source_p->name, 'C', + "*@127.0.0.1", buf, conf->name, conf->port, + conf->class ? conf->class->name : "<default>"); + } + break; + + case CONF_HUB: + DLINK_FOREACH(ptr, server_items.head) + { + conf = ptr->data; + + DLINK_FOREACH(dptr, conf->hub_list.head) + sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, + source_p->name, 'H', dptr->data, conf->name, 0, "*"); + } + + DLINK_FOREACH(ptr, server_items.head) + { + conf = ptr->data; + + DLINK_FOREACH(dptr, conf->leaf_list.head) + sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, + source_p->name, 'L', dptr->data, conf->name, 0, "*"); + } + + break; + + default: + break; + } +} + /* * This is part of the STATS replies. There is no offical numeric for this * since this isnt an official command, in much the same way as HASH isnt. |