ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/releases/ircd-hybrid-8.0.0beta1/modules/m_etrace.c
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (15 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_etrace.c
File size: 5677 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

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

Properties

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