ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 1118
Committed: Thu Jan 6 13:39:10 2011 UTC (15 years, 6 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_etrace.c
File size: 5777 byte(s)
Log Message:
- cleanup and sanitize m_server.c. remove hostmasking. Improve TS6 suppport

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #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 michael 172 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
51 adx 30 };
52    
53     #ifndef STATIC_MODULES
54 knight 31 const char *_version = "$Revision$";
55 adx 30 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 db 849 static void report_this_status(struct Client *, struct Client *, int);
84 adx 30
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 db 849 int full_etrace = 0;
96 adx 30 dlink_node *ptr;
97    
98 db 849 if (parc > 1)
99 adx 30 {
100 db 849 if (irccmp(parv[1], "-full") == 0)
101     {
102     parv++;
103     parc--;
104     full_etrace = 1;
105     }
106     }
107    
108     if (parc > 1)
109     {
110 adx 30 tname = parv[1];
111 db 849
112 adx 30 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 db 856 if (IsFull(source_p))
124     full_etrace = 1;
125    
126 adx 30 if (!wilds && !do_all)
127     {
128     target_p = find_client(tname);
129    
130     if (target_p && MyClient(target_p))
131 db 849 report_this_status(source_p, target_p, full_etrace);
132 adx 30
133     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
134 michael 891 source_p->name, tname);
135 adx 30 return;
136     }
137    
138     DLINK_FOREACH(ptr, local_client_list.head)
139     {
140     target_p = ptr->data;
141    
142     if (wilds)
143     {
144 michael 1118 if (match(tname, target_p->name))
145 michael 891 report_this_status(source_p, target_p, full_etrace);
146 adx 30 }
147     else
148 db 849 report_this_status(source_p, target_p, full_etrace);
149 adx 30 }
150    
151     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
152 michael 891 source_p->name, tname);
153 adx 30 }
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 michael 1114 int parc, char *parv[])
162 adx 30 {
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 db 849 * - flag full etrace or not
175 adx 30 * output - NONE
176     * side effects - NONE
177     */
178     static void
179 db 849 report_this_status(struct Client *source_p, struct Client *target_p,
180 michael 1114 int full_etrace)
181 adx 30 {
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 db 849 if (full_etrace)
193     {
194     if (ConfigFileEntry.hide_spoof_ips)
195 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
196 db 849 me.name,
197     source_p->name,
198     IsOper(target_p) ? "Oper" : "User",
199     class_name,
200     target_p->name,
201     target_p->username,
202 db 856 target_p->host,
203 michael 891 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
204 michael 1113 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_host,
205     IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_server,
206 db 849 target_p->info);
207     else
208 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
209 db 849 me.name,
210     source_p->name,
211     IsOper(target_p) ? "Oper" : "User",
212     class_name,
213     target_p->name,
214     target_p->username,
215 db 856 target_p->host,
216 michael 891 target_p->sockhost,
217 michael 1113 target_p->localClient->client_host,
218     target_p->localClient->client_server,
219 db 849 target_p->info);
220     }
221 adx 30 else
222 db 849 {
223     if (ConfigFileEntry.hide_spoof_ips)
224 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE),
225 db 849 me.name,
226     source_p->name,
227     IsOper(target_p) ? "Oper" : "User",
228     class_name,
229     target_p->name,
230     target_p->username,
231 db 856 target_p->host,
232 michael 891 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
233 db 849 target_p->info);
234     else
235 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE),
236 db 849 me.name,
237     source_p->name,
238     IsOper(target_p) ? "Oper" : "User",
239     class_name,
240     target_p->name,
241     target_p->username,
242 db 856 target_p->host,
243 michael 891 target_p->sockhost,
244 db 849 target_p->info);
245     }
246 adx 30 }
247     }

Properties

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