2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_trace.c: Traces a path to a client/server.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-07 09:27:32 +01:00
|
|
|
static const char trace_desc[] =
|
|
|
|
"Provides the TRACE command to trace the route to a client or server";
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void m_trace(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2016-03-09 08:29:41 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void trace_spy(client::client &, client::client *);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message trace_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"TRACE", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_unreg, {m_trace, 0}, {m_trace, 0}, mg_ignore, mg_ignore, {m_trace, 0}}
|
|
|
|
};
|
|
|
|
|
|
|
|
int doing_trace_hook;
|
|
|
|
|
|
|
|
mapi_clist_av1 trace_clist[] = { &trace_msgtab, NULL };
|
|
|
|
mapi_hlist_av1 trace_hlist[] = {
|
|
|
|
{ "doing_trace", &doing_trace_hook },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
2016-03-07 09:27:32 +01:00
|
|
|
DECLARE_MODULE_AV2(trace, NULL, NULL, trace_clist, trace_hlist, NULL, NULL, NULL, trace_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
static void count_downlinks(client::client *server_p, int *pservcount, int *pusercount);
|
2016-08-23 02:37:07 +02:00
|
|
|
static int report_this_status(client::client &source, client::client *target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-06-28 12:27:33 +02:00
|
|
|
static const char *empty_sockhost = "255.255.255.255";
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* m_trace
|
|
|
|
* parv[1] = servername
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
m_trace(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
client::client *target_p = NULL;
|
2007-01-25 07:40:21 +01:00
|
|
|
struct Class *cltmp;
|
|
|
|
const char *tname;
|
2016-03-09 08:37:03 +01:00
|
|
|
bool doall = false, wilds, dow;
|
|
|
|
int cnt = 0;
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(parc > 1)
|
|
|
|
{
|
|
|
|
tname = parv[1];
|
|
|
|
|
|
|
|
if(parc > 2)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(hunt_server(&client, &source, ":%s TRACE %s :%s", 2, parc, parv) !=
|
2007-01-25 07:40:21 +01:00
|
|
|
HUNTED_ISME)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tname = me.name;
|
|
|
|
|
|
|
|
/* if we have 3 parameters, then the command is directed at us. So
|
|
|
|
* we shouldnt be forwarding it anywhere.
|
|
|
|
*/
|
|
|
|
if(parc < 3)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
switch (hunt_server(&client, &source, ":%s TRACE :%s", 1, parc, parv))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
case HUNTED_PASS: /* note: gets here only if parv[1] exists */
|
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
client::client *ac2ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my(source))
|
2007-01-25 07:40:21 +01:00
|
|
|
ac2ptr = find_named_client(tname);
|
|
|
|
else
|
|
|
|
ac2ptr = find_client(tname);
|
|
|
|
|
|
|
|
if(ac2ptr == NULL)
|
|
|
|
{
|
2011-01-08 17:47:05 +01:00
|
|
|
RB_DLINK_FOREACH(ptr, global_serv_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
ac2ptr = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2007-02-01 02:07:42 +01:00
|
|
|
if(match(tname, ac2ptr->name))
|
2007-01-25 07:40:21 +01:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
ac2ptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* giving this out with flattened links defeats the
|
|
|
|
* object --fl
|
|
|
|
*/
|
2016-08-24 00:25:09 +02:00
|
|
|
if(is(source, umode::OPER) || is_exempt_shide(source) ||
|
2007-01-25 07:40:21 +01:00
|
|
|
!ConfigServerHide.flatten_links)
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACELINK,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_TRACELINK),
|
2016-08-16 01:21:01 +02:00
|
|
|
info::version.c_str(),
|
2007-01-25 07:40:21 +01:00
|
|
|
ac2ptr ? ac2ptr->name : tname,
|
|
|
|
ac2ptr ? ac2ptr->from->name : "EEK!");
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case HUNTED_ISME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(match(tname, me.name))
|
|
|
|
{
|
2016-03-09 08:37:03 +01:00
|
|
|
doall = true;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
/* if theyre tracing our SID, we need to move tname to our name so
|
|
|
|
* we dont give the sid in ENDOFTRACE
|
|
|
|
*/
|
2016-08-23 04:33:36 +02:00
|
|
|
else if(!my(source) && !strcmp(tname, me.id))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-03-09 08:37:03 +01:00
|
|
|
doall = true;
|
2007-01-25 07:40:21 +01:00
|
|
|
tname = me.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
wilds = strchr(tname, '*') || strchr(tname, '?');
|
|
|
|
dow = wilds || doall;
|
|
|
|
|
|
|
|
/* specific trace */
|
2016-03-09 08:37:03 +01:00
|
|
|
if(!dow)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my(source) || parc > 2)
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = client::find_named_person(tname);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = client::find_person(tname);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* tname could be pointing to an ID at this point, so reset
|
|
|
|
* it to target_p->name if we have a target --fl
|
|
|
|
*/
|
|
|
|
if(target_p != NULL)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
tname = target_p->name;
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
trace_spy(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_ENDOFTRACE,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_ENDOFTRACE), tname);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
trace_spy(source, NULL);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2014-03-03 05:25:47 +01:00
|
|
|
/* give non-opers a limited trace output of themselves (if local),
|
2007-01-25 07:40:21 +01:00
|
|
|
* opers and servers (if no shide) --fl
|
|
|
|
*/
|
2016-08-24 00:25:09 +02:00
|
|
|
if(!is(source, umode::OPER))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my(source))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(doall || (wilds && match(tname, source.name)))
|
|
|
|
report_this_status(source, &source);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, local_oper_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!doall && wilds && (match(tname, target_p->name) == 0))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if (is_exempt_shide(source) || !ConfigServerHide.flatten_links)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, serv_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!doall && wilds && !match(tname, target_p->name))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_ENDOFTRACE,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_ENDOFTRACE), tname);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
/* &source is opered */
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* report all direct connections */
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, lclient_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* dont show invisible users to remote opers */
|
2016-08-24 00:25:09 +02:00
|
|
|
if(is(*target_p, umode::INVISIBLE) && dow && !my_connect(source) && !is(*target_p, umode::OPER))
|
2007-01-25 07:40:21 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if(!doall && wilds && !match(tname, target_p->name))
|
|
|
|
continue;
|
|
|
|
|
2008-06-03 20:52:00 +02:00
|
|
|
/* remote opers may not see invisible normal users */
|
2016-08-24 00:25:09 +02:00
|
|
|
if(dow && !my_connect(source) && !is(*target_p, umode::OPER) &&
|
|
|
|
is(*target_p, umode::INVISIBLE))
|
2008-06-03 20:52:00 +02:00
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
cnt = report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, serv_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!doall && wilds && !match(tname, target_p->name))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
cnt = report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my_connect(source))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, unknown_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
target_p = (client::client *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!doall && wilds && !match(tname, target_p->name))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
cnt = report_this_status(source, target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!cnt)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, ERR_NOSUCHSERVER, form_str(ERR_NOSUCHSERVER),
|
2007-01-25 07:40:21 +01:00
|
|
|
tname);
|
|
|
|
|
|
|
|
/* let the user have some idea that its at the end of the
|
|
|
|
* trace
|
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_ENDOFTRACE,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_ENDOFTRACE), tname);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(doall)
|
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, class_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-07-13 07:17:21 +02:00
|
|
|
cltmp = (Class *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(CurrUsers(cltmp) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACECLASS,
|
2014-03-03 05:25:47 +01:00
|
|
|
form_str(RPL_TRACECLASS),
|
2007-01-25 07:40:21 +01:00
|
|
|
ClassName(cltmp), CurrUsers(cltmp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), tname);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* count_downlinks
|
|
|
|
*
|
|
|
|
* inputs - pointer to server to count
|
|
|
|
* - pointers to server and user count
|
|
|
|
* output - NONE
|
|
|
|
* side effects - server and user counts are added to given values
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-22 03:57:43 +02:00
|
|
|
count_downlinks(client::client *server_p, int *pservcount, int *pusercount)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
(*pservcount)++;
|
2016-08-22 03:57:43 +02:00
|
|
|
*pusercount += users(serv(*server_p)).size();
|
|
|
|
for(auto &client : servers(serv(*server_p)))
|
|
|
|
count_downlinks(client, pservcount, pusercount);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* report_this_status
|
|
|
|
*
|
|
|
|
* inputs - pointer to client to report to
|
|
|
|
* - pointer to client to report about
|
|
|
|
* output - counter of number of hits
|
|
|
|
* side effects - NONE
|
|
|
|
*/
|
|
|
|
static int
|
2016-08-23 02:37:07 +02:00
|
|
|
report_this_status(client::client &source, client::client *target_p)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *class_name;
|
|
|
|
char ip[HOSTIPLEN];
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
/* sanity check - should never happen */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!my_connect(*target_p))
|
2007-01-25 07:40:21 +01:00
|
|
|
return 0;
|
|
|
|
|
2008-04-20 06:55:41 +02:00
|
|
|
rb_inet_ntop_sock((struct sockaddr *)&target_p->localClient->ip, ip, sizeof(ip));
|
2007-01-25 07:40:21 +01:00
|
|
|
class_name = get_client_class(target_p);
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(is_any_server(*target_p))
|
2008-06-28 12:13:50 +02:00
|
|
|
name = target_p->name;
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
|
|
|
name = get_client_name(target_p, HIDE_IP);
|
|
|
|
|
|
|
|
switch (target_p->status)
|
|
|
|
{
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::CONNECTING:
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACECONNECTING,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_TRACECONNECTING),
|
|
|
|
class_name, name);
|
|
|
|
cnt++;
|
|
|
|
break;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::HANDSHAKE:
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACEHANDSHAKE,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_TRACEHANDSHAKE),
|
|
|
|
class_name, name);
|
|
|
|
cnt++;
|
|
|
|
break;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::ME:
|
2007-01-25 07:40:21 +01:00
|
|
|
break;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::UNKNOWN:
|
2007-01-25 07:40:21 +01:00
|
|
|
/* added time -Taner */
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACEUNKNOWN,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(RPL_TRACEUNKNOWN),
|
|
|
|
class_name, name, ip,
|
2014-02-23 22:46:06 +01:00
|
|
|
(unsigned long)(rb_current_time() - target_p->localClient->firsttime));
|
2007-01-25 07:40:21 +01:00
|
|
|
cnt++;
|
|
|
|
break;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::CLIENT:
|
2008-06-28 21:08:04 +02:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source,
|
2016-08-24 00:25:09 +02:00
|
|
|
is(*target_p, umode::OPER) ? RPL_TRACEOPERATOR : RPL_TRACEUSER,
|
|
|
|
is(*target_p, umode::OPER) ? form_str(RPL_TRACEOPERATOR) : form_str(RPL_TRACEUSER),
|
2008-06-28 21:08:04 +02:00
|
|
|
class_name, name,
|
2016-08-23 02:37:07 +02:00
|
|
|
show_ip(&source, target_p) ? ip : empty_sockhost,
|
2011-11-13 00:22:09 +01:00
|
|
|
(unsigned long)(rb_current_time() - target_p->localClient->lasttime),
|
|
|
|
(unsigned long)(rb_current_time() - target_p->localClient->last));
|
2008-06-28 21:08:04 +02:00
|
|
|
|
|
|
|
cnt++;
|
|
|
|
}
|
2008-06-28 16:20:24 +02:00
|
|
|
break;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
case client::status::SERVER:
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
int usercount = 0;
|
|
|
|
int servcount = 0;
|
|
|
|
|
|
|
|
count_downlinks(target_p, &servcount, &usercount);
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACESERVER, form_str(RPL_TRACESERVER),
|
2007-01-25 07:40:21 +01:00
|
|
|
class_name, servcount, usercount, name,
|
2016-08-22 03:57:43 +02:00
|
|
|
by(serv(*target_p)).empty()? by(serv(*target_p)).c_str() : "*", "*",
|
2011-11-13 00:22:09 +01:00
|
|
|
me.name,
|
|
|
|
(unsigned long)(rb_current_time() - target_p->localClient->lasttime));
|
2007-01-25 07:40:21 +01:00
|
|
|
cnt++;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* ...we actually shouldn't come here... --msa */
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, RPL_TRACENEWTYPE,
|
2011-11-13 00:22:09 +01:00
|
|
|
form_str(RPL_TRACENEWTYPE), name);
|
2007-01-25 07:40:21 +01:00
|
|
|
cnt++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* trace_spy()
|
|
|
|
*
|
|
|
|
* input - pointer to client
|
|
|
|
* output - none
|
|
|
|
* side effects - hook event doing_trace is called
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
trace_spy(client::client &source, client::client *target_p)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
hook_data_client hdata;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
hdata.client = &source;
|
2007-01-25 07:40:21 +01:00
|
|
|
hdata.target = target_p;
|
|
|
|
|
|
|
|
call_hook(doing_trace_hook, &hdata);
|
|
|
|
}
|