]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_trace.c
report_this_status fixed
[irc/rqf/shadowircd.git] / modules / m_trace.c
index 1ae65dd94b3e5b2af32eed206a093cb8b8126f8c..1c0122939e73c709dbad8b4ae9a816d174dce4a2 100644 (file)
@@ -172,7 +172,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);
+                       report_this_status(source_p, target_p, 0);
                        tname = target_p->name;
                }
 
@@ -193,7 +193,7 @@ 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);
+                               report_this_status(source_p, source_p, 0);
                }
 
                RB_DLINK_FOREACH(ptr, local_oper_list.head)
@@ -203,7 +203,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                        if(!doall && wilds && (match(tname, target_p->name) == 0))
                                continue;
 
-                       report_this_status(source_p, target_p);
+                       report_this_status(source_p, target_p, 0);
                }
 
                if (IsExemptShide(source_p) || !ConfigServerHide.flatten_links)
@@ -215,7 +215,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                                if(!doall && wilds && !match(tname, target_p->name))
                                        continue;
 
-                               report_this_status(source_p, target_p);
+                               report_this_status(source_p, target_p, 0);
                        }
                }
 
@@ -243,7 +243,7 @@ m_trace(struct Client *client_p, struct Client *source_p, int parc, const char *
                                IsInvisible(target_p))
                        continue;
 
-               cnt = report_this_status(source_p, target_p);
+               cnt = report_this_status(source_p, target_p, dow);
        }
 
        RB_DLINK_FOREACH(ptr, serv_list.head)
@@ -253,7 +253,7 @@ 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);
+               cnt = report_this_status(source_p, target_p, dow);
        }
 
        if(MyConnect(source_p))
@@ -265,7 +265,7 @@ 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);
+                       cnt = report_this_status(source_p, target_p, dow);
                }
        }
 
@@ -330,7 +330,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)
+report_this_status(struct Client *source_p, struct Client *target_p, int dow)
 {
        const char *name;
        const char *class_name;
@@ -345,7 +345,7 @@ report_this_status(struct Client *source_p, struct Client *target_p)
        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);
 
@@ -378,25 +378,26 @@ report_this_status(struct Client *source_p, struct Client *target_p)
                break;
 
        case STAT_CLIENT:
-               {
-                       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",
-                                                  rb_current_time() - target_p->localClient->lasttime,
-                                                  rb_current_time() - target_p->localClient->last);
+                /* 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))
+                {
+                        int tnumeric = RPL_TRACEUSER;
+                        if(IsOper(target_p))
+                                tnumeric = RPL_TRACEOPERATOR;
+                        
+                        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);
+                        cnt++;
+                }
+                break;
 
-                       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",
-                                                  rb_current_time() - target_p->localClient->lasttime,
-                                                  rb_current_time() - target_p->localClient->last);
-                       cnt++;
-               }
-               break;
 
        case STAT_SERVER:
                {