ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 8084
Committed: Sun Mar 26 10:15:47 2017 UTC (9 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4882 byte(s)
Log Message:
- Add RPL_ETRACEEND numeric taken from irc2.11

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2004-2017 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_etrace.c
23 * \brief Includes required functions for processing the ETRACE command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "server.h"
35 #include "send.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "conf.h"
39
40
41 /* report_this_status()
42 *
43 * inputs - pointer to client to report to
44 * - pointer to client to report about
45 * - flag full etrace or not
46 * output - NONE
47 * side effects - NONE
48 */
49 static void
50 report_this_status(struct Client *source_p, const struct Client *target_p)
51 {
52 if (target_p->status != STAT_CLIENT)
53 return;
54
55 sendto_one_numeric(source_p, &me, RPL_ETRACE,
56 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
57 get_client_class(&target_p->connection->confs),
58 target_p->name,
59 target_p->username,
60 target_p->host,
61 target_p->sockhost,
62 target_p->info);
63 }
64
65 /*
66 * do_etrace()
67 */
68 static void
69 do_etrace(struct Client *source_p, const char *arg)
70 {
71 const char *tname = NULL;
72 unsigned int wilds = 0, do_all = 0;
73 dlink_node *node;
74
75 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
76 "ETRACE requested by %s (%s@%s) [%s]",
77 source_p->name, source_p->username,
78 source_p->host, source_p->servptr->name);
79
80 if (EmptyString(arg))
81 {
82 do_all = 1;
83 tname = "*";
84 }
85 else
86 {
87 tname = arg;
88 wilds = has_wildcards(tname);
89
90 if (!match(tname, me.name))
91 do_all = 1;
92 else if (!MyClient(source_p) && !strcmp(tname, me.id))
93 do_all = 1;
94 }
95
96 if (!wilds && !do_all)
97 {
98 const struct Client *target_p = find_person(source_p, tname);
99
100 if (target_p && MyConnect(target_p))
101 report_this_status(source_p, target_p);
102
103 sendto_one_numeric(source_p, &me, RPL_ETRACEEND, me.name);
104 return;
105 }
106
107 DLINK_FOREACH(node, local_client_list.head)
108 {
109 const struct Client *target_p = node->data;
110
111 if (!wilds || !match(tname, target_p->name))
112 report_this_status(source_p, target_p);
113 }
114
115 sendto_one_numeric(source_p, &me, RPL_ETRACEEND, me.name);
116 }
117
118 /*! \brief ETRACE command handler
119 *
120 * \param source_p Pointer to allocated Client struct from which the message
121 * originally comes from. This can be a local or remote client.
122 * \param parc Integer holding the number of supplied arguments.
123 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
124 * pointers.
125 * \note Valid arguments for this command are:
126 * - parv[0] = command
127 * - parv[1] = nick name to trace
128 * - parv[2] = nick or server name to forward the etrace to
129 */
130 static int
131 mo_etrace(struct Client *source_p, int parc, char *parv[])
132 {
133 if (parc > 2)
134 if (server_hunt(source_p, ":%s ETRACE %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
135 return 0;
136
137 const struct server_hunt *hunt = server_hunt(source_p, ":%s ETRACE :%s", 1, parc, parv);
138 switch (hunt->ret)
139 {
140 case HUNTED_PASS:
141 sendto_one_numeric(source_p, &me, RPL_TRACELINK,
142 ircd_version, hunt->target_p->name, hunt->target_p->from->name);
143 break;
144 case HUNTED_ISME:
145 do_etrace(source_p, parv[1]);
146 break;
147 default:
148 break;
149 }
150
151 return 0;
152 }
153
154 static struct Message etrace_msgtab =
155 {
156 .cmd = "ETRACE",
157 .args_max = MAXPARA,
158 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
159 .handlers[CLIENT_HANDLER] = m_not_oper,
160 .handlers[SERVER_HANDLER] = mo_etrace,
161 .handlers[ENCAP_HANDLER] = m_ignore,
162 .handlers[OPER_HANDLER] = mo_etrace
163 };
164
165 static void
166 module_init(void)
167 {
168 mod_add_cmd(&etrace_msgtab);
169 }
170
171 static void
172 module_exit(void)
173 {
174 mod_del_cmd(&etrace_msgtab);
175 }
176
177 struct module module_entry =
178 {
179 .version = "$Revision$",
180 .modinit = module_init,
181 .modexit = module_exit,
182 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision