ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_etrace.c
Revision: 1834
Committed: Fri Apr 19 19:50:27 2013 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 5614 byte(s)
Log Message:
- Revert to -r1831

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

Properties

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