/[svn]/ircd-hybrid-8/modules/m_etrace.c
ViewVC logotype

Contents of /ircd-hybrid-8/modules/m_etrace.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1219 - (show annotations)
Sun Sep 18 09:02:38 2011 UTC (8 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 5617 byte(s)
- Start cleaning up macros in client.h. Replace several ClientHasSomeCoolFlag()
with simple HasFlag/HasUMode macros.

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_etrace.c: Traces a path to a client/server.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "handlers.h"
28 #include "hook.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "common.h"
32 #include "irc_string.h"
33 #include "ircd.h"
34 #include "numeric.h"
35 #include "fdlist.h"
36 #include "s_bsd.h"
37 #include "s_serv.h"
38 #include "send.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "s_conf.h"
43
44
45 static void do_etrace(struct Client *, int, char *[]);
46 static void mo_etrace(struct Client *, struct Client *, int, char *[]);
47
48 struct Message etrace_msgtab = {
49 "ETRACE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
50 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
51 };
52
53 const char *_version = "$Revision$";
54
55 void
56 _modinit(void)
57 {
58 mod_add_cmd(&etrace_msgtab);
59 }
60
61 void
62 _moddeinit(void)
63 {
64 mod_del_cmd(&etrace_msgtab);
65 }
66
67 static void report_this_status(struct Client *, struct Client *, int);
68
69 /*
70 * do_etrace()
71 */
72 static void
73 do_etrace(struct Client *source_p, int parc, char *parv[])
74 {
75 const char *tname = NULL;
76 struct Client *target_p = NULL;
77 int wilds = 0;
78 int do_all = 0;
79 int full_etrace = 0;
80 dlink_node *ptr;
81
82 sendto_realops_flags(UMODE_SPY, L_ALL,
83 "ETRACE requested by %s (%s@%s) [%s]",
84 source_p->name, source_p->username,
85 source_p->host, source_p->servptr->name);
86
87 if (parc > 1)
88 {
89 if (irccmp(parv[1], "-full") == 0)
90 {
91 ++parv;
92 --parc;
93 full_etrace = 1;
94 }
95 }
96
97 if (parc > 1)
98 {
99 tname = parv[1];
100
101 if (tname != NULL)
102 wilds = strchr(tname, '*') || strchr(tname, '?');
103 else
104 tname = "*";
105 }
106 else
107 {
108 do_all = 1;
109 tname = "*";
110 }
111
112 if (HasUMode(source_p, UMODE_CCONN_FULL))
113 full_etrace = 1;
114
115 if (!wilds && !do_all)
116 {
117 target_p = hash_find_client(tname);
118
119 if (target_p && MyClient(target_p))
120 report_this_status(source_p, target_p, full_etrace);
121
122 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
123 source_p->name, tname);
124 return;
125 }
126
127 DLINK_FOREACH(ptr, local_client_list.head)
128 {
129 target_p = ptr->data;
130
131 if (wilds)
132 {
133 if (match(tname, target_p->name))
134 report_this_status(source_p, target_p, full_etrace);
135 }
136 else
137 report_this_status(source_p, target_p, full_etrace);
138 }
139
140 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
141 source_p->name, tname);
142 }
143
144 /* mo_etrace()
145 * parv[0] = sender prefix
146 * parv[1] = servername
147 */
148 static void
149 mo_etrace(struct Client *client_p, struct Client *source_p,
150 int parc, char *parv[])
151 {
152 do_etrace(source_p, parc, parv);
153 }
154
155 /* report_this_status()
156 *
157 * inputs - pointer to client to report to
158 * - pointer to client to report about
159 * - flag full etrace or not
160 * output - NONE
161 * side effects - NONE
162 */
163 static void
164 report_this_status(struct Client *source_p, struct Client *target_p,
165 int full_etrace)
166 {
167 const char *name;
168 const char *class_name;
169
170 name = get_client_name(target_p, HIDE_IP);
171 class_name = get_client_class(target_p);
172
173 set_time();
174
175 if (target_p->status == STAT_CLIENT)
176 {
177 if (full_etrace)
178 {
179 if (ConfigFileEntry.hide_spoof_ips)
180 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
181 me.name,
182 source_p->name,
183 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
184 class_name,
185 target_p->name,
186 target_p->username,
187 target_p->host,
188 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
189 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_host,
190 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_server,
191 target_p->info);
192 else
193 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
194 me.name,
195 source_p->name,
196 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
197 class_name,
198 target_p->name,
199 target_p->username,
200 target_p->host,
201 target_p->sockhost,
202 target_p->localClient->client_host,
203 target_p->localClient->client_server,
204 target_p->info);
205 }
206 else
207 {
208 if (ConfigFileEntry.hide_spoof_ips)
209 sendto_one(source_p, form_str(RPL_ETRACE),
210 me.name,
211 source_p->name,
212 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
213 class_name,
214 target_p->name,
215 target_p->username,
216 target_p->host,
217 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
218 target_p->info);
219 else
220 sendto_one(source_p, form_str(RPL_ETRACE),
221 me.name,
222 source_p->name,
223 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
224 class_name,
225 target_p->name,
226 target_p->username,
227 target_p->host,
228 target_p->sockhost,
229 target_p->info);
230 }
231 }
232 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28