ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 8752
Committed: Tue Jan 1 11:07:01 2019 UTC (5 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 4525 byte(s)
Log Message:
- Update copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2004-2019 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 #include "patchlevel.h"
40
41
42 /* report_this_status()
43 *
44 * inputs - pointer to client to report to
45 * - pointer to client to report about
46 * - flag full etrace or not
47 * output - NONE
48 * side effects - NONE
49 */
50 static void
51 report_this_status(struct Client *source_p, const struct Client *target_p)
52 {
53 if (target_p->status != STAT_CLIENT)
54 return;
55
56 sendto_one_numeric(source_p, &me, RPL_ETRACE,
57 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
58 get_client_class(&target_p->connection->confs),
59 target_p->name,
60 target_p->username,
61 target_p->host,
62 target_p->sockhost,
63 target_p->info);
64 }
65
66 /*
67 * do_etrace()
68 */
69 static void
70 do_etrace(struct Client *source_p, const char *name)
71 {
72 bool doall = false;
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(name))
81 doall = true;
82 else if (match(name, me.name) == 0)
83 doall = true;
84 else if (!MyClient(source_p) && strcmp(name, me.id) == 0)
85 doall = true;
86
87 DLINK_FOREACH(node, local_client_list.head)
88 {
89 const struct Client *target_p = node->data;
90
91 if (doall == true || match(name, target_p->name) == 0)
92 report_this_status(source_p, target_p);
93 }
94
95 sendto_one_numeric(source_p, &me, RPL_ETRACEEND, me.name);
96 }
97
98 /*! \brief ETRACE command handler
99 *
100 * \param source_p Pointer to allocated Client struct from which the message
101 * originally comes from. This can be a local or remote client.
102 * \param parc Integer holding the number of supplied arguments.
103 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
104 * pointers.
105 * \note Valid arguments for this command are:
106 * - parv[0] = command
107 * - parv[1] = nick name to trace
108 * - parv[2] = nick or server name to forward the etrace to
109 */
110 static int
111 mo_etrace(struct Client *source_p, int parc, char *parv[])
112 {
113 if (parc > 2)
114 if (server_hunt(source_p, ":%s ETRACE %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
115 return 0;
116
117 const struct server_hunt *hunt = server_hunt(source_p, ":%s ETRACE :%s", 1, parc, parv);
118 switch (hunt->ret)
119 {
120 case HUNTED_PASS:
121 sendto_one_numeric(source_p, &me, RPL_TRACELINK,
122 PATCHLEVEL, hunt->target_p->name, hunt->target_p->from->name);
123 break;
124 case HUNTED_ISME:
125 do_etrace(source_p, parv[1]);
126 break;
127 default:
128 break;
129 }
130
131 return 0;
132 }
133
134 static struct Message etrace_msgtab =
135 {
136 .cmd = "ETRACE",
137 .args_max = MAXPARA,
138 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
139 .handlers[CLIENT_HANDLER] = m_not_oper,
140 .handlers[SERVER_HANDLER] = mo_etrace,
141 .handlers[ENCAP_HANDLER] = m_ignore,
142 .handlers[OPER_HANDLER] = mo_etrace
143 };
144
145 static void
146 module_init(void)
147 {
148 mod_add_cmd(&etrace_msgtab);
149 }
150
151 static void
152 module_exit(void)
153 {
154 mod_del_cmd(&etrace_msgtab);
155 }
156
157 struct module module_entry =
158 {
159 .version = "$Revision$",
160 .modinit = module_init,
161 .modexit = module_exit,
162 };

Properties

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