ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_trace.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/modules/m_trace.c (file contents), Revision 891 by michael, Thu Nov 1 13:44:50 2007 UTC vs.
ircd-hybrid/trunk/modules/m_trace.c (file contents), Revision 1618 by michael, Tue Oct 30 21:04:38 2012 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "handlers.h"
27 < #include "tools.h"
28 < #include "hook.h"
26 > #include "list.h"
27   #include "client.h"
28   #include "hash.h"
31 – #include "common.h"
29   #include "irc_string.h"
30   #include "ircd.h"
31   #include "numeric.h"
35 – #include "fdlist.h"
32   #include "s_bsd.h"
33   #include "s_serv.h"
34   #include "send.h"
39 – #include "msg.h"
35   #include "parse.h"
36   #include "modules.h"
37 < #include "s_conf.h"
37 > #include "conf.h"
38  
44 – static void m_trace(struct Client *, struct Client *, int, char *[]);
45 – static void ms_trace(struct Client *, struct Client *, int, char *[]);
46 – static void mo_trace(struct Client *, struct Client *, int, char *[]);
47 – static void do_actual_trace(struct Client *, int, char *[]);
48 –
49 – struct Message trace_msgtab = {
50 –  "TRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
51 –  { m_unregistered, m_trace, ms_trace, m_ignore, mo_trace, m_ignore }
52 – };
53 –
54 – #ifndef STATIC_MODULES
55 – const char *_version = "$Revision$";
56 – static struct Callback *trace_cb;
57 –
58 – static void *
59 – va_actual_trace(va_list args)
60 – {
61 –  struct Client *source_p = va_arg(args, struct Client *);
62 –  int parc = va_arg(args, int);
63 –  char **parv = va_arg(args, char **);
64 –
65 –  do_actual_trace(source_p, parc, parv);
66 –  return NULL;
67 – }
68 –
69 – void
70 – _modinit(void)
71 – {
72 –  trace_cb = register_callback("doing_trace", va_actual_trace);
73 –  mod_add_cmd(&trace_msgtab);
74 – }
75 –
76 – void
77 – _moddeinit(void)
78 – {
79 –  mod_del_cmd(&trace_msgtab);
80 –  uninstall_hook(trace_cb, va_actual_trace);
81 – }
82 – #endif
39  
40 + static void do_actual_trace(struct Client *, int, char *[]);
41   static void report_this_status(struct Client *, struct Client *, int);
42  
43   static void
# Line 156 | Line 113 | mo_trace(struct Client *client_p, struct
113      {
114        struct Client *ac2ptr = NULL;
115  
116 <      if ((ac2ptr = find_client(tname)) == NULL)
116 >      if ((ac2ptr = hash_find_client(tname)) == NULL)
117        {
118          DLINK_FOREACH(ptr, global_client_list.head)
119          {
120            ac2ptr = ptr->data;
121  
122 <          if (match(tname, ac2ptr->name) || match(ac2ptr->name, tname))
122 >          if (match(tname, ac2ptr->name))
123              break;
124            else
125              ac2ptr = NULL;
# Line 177 | Line 134 | mo_trace(struct Client *client_p, struct
134                     ircd_version, tname, "ac2ptr_is_NULL!!");
135        return;
136      }
137 +
138      case HUNTED_ISME:
181 – #ifdef STATIC_MODULES
139        do_actual_trace(source_p, parc, parv);
183 – #else
184 –      execute_callback(trace_cb, source_p, parc, parv);
185 – #endif
140        break;
141      default:
142        return;
143    }
144   }
145  
146 + /*
147 + ** ms_trace
148 + **      parv[0] = sender prefix
149 + **      parv[1] = servername
150 + */
151 + static void
152 + ms_trace(struct Client *client_p, struct Client *source_p,
153 +         int parc, char *parv[])
154 + {
155 +  if (hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv))
156 +    return;
157 +
158 +  if (HasUMode(source_p, UMODE_OPER))
159 +    mo_trace(client_p, source_p, parc, parv);
160 + }
161 +
162   static void
163   do_actual_trace(struct Client *source_p, int parc, char *parv[])
164   {
# Line 216 | Line 186 | do_actual_trace(struct Client *source_p,
186      to = source_p->name;
187    }
188  
189 +  sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
190 +                       "TRACE requested by %s (%s@%s) [%s]",
191 +                       source_p->name, source_p->username,
192 +                       source_p->host, source_p->servptr->name);
193 +
194    if (match(tname, me.name))
195 <    doall = TRUE;
195 >    doall = 1;
196    else if (!MyClient(source_p) && !strcmp(tname, me.id))
197    {
198 <    doall = TRUE;
198 >    doall = 1;
199      tname = me.name;
200    }
201  
202 <  wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?');
202 >  wilds = !parv[1] || has_wildcards(tname);
203    dow = wilds || doall;
204  
205    set_time();
206 <  if (!IsOper(source_p) || !dow) /* non-oper traces must be full nicks */
206 >  if (!HasUMode(source_p, UMODE_OPER) || !dow) /* non-oper traces must be full nicks */
207                                /* lets also do this for opers tracing nicks */
208    {
209      const char *name;
210      const char *class_name;
211  
212 <    target_p = find_client(tname);
212 >    target_p = hash_find_client(tname);
213        
214      if (target_p && IsClient(target_p))
215      {
216        name = get_client_name(target_p, HIDE_IP);
217        class_name = get_client_class(target_p);
218  
219 <      if (IsOper(target_p))
219 >      if (HasUMode(target_p, UMODE_OPER))
220        {
221          sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
222                     from, to, class_name, name,
223                     IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
224 <                   CurrentTime - target_p->lasttime,
225 <                   CurrentTime - target_p->localClient->last);
224 >                   CurrentTime - target_p->localClient->lasttime,
225 >                   CurrentTime - target_p->localClient->last_privmsg);
226        }
227        else
228        {
229          sendto_one(source_p,form_str(RPL_TRACEUSER),
230                     from, to, class_name, name,
231                     IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
232 <                   CurrentTime - target_p->lasttime,
233 <                   CurrentTime - target_p->localClient->last);
232 >                   CurrentTime - target_p->localClient->lasttime,
233 >                   CurrentTime - target_p->localClient->last_privmsg);
234        }
235      }
236        
# Line 269 | Line 244 | do_actual_trace(struct Client *source_p,
244    {
245      target_p = ptr->data;
246  
247 <    if (IsInvisible(target_p) && dow &&
248 <        !(MyConnect(source_p) && IsOper(source_p)) &&
249 <        !IsOper(target_p) && (target_p != source_p))
247 >    if (HasUMode(target_p, UMODE_INVISIBLE) && dow &&
248 >        !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) &&
249 >        !HasUMode(target_p, UMODE_OPER) && (target_p != source_p))
250        continue;
251      if (!doall && wilds && !match(tname, target_p->name))
252        continue;
# Line 311 | Line 286 | do_actual_trace(struct Client *source_p,
286      conf = ptr->data;
287      cltmp = map_to_conf(conf);
288  
289 <    if (CurrUserCount(cltmp) > 0)
289 >    if (cltmp->curr_user_count > 0)
290        sendto_one(source_p, form_str(RPL_TRACECLASS),
291 <                 from, to, conf->name, CurrUserCount(cltmp));
291 >                 from, to, conf->name, cltmp->curr_user_count);
292    }
293  
294    sendto_one(source_p, form_str(RPL_ENDOFTRACE), from, to, tname);
295   }
296  
322 – /*
323 – ** ms_trace
324 – **      parv[0] = sender prefix
325 – **      parv[1] = servername
326 – */
327 – static void
328 – ms_trace(struct Client *client_p, struct Client *source_p,
329 –         int parc, char *parv[])
330 – {
331 –  if (hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv))
332 –    return;
333 –
334 –  if (IsOper(source_p))
335 –    mo_trace(client_p, source_p, parc, parv);
336 – }
337 –
297   /* report_this_status()
298   *
299   * inputs       - pointer to client to report to
# Line 370 | Line 329 | report_this_status(struct Client *source
329      case STAT_CONNECTING:
330        sendto_one(source_p, form_str(RPL_TRACECONNECTING),
331                   from, to, class_name,
332 <                 IsOperAdmin(source_p) ? name : target_p->name);
332 >                 HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
333        break;
334      case STAT_HANDSHAKE:
335        sendto_one(source_p, form_str(RPL_TRACEHANDSHAKE),
336                   from, to, class_name,
337 <                 IsOperAdmin(source_p) ? name : target_p->name);
337 >                 HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
338        break;
339      case STAT_ME:
340        break;
# Line 383 | Line 342 | report_this_status(struct Client *source
342        /* added time -Taner */
343        sendto_one(source_p, form_str(RPL_TRACEUNKNOWN),
344                   from, to, class_name, name, target_p->sockhost,
345 <                 target_p->firsttime ? CurrentTime - target_p->firsttime : -1);
345 >                 target_p->localClient->firsttime ? /* TBD: can't be 0 */
346 >                 CurrentTime - target_p->localClient->firsttime : -1);
347        break;
348      case STAT_CLIENT:
349        /*
350         * Only opers see users if there is a wildcard
351         * but anyone can see all the opers.
352         */
353 <      if ((IsOper(source_p) &&
354 <           (MyClient(source_p) || !(dow && IsInvisible(target_p))))
355 <          || !dow || IsOper(target_p))
353 >      if ((HasUMode(source_p, UMODE_OPER) &&
354 >           (MyClient(source_p) || !(dow && HasUMode(target_p, UMODE_INVISIBLE))))
355 >          || !dow || HasUMode(target_p, UMODE_OPER))
356          {
357 <          if (IsAdmin(target_p) && !ConfigFileEntry.hide_spoof_ips)
357 >          if (HasUMode(target_p, UMODE_ADMIN) && !ConfigFileEntry.hide_spoof_ips)
358              sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
359                         from, to, class_name, name,
360 <                       IsOperAdmin(source_p) ? target_p->sockhost : "255.255.255.255",
361 <                       CurrentTime - target_p->lasttime,
362 <                       CurrentTime - target_p->localClient->last);
360 >                       HasUMode(source_p, UMODE_ADMIN) ? target_p->sockhost : "255.255.255.255",
361 >                       CurrentTime - target_p->localClient->lasttime,
362 >                       CurrentTime - target_p->localClient->last_privmsg);
363                        
364 <          else if (IsOper(target_p))
364 >          else if (HasUMode(target_p, UMODE_OPER))
365            {
366              if (ConfigFileEntry.hide_spoof_ips)
367                sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
368                           from, to, class_name, name,
369                           IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
370 <                         CurrentTime - target_p->lasttime,
371 <                         CurrentTime - target_p->localClient->last);
370 >                         CurrentTime - target_p->localClient->lasttime,
371 >                         CurrentTime - target_p->localClient->last_privmsg);
372              else
373                sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
374                           from, to, class_name, name,
375                           MyOper(source_p) ? target_p->sockhost :
376                           (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
377 <                         CurrentTime - target_p->lasttime,
378 <                         CurrentTime - target_p->localClient->last);
377 >                         CurrentTime - target_p->localClient->lasttime,
378 >                         CurrentTime - target_p->localClient->last_privmsg);
379            }                    
380            else
381            {
422 –            const char *format_str=NULL;
423 –            if (IsOper(source_p) && IsCaptured(target_p))
424 –              format_str = form_str(RPL_TRACECAPTURED);
425 –            else
426 –              format_str = form_str(RPL_TRACEUSER);
427 –
382              if (ConfigFileEntry.hide_spoof_ips)
383 <              sendto_one(source_p, format_str,
383 >              sendto_one(source_p, form_str(RPL_TRACEUSER),
384                           from, to, class_name, name,
385                           IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
386 <                         CurrentTime - target_p->lasttime,
387 <                         CurrentTime - target_p->localClient->last);
386 >                         CurrentTime - target_p->localClient->lasttime,
387 >                         CurrentTime - target_p->localClient->last_privmsg);
388              else
389 <              sendto_one(source_p, format_str,
389 >              sendto_one(source_p, form_str(RPL_TRACEUSER),
390                           from, to, class_name, name,
391                           MyOper(source_p) ? target_p->sockhost :
392                           (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
393 <                         CurrentTime - target_p->lasttime,
394 <                         CurrentTime - target_p->localClient->last);
393 >                         CurrentTime - target_p->localClient->lasttime,
394 >                         CurrentTime - target_p->localClient->last_privmsg);
395            }
396          }
397        break;
# Line 448 | Line 402 | report_this_status(struct Client *source
402  
403        trace_get_dependent(&servers, &clients, target_p);
404  
405 <      if (!IsOperAdmin(source_p))
405 >      if (!HasUMode(source_p, UMODE_ADMIN))
406          name = get_client_name(target_p, MASK_IP);
407  
408        sendto_one(source_p, form_str(RPL_TRACESERVER),
409                   from, to, class_name, servers,
410                   clients, name, *(target_p->serv->by) ?
411                   target_p->serv->by : "*", "*",
412 <                 me.name, CurrentTime - target_p->lasttime);
412 >                 me.name, CurrentTime - target_p->localClient->lasttime);
413        break;
414      }
415        
# Line 465 | Line 419 | report_this_status(struct Client *source
419        break;
420    }
421   }
422 +
423 + static struct Message trace_msgtab = {
424 +  "TRACE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
425 +  { m_unregistered, m_trace, ms_trace, m_ignore, mo_trace, m_ignore }
426 + };
427 +
428 + static void
429 + module_init(void)
430 + {
431 +  mod_add_cmd(&trace_msgtab);
432 + }
433 +
434 + static void
435 + module_exit(void)
436 + {
437 +  mod_del_cmd(&trace_msgtab);
438 + }
439 +
440 + struct module module_entry = {
441 +  .node    = { NULL, NULL, NULL },
442 +  .name    = NULL,
443 +  .version = "$Revision$",
444 +  .handle  = NULL,
445 +  .modinit = module_init,
446 +  .modexit = module_exit,
447 +  .flags   = 0
448 + };

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)