From: Michael Poole Date: Sun, 12 Sep 2004 01:42:17 +0000 (+0000) Subject: Send RPL_TRACEEND at end of trace output. X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=73be444461c6bf9f90276a1bb49984fa728ef2de;p=ircu2.10.12-pk.git Send RPL_TRACEEND at end of trace output. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1134 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index a50aa94..4320de5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-09-11 Michael Poole + + * include/numeric.h, ircd/s_err.c: Remove RPL_TRACEPING, and + replace with RPL_TRACEEND. + + * ircd/s_trace.c: Move all the duplicated code in m*_trace() to + do_trace(). Implement RPL_TRACEEND, per RFE#830291. + 2003-06-20 Alexander Maassen * ircd/m_topic.c : Don't allow banned users to set a topic in a diff --git a/include/numeric.h b/include/numeric.h index 0dfb1a2..ed631d2 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -156,8 +156,7 @@ extern const struct Numeric* get_error_numeric(int err); #define RPL_ADMINEMAIL 259 #define RPL_TRACELOG 261 /* unused */ -#define RPL_TRACEPING 262 /* Extension to RFC1459, unused */ -/* RPL_TRACEEND 262 efnet(?) Numerics List: IRCnet */ +#define RPL_TRACEEND 262 /* efnet/IRCnet */ /* RPL_LOAD_THROTTLED 263 efnet/hybrid */ /* RPL_TRYAGAIN 263 Numerics List: IRCnet */ /* RPL_LOAD2HI 263 Dalnet */ diff --git a/ircd/m_trace.c b/ircd/m_trace.c index 34547ee..e311682 100644 --- a/ircd/m_trace.c +++ b/ircd/m_trace.c @@ -101,14 +101,7 @@ #include #include -/* - * m_trace - generic message handler - * - * parv[0] = sender prefix - * parv[1] = nick or servername - * parv[2] = 'target' servername - */ -int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +void do_trace(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { int i; struct Client *acptr; @@ -121,9 +114,6 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) int wilds; int dow; - if (feature_bool(FEAT_HIS_TRACE)) - return send_reply(cptr, ERR_NOPRIVILEGES); - if (parc < 2 || BadPtr(parv[1])) { /* just "TRACE" without parameters. Must be from local client */ @@ -148,7 +138,7 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) parv[3] = 0; if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, IsServer(acptr), "%s :%C", 2, parc, parv)) == HUNTED_NOSUCH) - return 0; + return; } else i = HUNTED_ISME; @@ -161,7 +151,7 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) acptr = FindNServer(parv[2]); if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, 0, "%s :%C", 2, parc, parv)) == HUNTED_NOSUCH) - return 0; + return; tname = parv[1]; } @@ -173,7 +163,7 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_TRACELINK, version, debugmode, tname, acptr ? cli_name(cli_from(acptr)) : ""); - return 0; + return; } doall = (parv[1] && (parc > 1)) ? !match(tname, cli_name(&me)) : 1; @@ -181,8 +171,10 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) dow = wilds || doall; /* Don't give (long) remote listings to lusers */ - if (dow && !MyConnect(sptr) && !IsAnOper(sptr)) - return 0; + if (dow && !MyConnect(sptr) && !IsAnOper(sptr)) { + send_reply(sptr, RPL_TRACEEND); + return; + } for (i = 0; i < MAXCONNECTIONS; i++) link_s[i] = 0, link_u[i] = 0; @@ -292,20 +284,27 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * Add these lines to summarize the above which can get rather long * and messy when done remotely - Avalon */ - if (!IsAnOper(sptr) || !cnt) { - if (!cnt) - /* let the user have some idea that its at the end of the trace */ - send_reply(sptr, RPL_TRACESERVER, 0, link_s[cli_fd(&me)], - link_u[cli_fd(&me)], "", *(cli_serv(&me)->by) ? - cli_serv(&me)->by : "*", "*", cli_name(&me), 0, 0); - return 0; - } - if (doall) { + if (IsAnOper(sptr) && doall) { for (cl = get_class_list(); cl; cl = cl->next) { if (Links(cl) > 0) send_reply(sptr, RPL_TRACECLASS, ConClass(cl), Links(cl)); } } + send_reply(sptr, RPL_TRACEEND); +} + +/* + * m_trace - generic message handler + * + * parv[0] = sender prefix + * parv[1] = nick or servername + * parv[2] = 'target' servername + */ +int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + if (feature_bool(FEAT_HIS_TRACE)) + return send_reply(cptr, ERR_NOPRIVILEGES); + do_trace(cptr, sptr, parc, parv); return 0; } @@ -318,194 +317,7 @@ int m_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ int ms_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - int i; - struct Client *acptr; - const struct ConnectionClass* cl; - char *tname; - int doall; - int link_s[MAXCONNECTIONS]; - int link_u[MAXCONNECTIONS]; - int cnt = 0; - int wilds; - int dow; - - if (parc < 2 || BadPtr(parv[1])) { - /* just "TRACE" without parameters. Must be from local client */ - parc = 1; - acptr = &me; - tname = cli_name(&me); - i = HUNTED_ISME; - } else if (parc < 3 || BadPtr(parv[2])) { - /* No target specified. Make one before propagating. */ - parc = 2; - tname = parv[1]; - if ((acptr = find_match_server(parv[1])) || - ((acptr = FindClient(parv[1])) && !MyUser(acptr))) { - if (IsUser(acptr)) - parv[2] = cli_name(cli_user(acptr)->server); - else - parv[2] = cli_name(acptr); - parc = 3; - parv[3] = 0; - - if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, IsServer(acptr), - "%s :%C", 2, parc, parv)) == HUNTED_NOSUCH) - return 0; - } else - i = HUNTED_ISME; - } else { - /* Got "TRACE :" */ - parc = 3; - if (MyUser(sptr) || Protocol(cptr) < 10) - acptr = find_match_server(parv[2]); - else - acptr = FindNServer(parv[2]); - if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, 0, "%s :%C", 2, parc, - parv)) == HUNTED_NOSUCH) - return 0; - tname = parv[1]; - } - - if (i == HUNTED_PASS) { - if (!acptr) - acptr = next_client(GlobalClientList, tname); - else - acptr = cli_from(acptr); - send_reply(sptr, RPL_TRACELINK, - version, debugmode, tname, - acptr ? cli_name(cli_from(acptr)) : ""); - return 0; - } - - doall = (parv[1] && (parc > 1)) ? !match(tname, cli_name(&me)) : 1; - wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?'); - dow = wilds || doall; - - /* Don't give (long) remote listings to lusers */ - if (dow && !MyConnect(sptr) && !IsAnOper(sptr)) - return 0; - - for (i = 0; i < MAXCONNECTIONS; i++) - link_s[i] = 0, link_u[i] = 0; - - if (doall) { - for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) { - if (IsUser(acptr)) - link_u[cli_fd(cli_from(acptr))]++; - else if (IsServer(acptr)) - link_s[cli_fd(cli_from(acptr))]++; - } - } - - /* report all direct connections */ - - for (i = 0; i <= HighestFd; i++) { - const char *conClass; - - if (!(acptr = LocalClientArray[i])) /* Local Connection? */ - continue; - if (IsInvisible(acptr) && dow && !(MyConnect(sptr) && IsOper(sptr)) && - !IsAnOper(acptr) && (acptr != sptr)) - continue; - if (!doall && wilds && match(tname, cli_name(acptr))) - continue; - if (!dow && 0 != ircd_strcmp(tname, cli_name(acptr))) - continue; - conClass = get_client_class(acptr); - - switch (cli_status(acptr)) { - case STAT_CONNECTING: - send_reply(sptr, RPL_TRACECONNECTING, conClass, cli_name(acptr)); - cnt++; - break; - case STAT_HANDSHAKE: - send_reply(sptr, RPL_TRACEHANDSHAKE, conClass, cli_name(acptr)); - cnt++; - break; - case STAT_ME: - break; - case STAT_UNKNOWN: - case STAT_UNKNOWN_USER: - send_reply(sptr, RPL_TRACEUNKNOWN, conClass, - get_client_name(acptr, HIDE_IP)); - cnt++; - break; - case STAT_UNKNOWN_SERVER: - send_reply(sptr, RPL_TRACEUNKNOWN, conClass, "Unknown Server"); - cnt++; - break; - case STAT_USER: - /* Only opers see users if there is a wildcard - but anyone can see all the opers. */ - if ((IsAnOper(sptr) && (MyUser(sptr) || - !(dow && IsInvisible(acptr)))) || !dow || IsAnOper(acptr)) { - if (IsAnOper(acptr)) - send_reply(sptr, RPL_TRACEOPERATOR, conClass, - get_client_name(acptr, SHOW_IP), - CurrentTime - cli_lasttime(acptr)); - else - send_reply(sptr, RPL_TRACEUSER, conClass, - get_client_name(acptr, SHOW_IP), - CurrentTime - cli_lasttime(acptr)); - cnt++; - } - break; - /* - * Connection is a server - * - * Serv - * - * class Class the server is in - * nS Number of servers reached via this link - * nC Number of clients reached via this link - * name Name of the server linked - * ConnBy Who established this link - * last Seconds since we got something from this link - * age Seconds this link has been alive - * - * Additional comments etc...... -Cym- - */ - - case STAT_SERVER: - if (cli_serv(acptr)->user) - send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i], - link_u[i], cli_name(acptr), - (*(cli_serv(acptr))->by) ? cli_serv(acptr)->by : "*", - cli_serv(acptr)->user->username, cli_serv(acptr)->user->host, - CurrentTime - cli_lasttime(acptr), - CurrentTime - cli_serv(acptr)->timestamp); - else - send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i], - link_u[i], cli_name(acptr), - (*(cli_serv(acptr))->by) ? cli_serv(acptr)->by : "*", "*", - cli_name(&me), CurrentTime - cli_lasttime(acptr), - CurrentTime - cli_serv(acptr)->timestamp); - cnt++; - break; - default: /* We actually shouldn't come here, -msa */ - send_reply(sptr, RPL_TRACENEWTYPE, get_client_name(acptr, HIDE_IP)); - cnt++; - break; - } - } - /* - * Add these lines to summarize the above which can get rather long - * and messy when done remotely - Avalon - */ - if (!IsAnOper(sptr) || !cnt) { - if (!cnt) - /* let the user have some idea that its at the end of the trace */ - send_reply(sptr, RPL_TRACESERVER, 0, link_s[cli_fd(&me)], - link_u[cli_fd(&me)], "", *(cli_serv(&me)->by) ? - cli_serv(&me)->by : "*", "*", cli_name(&me), 0, 0); - return 0; - } - if (doall) { - for (cl = get_class_list(); cl; cl = cl->next) { - if (Links(cl) > 0) - send_reply(sptr, RPL_TRACECLASS, ConClass(cl), Links(cl)); - } - } + do_trace(cptr, sptr, parc, parv); return 0; } @@ -518,194 +330,8 @@ int ms_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ int mo_trace(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - int i; - struct Client* acptr; - const struct ConnectionClass* cl; - char* tname; - int doall; - int link_s[MAXCONNECTIONS]; - int link_u[MAXCONNECTIONS]; - int cnt = 0; - int wilds; - int dow; - - if (parc < 2 || BadPtr(parv[1])) { - /* just "TRACE" without parameters. Must be from local client */ - parc = 1; - acptr = &me; - tname = cli_name(&me); - i = HUNTED_ISME; - } else if (parc < 3 || BadPtr(parv[2])) { - /* No target specified. Make one before propagating. */ - parc = 2; - tname = parv[1]; - if ((acptr = find_match_server(parv[1])) || - ((acptr = FindClient(parv[1])) && !MyUser(acptr))) { - if (IsUser(acptr)) - parv[2] = cli_name(cli_user(acptr)->server); - else - parv[2] = cli_name(acptr); - parc = 3; - parv[3] = 0; - if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, IsServer(acptr), - "%s :%C", 2, parc, parv)) == HUNTED_NOSUCH) - return 0; - } else - i = HUNTED_ISME; - } else { - /* Got "TRACE :" */ - parc = 3; - if (MyUser(sptr) || Protocol(cptr) < 10) - acptr = find_match_server(parv[2]); - else - acptr = FindNServer(parv[2]); - if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, 0, "%s :%C", 2, parc, - parv)) == HUNTED_NOSUCH) - return 0; - tname = parv[1]; - } - - if (i == HUNTED_PASS) { - if (!acptr) - acptr = next_client(GlobalClientList, tname); - else - acptr = cli_from(acptr); - send_reply(sptr, RPL_TRACELINK, - version, debugmode, tname, - acptr ? cli_name(cli_from(acptr)) : ""); - return 0; - } - - doall = (parv[1] && (parc > 1)) ? !match(tname, cli_name(&me)) : 1; - wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?'); - dow = wilds || doall; - - /* Don't give (long) remote listings to lusers */ - if (dow && !MyConnect(sptr) && !IsAnOper(sptr)) - return 0; - - for (i = 0; i < MAXCONNECTIONS; i++) - link_s[i] = 0, link_u[i] = 0; - - if (doall) { - for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) { - if (IsUser(acptr)) - link_u[cli_fd(cli_from(acptr))]++; - else if (IsServer(acptr)) - link_s[cli_fd(cli_from(acptr))]++; - } - } - - /* report all direct connections */ - - for (i = 0; i <= HighestFd; i++) { - const char *conClass; - - if (!(acptr = LocalClientArray[i])) /* Local Connection? */ - continue; - if (IsInvisible(acptr) && dow && !(MyConnect(sptr) && IsOper(sptr)) && - !IsAnOper(acptr) && (acptr != sptr)) - continue; - if (!doall && wilds && match(tname, cli_name(acptr))) - continue; - if (!dow && 0 != ircd_strcmp(tname, cli_name(acptr))) - continue; - conClass = get_client_class(acptr); - - switch (cli_status(acptr)) { - case STAT_CONNECTING: - send_reply(sptr, RPL_TRACECONNECTING, conClass, cli_name(acptr)); - cnt++; - break; - case STAT_HANDSHAKE: - send_reply(sptr, RPL_TRACEHANDSHAKE, conClass, cli_name(acptr)); - cnt++; - break; - case STAT_ME: - break; - case STAT_UNKNOWN: - case STAT_UNKNOWN_USER: - send_reply(sptr, RPL_TRACEUNKNOWN, conClass, - get_client_name(acptr, HIDE_IP)); - cnt++; - break; - case STAT_UNKNOWN_SERVER: - send_reply(sptr, RPL_TRACEUNKNOWN, conClass, "Unknown Server"); - cnt++; - break; - case STAT_USER: - /* Only opers see users if there is a wildcard - but anyone can see all the opers. */ - if ((IsAnOper(sptr) && (MyUser(sptr) || - !(dow && IsInvisible(acptr)))) || !dow || IsAnOper(acptr)) { - if (IsAnOper(acptr)) - send_reply(sptr, RPL_TRACEOPERATOR, conClass, - get_client_name(acptr, SHOW_IP), - CurrentTime - cli_lasttime(acptr)); - else - send_reply(sptr, RPL_TRACEUSER, conClass, - get_client_name(acptr, SHOW_IP), - CurrentTime - cli_lasttime(acptr)); - cnt++; - } - break; - /* - * Connection is a server - * - * Serv - * - * class Class the server is in - * nS Number of servers reached via this link - * nC Number of clients reached via this link - * name Name of the server linked - * ConnBy Who established this link - * last Seconds since we got something from this link - * age Seconds this link has been alive - * - * Additional comments etc...... -Cym- - */ - - case STAT_SERVER: - if (cli_serv(acptr)->user) - send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i], - link_u[i], cli_name(acptr), - (*(cli_serv(acptr))->by) ? cli_serv(acptr)->by : "*", - cli_serv(acptr)->user->username, cli_serv(acptr)->user->host, - CurrentTime - cli_lasttime(acptr), - CurrentTime - cli_serv(acptr)->timestamp); - else - send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i], - link_u[i], cli_name(acptr), - (*(cli_serv(acptr))->by) ? cli_serv(acptr)->by : "*", "*", - cli_name(&me), CurrentTime - cli_lasttime(acptr), - CurrentTime - cli_serv(acptr)->timestamp); - cnt++; - break; - default: /* We actually shouldn't come here, -msa */ - send_reply(sptr, RPL_TRACENEWTYPE, get_client_name(acptr, HIDE_IP)); - cnt++; - break; - } - } - /* - * Add these lines to summarize the above which can get rather long - * and messy when done remotely - Avalon - */ - if (!IsAnOper(sptr) || !cnt) { - if (!cnt) - /* let the user have some idea that its at the end of the trace */ - send_reply(sptr, RPL_TRACESERVER, 0, link_s[cli_fd(&me)], - link_u[cli_fd(&me)], "", *(cli_serv(&me)->by) ? - cli_serv(&me)->by : "*", "*", cli_name(&me), 0, 0); - return 0; - } - if (doall) { - for (cl = get_class_list(); cl; cl = cl->next) { - if (Links(cl) > 0) - send_reply(sptr, RPL_TRACECLASS, ConClass(cl), Links(cl)); - } - } + if (feature_bool(FEAT_HIS_TRACE) && !IsAnOper(sptr)) + return send_reply(cptr, ERR_NOPRIVILEGES); + do_trace(cptr, sptr, parc, parv); return 0; } - - diff --git a/ircd/s_err.c b/ircd/s_err.c index 79da7b9..46feebf 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -556,7 +556,7 @@ static Numeric replyTable[] = { /* 261 */ { RPL_TRACELOG, "File %s %d", "261" }, /* 262 */ - { RPL_TRACEPING, "Ping %s %s", "262" }, + { RPL_TRACEEND, ":End of TRACE", "262" }, /* 263 */ { 0 }, /* 264 */