Make realname Kill blocks more predictable, and add username="x" field.
[ircu2.10.12-pk.git] / ircd / s_stats.c
index 1b332af99b78b708b09e39a314cd4a0acc904200..9714157616944cec13960e3df27ca664e79f2bb7 100644 (file)
@@ -24,6 +24,7 @@
 #include "class.h"
 #include "client.h"
 #include "gline.h"
+#include "hash.h"
 #include "ircd.h"
 #include "ircd_chattr.h"
 #include "ircd_events.h"
@@ -40,6 +41,7 @@
 #include "msgq.h"
 #include "numeric.h"
 #include "numnicks.h"
+#include "querycmds.h"
 #include "res.h"
 #include "s_bsd.h"
 #include "s_conf.h"
@@ -87,7 +89,7 @@ stats_configured_links(struct Client *sptr, const struct StatDesc* sd,
   struct ConfItem *tmp;
   unsigned short int port;
   int maximum;
-  char *host, *pass, *name, *hub_limit;
+  char *host, *pass, *name, *username, *hub_limit;
 
   for (tmp = GlobalConfList; tmp; tmp = tmp->next)
   {
@@ -96,17 +98,22 @@ stats_configured_links(struct Client *sptr, const struct StatDesc* sd,
       host = BadPtr(tmp->host) ? null : tmp->host;
       pass = BadPtr(tmp->passwd) ? null : tmp->passwd;
       name = BadPtr(tmp->name) ? null : tmp->name;
+      username = BadPtr(tmp->username) ? null : tmp->username;
       hub_limit = BadPtr(tmp->hub_limit) ? null : tmp->hub_limit;
       maximum = tmp->maximum;
       port = tmp->address.port;
+
       if (tmp->status & CONF_UWORLD)
-       send_reply(sptr, RPL_STATSULINE, name);
+       send_reply(sptr, RPL_STATSULINE, host);
       else if (tmp->status & CONF_SERVER)
-       send_reply(sptr, RPL_STATSCLINE, name, host, port, maximum, hub_limit, get_conf_class(tmp));
+       send_reply(sptr, RPL_STATSCLINE, name, "", "*", port, maximum, hub_limit, get_conf_class(tmp));
       else if (tmp->status & CONF_CLIENT)
-        send_reply(sptr, RPL_STATSILINE, host, maximum, name, port, get_conf_class(tmp));
+        send_reply(sptr, RPL_STATSILINE,
+                   (tmp->host ? tmp->host : "*"), maximum,
+                   (name[0] == ':' ? "0" : ""), (tmp->name ? tmp->name : "*"),
+                   port, get_conf_class(tmp));
       else if (tmp->status & CONF_OPERATOR)
-       send_reply(sptr, RPL_STATSOLINE, host, name, port, get_conf_class(tmp));
+       send_reply(sptr, RPL_STATSOLINE, username, host, name, get_conf_class(tmp));
     }
   }
 }
@@ -187,8 +194,11 @@ report_deny_list(struct Client* to)
 {
   const struct DenyConf* p = conf_get_deny_list();
   for ( ; p; p = p->next)
-    send_reply(to, RPL_STATSKLINE, (p->flags & DENY_FLAGS_IP) ? 'k' : 'K',
-               p->hostmask, p->message, p->usermask);
+    send_reply(to, RPL_STATSKLINE, p->bits > 0 ? 'k' : 'K',
+               p->usermask ? p->usermask : "*",
+               p->hostmask ? p->hostmask : "*",
+               p->message ? p->message : "(none)",
+               p->realmask ? p->realmask : "*");
 }
 
 /** Report K/k-lines to a user.
@@ -239,9 +249,11 @@ stats_klines(struct Client *sptr, const struct StatDesc *sd, char *mask)
         (wilds && !mmatch(host, conf->hostmask) &&
          (!user || !mmatch(user, conf->usermask))))
     {
-      send_reply(sptr, RPL_STATSKLINE,
-                 (conf->flags & DENY_FLAGS_IP) ? 'k' : 'K',
-                 conf->hostmask, conf->message, conf->usermask);
+      send_reply(sptr, RPL_STATSKLINE, conf->bits > 0 ? 'k' : 'K',
+                 conf->usermask ? conf->usermask : "*",
+                 conf->hostmask ? conf->hostmask : "*",
+                 conf->message ? conf->message : "(none)",
+                 conf->realmask ? conf->realmask : "*");
       if (--count == 0)
         return;
     }
@@ -451,7 +463,7 @@ stats_servers_verbose(struct Client* sptr, const struct StatDesc* sd,
                cli_serv(acptr)->asll_rtt,
                cli_serv(acptr)->asll_to,
                cli_serv(acptr)->asll_from,
-               cli_serv(acptr)->clients,
+               (acptr == &me ? UserStats.local_clients : cli_serv(acptr)->clients),
                cli_serv(acptr)->nn_mask,
                cli_serv(acptr)->prot,
                cli_serv(acptr)->timestamp,
@@ -518,9 +530,12 @@ struct StatDesc statsinfo[] = {
   { 'i', "access", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM), FEAT_HIS_STATS_i,
     stats_access, CONF_CLIENT,
     "Connection authorization lines." },
-  { 'j', "histogram", STAT_FLAG_OPERFEAT, FEAT_HIS_STATS_j,
+  { 'j', "histogram", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_j,
     msgq_histogram, 0,
     "Message length histogram." },
+  { 'J', "jupes", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_J,
+    stats_nickjupes, 0,
+    "Nickname jupes." },
   { 'k', "klines", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM), FEAT_HIS_STATS_k,
     stats_klines, 0,
     "Local bans (K-Lines)." },
@@ -560,7 +575,7 @@ struct StatDesc statsinfo[] = {
     "Local connection statistics (Total SND/RCV, etc)." },
   { 'U', "uworld", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_U,
     stats_configured_links, CONF_UWORLD,
-    "Service server & nick jupes information." },
+    "Service server information." },
   { 'u', "uptime", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_u,
     stats_uptime, 0,
     "Current uptime & highest connection count." },
@@ -614,7 +629,7 @@ stats_cmp(const void *a_, const void *b_)
 /** Compare a StatDesc's name against a string.
  * @param[in] key Pointer to a null-terminated string.
  * @param[in] sd_ Pointer to a StatDesc.
- * @return Less than,qual to, or greater than zero if \a key is
+ * @return Less than, equal to, or greater than zero if \a key is
  * lexicographically less than, equal to, or greater than \a
  * sd_->sd_name.
  */