ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_etrace.c
Revision: 849
Committed: Mon Feb 19 19:41:59 2007 UTC (19 years, 7 months ago) by db
Content type: text/x-csrc
File size: 5898 byte(s)
Log Message:
- Add +C 
- add etrace -full

Reviewed by: cryogen, bear

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     #include "handlers.h"
27     #include "tools.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     #include "irc_getnameinfo.h"
44    
45 db 849 #define FORM_STR_RPL_ETRACE ":%s 709 %s %s %s %s %s %s :%s"
46     #define FORM_STR_RPL_ETRACE_FULL ":%s 708 %s %s %s %s %s %s %s %s :%s"
47 adx 30
48     static void do_etrace(struct Client *, int, char **);
49     static void mo_etrace(struct Client *, struct Client *, int, char *[]);
50    
51     struct Message etrace_msgtab = {
52     "ETRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
53 michael 172 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
54 adx 30 };
55    
56     #ifndef STATIC_MODULES
57 knight 31 const char *_version = "$Revision$";
58 adx 30 static struct Callback *etrace_cb;
59    
60     static void *
61     va_etrace(va_list args)
62     {
63     struct Client *source_p = va_arg(args, struct Client *);
64     int parc = va_arg(args, int);
65     char **parv = va_arg(args, char **);
66    
67     do_etrace(source_p, parc, parv);
68     return NULL;
69     }
70    
71     void
72     _modinit(void)
73     {
74     etrace_cb = register_callback("doing_etrace", va_etrace);
75     mod_add_cmd(&etrace_msgtab);
76     }
77    
78     void
79     _moddeinit(void)
80     {
81     mod_del_cmd(&etrace_msgtab);
82     uninstall_hook(etrace_cb, va_etrace);
83     }
84     #endif
85    
86 db 849 static void report_this_status(struct Client *, struct Client *, int);
87 adx 30
88     /*
89     * do_etrace()
90     */
91     static void
92     do_etrace(struct Client *source_p, int parc, char **parv)
93     {
94     const char *tname = NULL;
95     struct Client *target_p = NULL;
96     int wilds = 0;
97     int do_all = 0;
98 db 849 int full_etrace = 0;
99 adx 30 dlink_node *ptr;
100    
101 db 849 if (parc > 1)
102 adx 30 {
103 db 849 if (irccmp(parv[1], "-full") == 0)
104     {
105     parv++;
106     parc--;
107     full_etrace = 1;
108     }
109     }
110    
111     if (parc > 1)
112     {
113 adx 30 tname = parv[1];
114 db 849
115 adx 30 if (tname != NULL)
116     wilds = strchr(tname, '*') || strchr(tname, '?');
117     else
118     tname = "*";
119     }
120     else
121     {
122     do_all = 1;
123     tname = "*";
124     }
125    
126     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     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 db 849 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     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 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     int full_etrace)
181 adx 30 {
182     const char *name;
183     const char *class_name;
184     char ip[HOSTIPLEN];
185    
186     /* Should this be sockhost? - stu */
187     irc_getnameinfo((struct sockaddr*)&target_p->localClient->ip,
188     target_p->localClient->ip.ss_len, ip, HOSTIPLEN, NULL, 0,
189     NI_NUMERICHOST);
190    
191     name = get_client_name(target_p, HIDE_IP);
192     class_name = get_client_class(target_p);
193    
194     set_time();
195    
196     if (target_p->status == STAT_CLIENT)
197     {
198 db 849 if (full_etrace)
199     {
200     if (ConfigFileEntry.hide_spoof_ips)
201     sendto_one(source_p, FORM_STR_RPL_ETRACE_FULL,
202     me.name,
203     source_p->name,
204     IsOper(target_p) ? "Oper" : "User",
205     class_name,
206     target_p->name,
207     target_p->username,
208     IsIPSpoof(target_p) ? "255.255.255.255" : ip,
209     IsIPSpoof(target_p) ? "<hidden>" : target_p->client_host,
210     IsIPSpoof(target_p) ? "<hidden>" : target_p->client_server,
211     target_p->info);
212     else
213     sendto_one(source_p, FORM_STR_RPL_ETRACE_FULL,
214     me.name,
215     source_p->name,
216     IsOper(target_p) ? "Oper" : "User",
217     class_name,
218     target_p->name,
219     target_p->username,
220     ip,
221     target_p->client_host,
222     target_p->client_server,
223     target_p->info);
224     }
225 adx 30 else
226 db 849 {
227     if (ConfigFileEntry.hide_spoof_ips)
228     sendto_one(source_p, FORM_STR_RPL_ETRACE,
229     me.name,
230     source_p->name,
231     IsOper(target_p) ? "Oper" : "User",
232     class_name,
233     target_p->name,
234     target_p->username,
235     IsIPSpoof(target_p) ? "255.255.255.255" : ip,
236     target_p->info);
237     else
238     sendto_one(source_p, FORM_STR_RPL_ETRACE,
239     me.name,
240     source_p->name,
241     IsOper(target_p) ? "Oper" : "User",
242     class_name,
243     target_p->name,
244     target_p->username,
245     ip,
246     target_p->info);
247     }
248 adx 30 }
249     }

Properties

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