ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 8066
Committed: Thu Mar 23 17:38:28 2017 UTC (9 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4766 byte(s)
Log Message:
- m_etrace.c: add support for remote ETRACE

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, int parc, char *parv[])
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(parv[1]))
81 {
82 do_all = 1;
83 tname = "*";
84 }
85 else
86 {
87 tname = parv[1];
88 wilds = has_wildcards(tname);
89 }
90
91 if (!wilds && !do_all)
92 {
93 const struct Client *target_p = find_person(source_p, tname);
94
95 if (target_p && MyConnect(target_p))
96 report_this_status(source_p, target_p);
97
98 sendto_one_numeric(source_p, &me, RPL_TRACEEND, tname);
99 return;
100 }
101
102 DLINK_FOREACH(node, local_client_list.head)
103 {
104 const struct Client *target_p = node->data;
105
106 if (!wilds || !match(tname, target_p->name))
107 report_this_status(source_p, target_p);
108 }
109
110 sendto_one_numeric(source_p, &me, RPL_TRACEEND, tname);
111 }
112
113 /*! \brief ETRACE command handler
114 *
115 * \param source_p Pointer to allocated Client struct from which the message
116 * originally comes from. This can be a local or remote client.
117 * \param parc Integer holding the number of supplied arguments.
118 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
119 * pointers.
120 * \note Valid arguments for this command are:
121 * - parv[0] = command
122 * - parv[1] = nick name to trace
123 * - parv[2] = nick or server name to forward the etrace to
124 */
125 static int
126 mo_etrace(struct Client *source_p, int parc, char *parv[])
127 {
128 if (parc > 2)
129 if (server_hunt(source_p, ":%s ETRACE %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
130 return 0;
131
132 const struct server_hunt *hunt = server_hunt(source_p, ":%s ETRACE :%s", 1, parc, parv);
133 switch (hunt->ret)
134 {
135 case HUNTED_PASS:
136 sendto_one_numeric(source_p, &me, RPL_TRACELINK,
137 ircd_version, hunt->target_p->name, hunt->target_p->from->name);
138 break;
139 case HUNTED_ISME:
140 do_etrace(source_p, parc, parv);
141 break;
142 default:
143 break;
144 }
145
146 return 0;
147 }
148
149 static struct Message etrace_msgtab =
150 {
151 .cmd = "ETRACE",
152 .args_max = MAXPARA,
153 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
154 .handlers[CLIENT_HANDLER] = m_not_oper,
155 .handlers[SERVER_HANDLER] = mo_etrace,
156 .handlers[ENCAP_HANDLER] = m_ignore,
157 .handlers[OPER_HANDLER] = mo_etrace
158 };
159
160 static void
161 module_init(void)
162 {
163 mod_add_cmd(&etrace_msgtab);
164 }
165
166 static void
167 module_exit(void)
168 {
169 mod_del_cmd(&etrace_msgtab);
170 }
171
172 struct module module_entry =
173 {
174 .version = "$Revision$",
175 .modinit = module_init,
176 .modexit = module_exit,
177 };

Properties

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