ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 3580
Committed: Sat May 17 17:26:25 2014 UTC (12 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 4346 byte(s)
Log Message:
- m_etrace.c: further cleanups

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2004-2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 "send.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "conf.h"
38
39
40 /* report_this_status()
41 *
42 * inputs - pointer to client to report to
43 * - pointer to client to report about
44 * - flag full etrace or not
45 * output - NONE
46 * side effects - NONE
47 */
48 static void
49 report_this_status(struct Client *source_p, const struct Client *target_p)
50 {
51 if (target_p->status != STAT_CLIENT)
52 return;
53
54 if (ConfigFileEntry.hide_spoof_ips)
55 sendto_one_numeric(source_p, &me, RPL_ETRACE,
56 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
57 get_client_class(&target_p->localClient->confs),
58 target_p->name,
59 target_p->username,
60 target_p->host,
61 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
62 target_p->info);
63 else
64 sendto_one_numeric(source_p, &me, RPL_ETRACE,
65 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
66 get_client_class(&target_p->localClient->confs),
67 target_p->name,
68 target_p->username,
69 target_p->host,
70 target_p->sockhost,
71 target_p->info);
72 }
73
74 /*
75 * do_etrace()
76 */
77 static void
78 do_etrace(struct Client *source_p, const char *arg)
79 {
80 const char *tname = NULL;
81 unsigned int wilds = 0, do_all = 0;
82 const dlink_node *ptr = NULL;
83
84 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
85 "ETRACE requested by %s (%s@%s) [%s]",
86 source_p->name, source_p->username,
87 source_p->host, source_p->servptr->name);
88
89 if (!EmptyString(arg))
90 {
91 tname = arg;
92
93 if (tname)
94 wilds = has_wildcards(tname);
95 else
96 tname = "*";
97 }
98 else
99 {
100 do_all = 1;
101 tname = "*";
102 }
103
104 if (!wilds && !do_all)
105 {
106 const struct Client *target_p = hash_find_client(tname);
107
108 if (target_p && MyClient(target_p))
109 report_this_status(source_p, target_p);
110
111 sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname);
112 return;
113 }
114
115 DLINK_FOREACH(ptr, local_client_list.head)
116 {
117 const struct Client *target_p = ptr->data;
118
119 if (wilds)
120 {
121 if (!match(tname, target_p->name))
122 report_this_status(source_p, target_p);
123 }
124 else
125 report_this_status(source_p, target_p);
126 }
127
128 sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname);
129 }
130
131 /* mo_etrace()
132 * parv[0] = command
133 * parv[1] = servername
134 */
135 static int
136 mo_etrace(struct Client *source_p, int parc, char *parv[])
137 {
138 do_etrace(source_p, parv[1]);
139 return 0;
140 }
141
142 static struct Message etrace_msgtab =
143 {
144 "ETRACE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
145 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore }
146 };
147
148 static void
149 module_init(void)
150 {
151 mod_add_cmd(&etrace_msgtab);
152 }
153
154 static void
155 module_exit(void)
156 {
157 mod_del_cmd(&etrace_msgtab);
158 }
159
160 struct module module_entry =
161 {
162 .node = { NULL, NULL, NULL },
163 .name = NULL,
164 .version = "$Revision$",
165 .handle = NULL,
166 .modinit = module_init,
167 .modexit = module_exit,
168 .flags = 0
169 };

Properties

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