/[svn]/ircd-hybrid-7.3/modules/m_etrace.c
ViewVC logotype

Annotation of /ircd-hybrid-7.3/modules/m_etrace.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1144 - (hide annotations)
Tue Jul 26 19:33:54 2011 UTC (9 years ago) by michael
File MIME type: text/x-chdr
File size: 5530 byte(s)
Added back STATS/TRACE/MOTD/ADMIN request notices. Removed
   spy_*_notice modules accordingly.


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

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28