Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / s_stats.c
index a26c0b2e2c6d8ce6cb31dc6a1c49ec1e170f1988..e966e46648e456d6fb0d636281ecd6f7f3ba5b59 100644 (file)
  *
  * $Id$
  */
+#include "config.h"
 
 #include "s_stats.h"
 #include "class.h"
 #include "client.h"
 #include "ircd.h"
 #include "ircd_chattr.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "listener.h"
@@ -71,10 +73,11 @@ const char *statsinfo[] = {
     "g - Global bans (G-lines).",
     "k - Local bans (K-Lines).",
     "o - Operator information.", 
+    "e - Report server event loop engine.",
+    "f - Feature settings.",
     "m - Message usage information.",
     "t - Local connection statistics (Total SND/RCV, etc).", 
     "w - Userload statistics.",
-    "v - Connection class information.",
     "M - Memory allocation & leak monitoring.", 
     "z - Memory/Structure allocation information.",
     "r - System resource usage (Debug only).", 
@@ -85,8 +88,6 @@ const char *statsinfo[] = {
 static unsigned int report_array[17][3] = {
   {CONF_SERVER, RPL_STATSCLINE, 'C'},
   {CONF_CLIENT, RPL_STATSILINE, 'I'},
-  {CONF_KILL, RPL_STATSKLINE, 'K'},
-  {CONF_IPKILL, RPL_STATSKLINE, 'k'},
   {CONF_LEAF, RPL_STATSLLINE, 'L'},
   {CONF_OPERATOR, RPL_STATSOLINE, 'O'},
   {CONF_HUB, RPL_STATSHLINE, 'H'},
@@ -123,9 +124,7 @@ void report_configured_links(struct Client *sptr, int mask)
        * displayed on STATS reply.    -Vesa
        */
       /* Special-case 'k' or 'K' lines as appropriate... -Kev */
-      if ((tmp->status & CONF_KLINE))
-       send_reply(sptr, p[1], c, host, pass, name, port, get_conf_class(tmp));
-      else if ((tmp->status & CONF_UWORLD))
+      if ((tmp->status & CONF_UWORLD))
        send_reply(sptr, p[1], c, host, pass, name, port, get_conf_class(tmp));
       else if ((tmp->status & (CONF_SERVER | CONF_HUB)))
        send_reply(sptr, p[1], c, "*", name, port, get_conf_class(tmp));
@@ -137,13 +136,15 @@ void report_configured_links(struct Client *sptr, int mask)
 
 /*
  *  {CONF_TLINES, RPL_STATSTLINE, 'T'},
+ *
+ * see now motd_report() in motd.c
  */
-void report_motd_list(struct Client* to)
-{
-  const struct MotdConf* conf = conf_get_motd_list();
-  for ( ; conf; conf = conf->next)
-    send_reply(to, RPL_STATSTLINE, 'T', conf->hostmask, conf->path);
-}
+/*  void report_motd_list(struct Client* to) */
+/*  { */
+/*    const struct MotdConf* conf = conf_get_motd_list(); */
+/*    for ( ; conf; conf = conf->next) */
+/*      send_reply(to, RPL_STATSTLINE, 'T', conf->hostmask, conf->path); */
+/*  } */
 
 /*
  * {CONF_CRULEALL, RPL_STATSDLINE, 'D'},
@@ -158,20 +159,38 @@ void report_crule_list(struct Client* to, int mask)
   }
 }
 
+/*
+ * {CONF_KILL, RPL_STATSKLINE, 'K'},
+ * {CONF_IPKILL, RPL_STATSKLINE, 'k'},
+ */
+void 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);
+}
+
 /* m_stats is so obnoxiously full of special cases that the different
  * hunt_server() possiblites were becoming very messy. It now uses a
  * switch() so as to be easier to read and update as params change. 
  * -Ghostwolf 
+ *
+ * 2.10.11: Don't check for the oper limitation if it's not our local server.
+ *          thusly once all the hubs have upgraded local opers will be able
+ *          to remote stats anywhere on the network.
  */
-int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[], char stat)
+int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[], char stat, int MustBeOper)
 {
   switch (stat)
   {
       /* open to all, standard # of params */
     case 'U':
     case 'u':
-      return hunt_server_cmd(sptr, CMD_STATS, cptr, 0, "%s :%C", 2, parc,
-                            parv);
+    case 'F':
+    case 'f':
+      return hunt_server_cmd(sptr, CMD_STATS, cptr, MustBeOper, "%s :%C", 2,
+                            parc, parv);
 
     /* open to all, varying # of params */
     case 'k':
@@ -182,9 +201,11 @@ int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[],
     case 'P':
     {
       if (parc > 3)
-       return hunt_server_cmd(sptr, CMD_STATS, cptr, 0, "%s %C :%s", 2, parc, parv);
+       return hunt_server_cmd(sptr, CMD_STATS, cptr, MustBeOper, "%s %C :%s",
+                              2, parc, parv);
       else
-       return hunt_server_cmd(sptr, CMD_STATS, cptr, 0, "%s :%C", 2, parc, parv);
+       return hunt_server_cmd(sptr, CMD_STATS, cptr, MustBeOper, "%s :%C", 2,
+                              parc, parv);
     }
 
       /* oper only, varying # of params */
@@ -193,16 +214,24 @@ int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[],
     case 'M':
     {
       if (parc == 4)
-       return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s %C :%s", 2, parc, parv);
+       return hunt_server_cmd(sptr, CMD_STATS, cptr,
+                              MyUser(sptr) ? 1 : MustBeOper, "%s %C :%s", 2,
+                              parc, parv);
       else if (parc > 4)
-       return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s %C %s :%s", 2, parc, parv);
+       return hunt_server_cmd(sptr, CMD_STATS, cptr,
+                              MyUser(sptr) ? 1 : MustBeOper, "%s %C %s :%s",
+                              2, parc, parv);
       else 
-       return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s :%C", 2, parc, parv);
+       return hunt_server_cmd(sptr, CMD_STATS, cptr,
+                              MyUser(sptr) ? 1 : MustBeOper, "%s :%C", 2,
+                              parc, parv);
     }
 
       /* oper only, standard # of params */
     default:
-      return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s :%C", 2, parc, parv);
+      return hunt_server_cmd(sptr, CMD_STATS, cptr,
+                            MyUser(sptr) ? 1 : MustBeOper, "%s :%C", 2, parc,
+                            parv);
   }
 }