ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 9857
Committed: Fri Jan 1 04:43:22 2021 UTC (5 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4551 byte(s)
Log Message:
- Bump copyright years

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 9857 * Copyright (c) 2004-2021 ircd-hybrid development team
5 adx 30 *
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 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_etrace.c
23     * \brief Includes required functions for processing the ETRACE command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #include "client.h"
30     #include "hash.h"
31     #include "irc_string.h"
32     #include "ircd.h"
33     #include "numeric.h"
34 michael 8066 #include "server.h"
35 adx 30 #include "send.h"
36     #include "parse.h"
37     #include "modules.h"
38 michael 1309 #include "conf.h"
39 michael 8729 #include "patchlevel.h"
40 adx 30
41    
42 michael 2968 /* 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 michael 3578 report_this_status(struct Client *source_p, const struct Client *target_p)
52 michael 2968 {
53 michael 3578 if (target_p->status != STAT_CLIENT)
54 michael 3787 return;
55 michael 3578
56 michael 4967 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 michael 2968 }
65 adx 30
66     /*
67     * do_etrace()
68     */
69     static void
70 michael 8259 do_etrace(struct Client *source_p, const char *name)
71 adx 30 {
72 michael 8656 bool doall = false;
73 michael 7687 dlink_node *node;
74 adx 30
75 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
76 michael 1144 "ETRACE requested by %s (%s@%s) [%s]",
77     source_p->name, source_p->username,
78     source_p->host, source_p->servptr->name);
79    
80 michael 8259 if (EmptyString(name))
81 michael 8656 doall = true;
82 michael 8603 else if (match(name, me.name) == 0)
83 michael 8656 doall = true;
84 michael 8603 else if (!MyClient(source_p) && strcmp(name, me.id) == 0)
85 michael 8656 doall = true;
86 michael 8080
87 michael 4815 DLINK_FOREACH(node, local_client_list.head)
88 adx 30 {
89 michael 4815 const struct Client *target_p = node->data;
90 adx 30
91 michael 8656 if (doall == true || match(name, target_p->name) == 0)
92 michael 2189 report_this_status(source_p, target_p);
93 adx 30 }
94    
95 michael 8084 sendto_one_numeric(source_p, &me, RPL_ETRACEEND, me.name);
96 adx 30 }
97    
98 michael 8066 /*! \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 adx 30 */
110 michael 9077 static void
111 michael 3156 mo_etrace(struct Client *source_p, int parc, char *parv[])
112 adx 30 {
113 michael 8066 if (parc > 2)
114 michael 9397 if (server_hunt(source_p, ":%s ETRACE %s :%s", 2, parv)->ret != HUNTED_ISME)
115 michael 9077 return;
116 michael 8066
117 michael 9397 const struct server_hunt *hunt = server_hunt(source_p, ":%s ETRACE :%s", 1, parv);
118 michael 8066 switch (hunt->ret)
119     {
120     case HUNTED_PASS:
121     sendto_one_numeric(source_p, &me, RPL_TRACELINK,
122 michael 8729 PATCHLEVEL, hunt->target_p->name, hunt->target_p->from->name);
123 michael 8066 break;
124     case HUNTED_ISME:
125 michael 8078 do_etrace(source_p, parv[1]);
126 michael 8066 break;
127     default:
128     break;
129     }
130 adx 30 }
131    
132 michael 2820 static struct Message etrace_msgtab =
133     {
134 michael 5881 .cmd = "ETRACE",
135 michael 9374 .handlers[UNREGISTERED_HANDLER] = { .handler = m_unregistered },
136     .handlers[CLIENT_HANDLER] = { .handler = m_not_oper },
137     .handlers[SERVER_HANDLER] = { .handler = mo_etrace },
138     .handlers[ENCAP_HANDLER] = { .handler = m_ignore },
139     .handlers[OPER_HANDLER] = { .handler = mo_etrace }
140 michael 1230 };
141    
142     static void
143     module_init(void)
144     {
145     mod_add_cmd(&etrace_msgtab);
146     }
147    
148     static void
149     module_exit(void)
150     {
151     mod_del_cmd(&etrace_msgtab);
152     }
153    
154 michael 2820 struct module module_entry =
155     {
156 michael 1230 .version = "$Revision$",
157     .modinit = module_init,
158     .modexit = module_exit,
159     };

Properties

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