]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_trace.c
Remove obsolete comment.
[irc/rqf/shadowircd.git] / modules / m_trace.c
index 3d62f68592122e01747fd39bc92ceabcb6fcf5f3..603922e6fe781111ccbbfae83cd898a30af5fa47 100644 (file)
 #include "hash.h"
 #include "common.h"
 #include "hash.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_serv.h"
 #include "s_conf.h"
 #include "s_newconf.h"
@@ -62,11 +61,12 @@ mapi_hlist_av1 trace_hlist[] = {
 DECLARE_MODULE_AV1(trace, NULL, NULL, trace_clist, trace_hlist, NULL, "$Revision: 3183 $");
 
 static void count_downlinks(struct Client *server_p, int *pservcount, int *pusercount);
-static int report_this_status(struct Client *source_p, struct Client *target_p, int dow);
+static int report_this_status(struct Client *source_p, struct Client *target_p);
+
+static const char *empty_sockhost = "255.255.255.255";
 
 /*
  * m_trace
- *      parv[0] = sender prefix
  *      parv[1] = servername
  */
 static int
@@ -77,7 +77,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
        const char *tname;
        int doall = 0;
        int cnt = 0, wilds, dow;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
 
        if(parc > 1)
        {
@@ -111,7 +111,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
 
                        if(ac2ptr == NULL)
                        {
-                               DLINK_FOREACH(ptr, global_client_list.head)
+                               RB_DLINK_FOREACH(ptr, global_client_list.head)
                                {
                                        ac2ptr = ptr->data;
 
@@ -173,7 +173,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                 */
                if(target_p != NULL)
                {
-                       report_this_status(source_p, target_p, 0);
+                       report_this_status(source_p, target_p);
                        tname = target_p->name;
                }
 
@@ -194,29 +194,29 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                if(MyClient(source_p))
                {
                        if(doall || (wilds && match(tname, source_p->name)))
-                               report_this_status(source_p, source_p, 0);
+                               report_this_status(source_p, source_p);
                }
 
-               DLINK_FOREACH(ptr, local_oper_list.head)
+               RB_DLINK_FOREACH(ptr, local_oper_list.head)
                {
                        target_p = ptr->data;
 
                        if(!doall && wilds && (match(tname, target_p->name) == 0))
                                continue;
 
-                       report_this_status(source_p, target_p, 0);
+                       report_this_status(source_p, target_p);
                }
 
                if (IsExemptShide(source_p) || !ConfigServerHide.flatten_links)
                {
-                       DLINK_FOREACH(ptr, serv_list.head)
+                       RB_DLINK_FOREACH(ptr, serv_list.head)
                        {
                                target_p = ptr->data;
 
                                if(!doall && wilds && !match(tname, target_p->name))
                                        continue;
 
-                               report_this_status(source_p, target_p, 0);
+                               report_this_status(source_p, target_p);
                        }
                }
 
@@ -228,7 +228,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
        /* source_p is opered */
 
        /* report all direct connections */
-       DLINK_FOREACH(ptr, lclient_list.head)
+       RB_DLINK_FOREACH(ptr, lclient_list.head)
        {
                target_p = ptr->data;
 
@@ -239,29 +239,34 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                if(!doall && wilds && !match(tname, target_p->name))
                        continue;
 
-               cnt = report_this_status(source_p, target_p, dow);
+               /* remote opers may not see invisible normal users */
+               if(dow && !MyConnect(source_p) && !IsOper(target_p) &&
+                               IsInvisible(target_p))
+                       continue;
+
+               cnt = report_this_status(source_p, target_p);
        }
 
-       DLINK_FOREACH(ptr, serv_list.head)
+       RB_DLINK_FOREACH(ptr, serv_list.head)
        {
                target_p = ptr->data;
 
                if(!doall && wilds && !match(tname, target_p->name))
                        continue;
 
-               cnt = report_this_status(source_p, target_p, dow);
+               cnt = report_this_status(source_p, target_p);
        }
 
        if(MyConnect(source_p))
        {
-               DLINK_FOREACH(ptr, unknown_list.head)
+               RB_DLINK_FOREACH(ptr, unknown_list.head)
                {
                        target_p = ptr->data;
 
                        if(!doall && wilds && !match(tname, target_p->name))
                                continue;
 
-                       cnt = report_this_status(source_p, target_p, dow);
+                       cnt = report_this_status(source_p, target_p);
                }
        }
 
@@ -280,7 +285,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
 
        if(doall)
        {
-               DLINK_FOREACH(ptr, class_list.head)
+               RB_DLINK_FOREACH(ptr, class_list.head)
                {
                        cltmp = ptr->data;
 
@@ -307,11 +312,11 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
 static void
 count_downlinks(struct Client *server_p, int *pservcount, int *pusercount)
 {
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
 
        (*pservcount)++;
-       *pusercount += dlink_list_length(&server_p->serv->users);
-       DLINK_FOREACH(ptr, server_p->serv->servers.head)
+       *pusercount += rb_dlink_list_length(&server_p->serv->users);
+       RB_DLINK_FOREACH(ptr, server_p->serv->servers.head)
        {
                count_downlinks(ptr->data, pservcount, pusercount);
        }
@@ -326,8 +331,7 @@ count_downlinks(struct Client *server_p, int *pservcount, int *pusercount)
  * side effects - NONE
  */
 static int
-report_this_status(struct Client *source_p, struct Client *target_p,
-                  int dow)
+report_this_status(struct Client *source_p, struct Client *target_p)
 {
        const char *name;
        const char *class_name;
@@ -338,11 +342,11 @@ report_this_status(struct Client *source_p, struct Client *target_p,
        if(!MyConnect(target_p))
                return 0;
 
-       inetntop_sock((struct sockaddr *)&target_p->localClient->ip, ip, sizeof(ip));
+       rb_inet_ntop_sock((struct sockaddr *)&target_p->localClient->ip, ip, sizeof(ip));
        class_name = get_client_class(target_p);
 
        if(IsAnyServer(target_p))
-               name = get_server_name(target_p, HIDE_IP);
+               name = target_p->name;
        else
                name = get_client_name(target_p, HIDE_IP);
 
@@ -370,33 +374,21 @@ report_this_status(struct Client *source_p, struct Client *target_p,
                sendto_one_numeric(source_p, RPL_TRACEUNKNOWN,
                                   form_str(RPL_TRACEUNKNOWN),
                                   class_name, name, ip,
-                                  CurrentTime - target_p->localClient->firsttime);
+                                  rb_current_time() - target_p->localClient->firsttime);
                cnt++;
                break;
 
        case STAT_CLIENT:
-               /* Only opers see users if there is a wildcard
-                * but anyone can see all the opers.
-                */
-               if((IsOper(source_p) &&
-                   (MyClient(source_p) || !(dow && IsInvisible(target_p))))
-                  || !dow || IsOper(target_p) || (source_p == target_p))
                {
-                       if(IsOper(target_p))
-                               sendto_one_numeric(source_p, RPL_TRACEOPERATOR,
-                                                  form_str(RPL_TRACEOPERATOR),
-                                                  class_name, name,
-                                                  show_ip(source_p, target_p) ? ip : "255.255.255.255",
-                                                  CurrentTime - target_p->localClient->lasttime,
-                                                  CurrentTime - target_p->localClient->last);
+                       int tnumeric;
+
+                       tnumeric = IsOper(target_p) ? RPL_TRACEOPERATOR : RPL_TRACEUSER;
+                       sendto_one_numeric(source_p, tnumeric, form_str(tnumeric),
+                                       class_name, name,
+                                       show_ip(source_p, target_p) ? ip : empty_sockhost,
+                                       rb_current_time() - target_p->localClient->lasttime,
+                                       rb_current_time() - target_p->localClient->last);
 
-                       else
-                               sendto_one_numeric(source_p, RPL_TRACEUSER, 
-                                                  form_str(RPL_TRACEUSER),
-                                                  class_name, name,
-                                                  show_ip(source_p, target_p) ? ip : "255.255.255.255",
-                                                  CurrentTime - target_p->localClient->lasttime,
-                                                  CurrentTime - target_p->localClient->last);
                        cnt++;
                }
                break;
@@ -411,7 +403,7 @@ report_this_status(struct Client *source_p, struct Client *target_p,
                        sendto_one_numeric(source_p, RPL_TRACESERVER, form_str(RPL_TRACESERVER),
                                   class_name, servcount, usercount, name,
                                   *(target_p->serv->by) ? target_p->serv->by : "*", "*",
-                                  me.name, CurrentTime - target_p->localClient->lasttime);
+                                  me.name, rb_current_time() - target_p->localClient->lasttime);
                        cnt++;
 
                }