ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (14 years, 4 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_etrace.c
File size: 5599 byte(s)
Log Message:
- renaming files:

  ircd_parser.y -> conf_parser.y
  ircd_lexer.l  -> conf_lexer.l
  s_conf.c      -> conf.c
  s_conf.h      -> conf.h
  s_log.c       -> log.c
  s_log.h       -> log.h

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 "client.h"
28 #include "hash.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "fdlist.h"
33 #include "s_bsd.h"
34 #include "s_serv.h"
35 #include "send.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "conf.h"
39
40
41 static void report_this_status(struct Client *, struct Client *, int);
42
43 /*
44 * do_etrace()
45 */
46 static void
47 do_etrace(struct Client *source_p, int parc, char *parv[])
48 {
49 const char *tname = NULL;
50 struct Client *target_p = NULL;
51 int wilds = 0;
52 int do_all = 0;
53 int full_etrace = 0;
54 dlink_node *ptr;
55
56 sendto_realops_flags(UMODE_SPY, L_ALL,
57 "ETRACE requested by %s (%s@%s) [%s]",
58 source_p->name, source_p->username,
59 source_p->host, source_p->servptr->name);
60
61 if (parc > 1)
62 {
63 if (irccmp(parv[1], "-full") == 0)
64 {
65 ++parv;
66 --parc;
67 full_etrace = 1;
68 }
69 }
70
71 if (parc > 1)
72 {
73 tname = parv[1];
74
75 if (tname != NULL)
76 wilds = strchr(tname, '*') || strchr(tname, '?');
77 else
78 tname = "*";
79 }
80 else
81 {
82 do_all = 1;
83 tname = "*";
84 }
85
86 if (HasUMode(source_p, UMODE_CCONN_FULL))
87 full_etrace = 1;
88
89 if (!wilds && !do_all)
90 {
91 target_p = hash_find_client(tname);
92
93 if (target_p && MyClient(target_p))
94 report_this_status(source_p, target_p, full_etrace);
95
96 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
97 source_p->name, tname);
98 return;
99 }
100
101 DLINK_FOREACH(ptr, local_client_list.head)
102 {
103 target_p = ptr->data;
104
105 if (wilds)
106 {
107 if (match(tname, target_p->name))
108 report_this_status(source_p, target_p, full_etrace);
109 }
110 else
111 report_this_status(source_p, target_p, full_etrace);
112 }
113
114 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
115 source_p->name, tname);
116 }
117
118 /* mo_etrace()
119 * parv[0] = sender prefix
120 * parv[1] = servername
121 */
122 static void
123 mo_etrace(struct Client *client_p, struct Client *source_p,
124 int parc, char *parv[])
125 {
126 do_etrace(source_p, parc, parv);
127 }
128
129 /* report_this_status()
130 *
131 * inputs - pointer to client to report to
132 * - pointer to client to report about
133 * - flag full etrace or not
134 * output - NONE
135 * side effects - NONE
136 */
137 static void
138 report_this_status(struct Client *source_p, struct Client *target_p,
139 int full_etrace)
140 {
141 const char *name;
142 const char *class_name;
143
144 name = get_client_name(target_p, HIDE_IP);
145 class_name = get_client_class(target_p);
146
147 set_time();
148
149 if (target_p->status == STAT_CLIENT)
150 {
151 if (full_etrace)
152 {
153 if (ConfigFileEntry.hide_spoof_ips)
154 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
155 me.name,
156 source_p->name,
157 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
158 class_name,
159 target_p->name,
160 target_p->username,
161 target_p->host,
162 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
163 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_host,
164 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_server,
165 target_p->info);
166 else
167 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
168 me.name,
169 source_p->name,
170 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
171 class_name,
172 target_p->name,
173 target_p->username,
174 target_p->host,
175 target_p->sockhost,
176 target_p->localClient->client_host,
177 target_p->localClient->client_server,
178 target_p->info);
179 }
180 else
181 {
182 if (ConfigFileEntry.hide_spoof_ips)
183 sendto_one(source_p, form_str(RPL_ETRACE),
184 me.name,
185 source_p->name,
186 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
187 class_name,
188 target_p->name,
189 target_p->username,
190 target_p->host,
191 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
192 target_p->info);
193 else
194 sendto_one(source_p, form_str(RPL_ETRACE),
195 me.name,
196 source_p->name,
197 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
198 class_name,
199 target_p->name,
200 target_p->username,
201 target_p->host,
202 target_p->sockhost,
203 target_p->info);
204 }
205 }
206 }
207
208 static struct Message etrace_msgtab = {
209 "ETRACE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
210 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
211 };
212
213 static void
214 module_init(void)
215 {
216 mod_add_cmd(&etrace_msgtab);
217 }
218
219 static void
220 module_exit(void)
221 {
222 mod_del_cmd(&etrace_msgtab);
223 }
224
225 struct module module_entry = {
226 .node = { NULL, NULL, NULL },
227 .name = NULL,
228 .version = "$Revision$",
229 .handle = NULL,
230 .modinit = module_init,
231 .modexit = module_exit,
232 .flags = 0
233 };

Properties

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