ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.3/modules/m_etrace.c
Revision: 1114
Committed: Mon Dec 20 20:33:05 2010 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 5809 byte(s)
Log Message:
- Move RPL_ETRACE to messages.tab
- CHANGE RPL_WHOISSSL to use the 671 numeric

File Contents

# Content
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, 0, MFLG_SLOW, 0,
50 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
51 };
52
53 #ifndef STATIC_MODULES
54 const char *_version = "$Revision$";
55 static struct Callback *etrace_cb;
56
57 static void *
58 va_etrace(va_list args)
59 {
60 struct Client *source_p = va_arg(args, struct Client *);
61 int parc = va_arg(args, int);
62 char **parv = va_arg(args, char **);
63
64 do_etrace(source_p, parc, parv);
65 return NULL;
66 }
67
68 void
69 _modinit(void)
70 {
71 etrace_cb = register_callback("doing_etrace", va_etrace);
72 mod_add_cmd(&etrace_msgtab);
73 }
74
75 void
76 _moddeinit(void)
77 {
78 mod_del_cmd(&etrace_msgtab);
79 uninstall_hook(etrace_cb, va_etrace);
80 }
81 #endif
82
83 static void report_this_status(struct Client *, struct Client *, int);
84
85 /*
86 * do_etrace()
87 */
88 static void
89 do_etrace(struct Client *source_p, int parc, char **parv)
90 {
91 const char *tname = NULL;
92 struct Client *target_p = NULL;
93 int wilds = 0;
94 int do_all = 0;
95 int full_etrace = 0;
96 dlink_node *ptr;
97
98 if (parc > 1)
99 {
100 if (irccmp(parv[1], "-full") == 0)
101 {
102 parv++;
103 parc--;
104 full_etrace = 1;
105 }
106 }
107
108 if (parc > 1)
109 {
110 tname = parv[1];
111
112 if (tname != NULL)
113 wilds = strchr(tname, '*') || strchr(tname, '?');
114 else
115 tname = "*";
116 }
117 else
118 {
119 do_all = 1;
120 tname = "*";
121 }
122
123 if (IsFull(source_p))
124 full_etrace = 1;
125
126 if (!wilds && !do_all)
127 {
128 target_p = find_client(tname);
129
130 if (target_p && MyClient(target_p))
131 report_this_status(source_p, target_p, full_etrace);
132
133 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
134 source_p->name, tname);
135 return;
136 }
137
138 DLINK_FOREACH(ptr, local_client_list.head)
139 {
140 target_p = ptr->data;
141
142 if (wilds)
143 {
144 if (match(tname, target_p->name) || match(target_p->name, tname))
145 report_this_status(source_p, target_p, full_etrace);
146 }
147 else
148 report_this_status(source_p, target_p, full_etrace);
149 }
150
151 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
152 source_p->name, tname);
153 }
154
155 /* mo_etrace()
156 * parv[0] = sender prefix
157 * parv[1] = servername
158 */
159 static void
160 mo_etrace(struct Client *client_p, struct Client *source_p,
161 int parc, char *parv[])
162 {
163 #ifdef STATIC_MODULES
164 do_etrace(source_p, parc, parv);
165 #else
166 execute_callback(etrace_cb, source_p, parc, parv);
167 #endif
168 }
169
170 /* report_this_status()
171 *
172 * inputs - pointer to client to report to
173 * - pointer to client to report about
174 * - flag full etrace or not
175 * output - NONE
176 * side effects - NONE
177 */
178 static void
179 report_this_status(struct Client *source_p, struct Client *target_p,
180 int full_etrace)
181 {
182 const char *name;
183 const char *class_name;
184
185 name = get_client_name(target_p, HIDE_IP);
186 class_name = get_client_class(target_p);
187
188 set_time();
189
190 if (target_p->status == STAT_CLIENT)
191 {
192 if (full_etrace)
193 {
194 if (ConfigFileEntry.hide_spoof_ips)
195 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
196 me.name,
197 source_p->name,
198 IsOper(target_p) ? "Oper" : "User",
199 class_name,
200 target_p->name,
201 target_p->username,
202 target_p->host,
203 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
204 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_host,
205 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_server,
206 target_p->info);
207 else
208 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
209 me.name,
210 source_p->name,
211 IsOper(target_p) ? "Oper" : "User",
212 class_name,
213 target_p->name,
214 target_p->username,
215 target_p->host,
216 target_p->sockhost,
217 target_p->localClient->client_host,
218 target_p->localClient->client_server,
219 target_p->info);
220 }
221 else
222 {
223 if (ConfigFileEntry.hide_spoof_ips)
224 sendto_one(source_p, form_str(RPL_ETRACE),
225 me.name,
226 source_p->name,
227 IsOper(target_p) ? "Oper" : "User",
228 class_name,
229 target_p->name,
230 target_p->username,
231 target_p->host,
232 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
233 target_p->info);
234 else
235 sendto_one(source_p, form_str(RPL_ETRACE),
236 me.name,
237 source_p->name,
238 IsOper(target_p) ? "Oper" : "User",
239 class_name,
240 target_p->name,
241 target_p->username,
242 target_p->host,
243 target_p->sockhost,
244 target_p->info);
245 }
246 }
247 }

Properties

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