ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.0.0beta2/modules/m_etrace.c
Revision: 1471
Committed: Sat Jul 21 20:39:22 2012 UTC (13 years, 1 month ago) by lusky
Content type: text/x-csrc
Original Path: releases/ircd-hybrid-8.0.0beta2/modules/m_etrace.c
File size: 5579 byte(s)
Log Message:
RELEASE TAG ircd-hybrid-8.0.0beta2

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 "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 michael 1309 #include "conf.h"
39 adx 30
40    
41 db 849 static void report_this_status(struct Client *, struct Client *, int);
42 adx 30
43     /*
44     * do_etrace()
45     */
46     static void
47 michael 1144 do_etrace(struct Client *source_p, int parc, char *parv[])
48 adx 30 {
49     const char *tname = NULL;
50     struct Client *target_p = NULL;
51     int wilds = 0;
52     int do_all = 0;
53 db 849 int full_etrace = 0;
54 adx 30 dlink_node *ptr;
55    
56 michael 1144 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 db 849 if (parc > 1)
62 adx 30 {
63 db 849 if (irccmp(parv[1], "-full") == 0)
64     {
65 michael 1169 ++parv;
66     --parc;
67 db 849 full_etrace = 1;
68     }
69     }
70    
71     if (parc > 1)
72     {
73 adx 30 tname = parv[1];
74 db 849
75 adx 30 if (tname != NULL)
76 michael 1400 wilds = has_wildcards(tname);
77 adx 30 else
78     tname = "*";
79     }
80     else
81     {
82     do_all = 1;
83     tname = "*";
84     }
85    
86 michael 1219 if (HasUMode(source_p, UMODE_CCONN_FULL))
87 db 856 full_etrace = 1;
88    
89 adx 30 if (!wilds && !do_all)
90     {
91 michael 1169 target_p = hash_find_client(tname);
92 adx 30
93     if (target_p && MyClient(target_p))
94 db 849 report_this_status(source_p, target_p, full_etrace);
95 adx 30
96     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
97 michael 891 source_p->name, tname);
98 adx 30 return;
99     }
100    
101     DLINK_FOREACH(ptr, local_client_list.head)
102     {
103     target_p = ptr->data;
104    
105     if (wilds)
106     {
107 michael 1118 if (match(tname, target_p->name))
108 michael 891 report_this_status(source_p, target_p, full_etrace);
109 adx 30 }
110     else
111 db 849 report_this_status(source_p, target_p, full_etrace);
112 adx 30 }
113    
114     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
115 michael 891 source_p->name, tname);
116 adx 30 }
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 michael 1114 int parc, char *parv[])
125 adx 30 {
126 michael 1144 do_etrace(source_p, parc, parv);
127 adx 30 }
128    
129     /* report_this_status()
130     *
131     * inputs - pointer to client to report to
132     * - pointer to client to report about
133 db 849 * - flag full etrace or not
134 adx 30 * output - NONE
135     * side effects - NONE
136     */
137     static void
138 db 849 report_this_status(struct Client *source_p, struct Client *target_p,
139 michael 1114 int full_etrace)
140 adx 30 {
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 db 849 if (full_etrace)
152     {
153     if (ConfigFileEntry.hide_spoof_ips)
154 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
155 db 849 me.name,
156     source_p->name,
157 michael 1219 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
158 db 849 class_name,
159     target_p->name,
160     target_p->username,
161 db 856 target_p->host,
162 michael 891 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
163 michael 1113 IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_host,
164     IsIPSpoof(target_p) ? "<hidden>" : target_p->localClient->client_server,
165 db 849 target_p->info);
166     else
167 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE_FULL),
168 db 849 me.name,
169     source_p->name,
170 michael 1219 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
171 db 849 class_name,
172     target_p->name,
173     target_p->username,
174 db 856 target_p->host,
175 michael 891 target_p->sockhost,
176 michael 1113 target_p->localClient->client_host,
177     target_p->localClient->client_server,
178 db 849 target_p->info);
179     }
180 adx 30 else
181 db 849 {
182     if (ConfigFileEntry.hide_spoof_ips)
183 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE),
184 db 849 me.name,
185     source_p->name,
186 michael 1219 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
187 db 849 class_name,
188     target_p->name,
189     target_p->username,
190 db 856 target_p->host,
191 michael 891 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
192 db 849 target_p->info);
193     else
194 michael 1114 sendto_one(source_p, form_str(RPL_ETRACE),
195 db 849 me.name,
196     source_p->name,
197 michael 1219 HasUMode(target_p, UMODE_OPER) ? "Oper" : "User",
198 db 849 class_name,
199     target_p->name,
200     target_p->username,
201 db 856 target_p->host,
202 michael 891 target_p->sockhost,
203 db 849 target_p->info);
204     }
205 adx 30 }
206     }
207 michael 1230
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