155
155
struct Client *target_p = NULL;
166
166
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
167
167
"TRACE requested by %s (%s@%s) [%s]",
168
168
source_p->name, source_p->username,
169
169
source_p->host, source_p->servptr->name);
171
if (!match(tname, me.name))
171
if (!match(name, me.name))
173
else if (!MyClient(source_p) && !strcmp(tname, me.id))
173
else if (!MyClient(source_p) && !strcmp(name, me.id))
179
wilds = !parv[1] || has_wildcards(tname);
179
wilds = !parv[1] || has_wildcards(name);
180
180
dow = wilds || doall;
182
182
if (!HasUMode(source_p, UMODE_OPER) || !dow) /* non-oper traces must be full nicks */
183
183
/* lets also do this for opers tracing nicks */
186
target_p = hash_find_client(tname);
185
target_p = hash_find_client(name);
188
187
if (target_p && IsClient(target_p))
190
name = get_client_name(target_p, HIDE_IP);
192
189
if (HasUMode(target_p, UMODE_OPER))
194
191
sendto_one_numeric(source_p, &me, RPL_TRACEOPERATOR,
195
get_client_class(&target_p->localClient->confs), name,
196
IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
197
CurrentTime - target_p->localClient->lasttime,
198
idle_time_get(source_p, target_p));
192
get_client_class(&target_p->connection->confs), get_client_name(target_p, HIDE_IP),
194
CurrentTime - target_p->connection->lasttime,
195
client_get_idle_time(source_p, target_p));
202
199
sendto_one_numeric(source_p, &me, RPL_TRACEUSER,
203
get_client_class(&target_p->localClient->confs), name,
204
IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
205
CurrentTime - target_p->localClient->lasttime,
206
idle_time_get(source_p, target_p));
200
get_client_class(&target_p->connection->confs), get_client_name(target_p, HIDE_IP),
202
CurrentTime - target_p->connection->lasttime,
203
client_get_idle_time(source_p, target_p));
210
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname);
207
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, name);
214
211
/* report all direct connections */
215
DLINK_FOREACH(ptr, local_client_list.head)
212
DLINK_FOREACH(node, local_client_list.head)
217
target_p = ptr->data;
214
target_p = node->data;
219
216
if (HasUMode(target_p, UMODE_INVISIBLE) && dow &&
220
217
!(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) &&
221
218
!HasUMode(target_p, UMODE_OPER) && (target_p != source_p))
223
if (!doall && wilds && match(tname, target_p->name))
220
if (!doall && wilds && match(name, target_p->name))
225
if (!dow && irccmp(tname, target_p->name))
222
if (!dow && irccmp(name, target_p->name))
228
225
report_this_status(source_p, target_p, dow);
231
DLINK_FOREACH(ptr, local_server_list.head)
228
DLINK_FOREACH(node, local_server_list.head)
233
target_p = ptr->data;
230
target_p = node->data;
235
if (!doall && wilds && match(tname, target_p->name))
232
if (!doall && wilds && match(name, target_p->name))
237
if (!dow && irccmp(tname, target_p->name))
234
if (!dow && irccmp(name, target_p->name))
240
237
report_this_status(source_p, target_p, dow);
243
240
/* This section is to report the unknowns */
244
DLINK_FOREACH(ptr, unknown_list.head)
241
DLINK_FOREACH(node, unknown_list.head)
246
target_p = ptr->data;
243
target_p = node->data;
248
if (!doall && wilds && match(tname, target_p->name))
245
if (!doall && wilds && match(name, target_p->name))
250
if (!dow && irccmp(tname, target_p->name))
247
if (!dow && irccmp(name, target_p->name))
253
250
report_this_status(source_p, target_p, dow);
256
DLINK_FOREACH(ptr, class_get_list()->head)
253
DLINK_FOREACH(node, class_get_list()->head)
258
const struct ClassItem *class = ptr->data;
255
const struct ClassItem *class = node->data;
260
257
if (class->ref_count > 0)
261
258
sendto_one_numeric(source_p, &me, RPL_TRACECLASS, class->name, class->ref_count);
264
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname);
261
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, name);
267
264
/* report_this_status()
278
275
const char *class_name;
280
277
name = get_client_name(target_p, HIDE_IP);
281
class_name = get_client_class(&target_p->localClient->confs);
278
class_name = get_client_class(&target_p->connection->confs);
283
280
switch (target_p->status)
285
282
case STAT_CONNECTING:
286
283
sendto_one_numeric(source_p, &me, RPL_TRACECONNECTING, class_name,
287
HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
284
HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
289
286
case STAT_HANDSHAKE:
290
287
sendto_one_numeric(source_p, &me, RPL_TRACEHANDSHAKE, class_name,
291
HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
288
HasUMode(source_p, UMODE_ADMIN) ? name : target_p->name);
295
292
case STAT_UNKNOWN:
296
/* added time -Taner */
297
293
sendto_one_numeric(source_p, &me, RPL_TRACEUNKNOWN, class_name,
298
name, target_p->sockhost,
299
CurrentTime - target_p->localClient->firsttime);
294
name, target_p->sockhost,
295
CurrentTime - target_p->connection->firsttime);
301
297
case STAT_CLIENT:
303
* Only opers see users if there is a wildcard
304
* but anyone can see all the opers.
306
if ((HasUMode(source_p, UMODE_OPER) &&
307
(MyClient(source_p) || !(dow && HasUMode(target_p, UMODE_INVISIBLE))))
308
|| !dow || HasUMode(target_p, UMODE_OPER))
310
if (HasUMode(target_p, UMODE_ADMIN) && !ConfigGeneral.hide_spoof_ips)
311
sendto_one_numeric(source_p, &me, RPL_TRACEOPERATOR, class_name, name,
312
HasUMode(source_p, UMODE_ADMIN) ? target_p->sockhost : "255.255.255.255",
313
CurrentTime - target_p->localClient->lasttime,
314
idle_time_get(source_p, target_p));
316
else if (HasUMode(target_p, UMODE_OPER))
318
if (ConfigGeneral.hide_spoof_ips)
319
sendto_one_numeric(source_p, &me, RPL_TRACEOPERATOR, class_name, name,
320
IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
321
CurrentTime - target_p->localClient->lasttime,
322
idle_time_get(source_p, target_p));
324
sendto_one_numeric(source_p, &me, RPL_TRACEOPERATOR, class_name, name,
325
MyOper(source_p) ? target_p->sockhost :
326
(IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
327
CurrentTime - target_p->localClient->lasttime,
328
idle_time_get(source_p, target_p));
332
if (ConfigGeneral.hide_spoof_ips)
333
sendto_one_numeric(source_p, &me, RPL_TRACEUSER, class_name, name,
334
IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
335
CurrentTime - target_p->localClient->lasttime,
336
idle_time_get(source_p, target_p));
338
sendto_one_numeric(source_p, &me, RPL_TRACEUSER, class_name, name,
339
MyOper(source_p) ? target_p->sockhost :
340
(IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
341
CurrentTime - target_p->localClient->lasttime,
342
idle_time_get(source_p, target_p));
298
if (HasUMode(target_p, UMODE_OPER))
299
sendto_one_numeric(source_p, &me, RPL_TRACEOPERATOR, class_name, name,
301
CurrentTime - target_p->connection->lasttime,
302
client_get_idle_time(source_p, target_p));
304
sendto_one_numeric(source_p, &me, RPL_TRACEUSER, class_name, name,
306
CurrentTime - target_p->connection->lasttime,
307
client_get_idle_time(source_p, target_p));
346
309
case STAT_SERVER: