ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_etrace.c
Revision: 444
Committed: Sun Feb 12 00:15:24 2006 UTC (20 years, 6 months ago) by adx
Content type: text/x-csrc
File size: 4358 byte(s)
Log Message:
+ STATIC_MODULES is no longer meaningful so byebye

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 "client.h"
28     #include "hash.h"
29     #include "common.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "s_serv.h"
33     #include "send.h"
34     #include "msg.h"
35     #include "parse.h"
36     #include "modules.h"
37     #include "s_conf.h"
38    
39     #define FORM_STR_RPL_ETRACE ":%s 709 %s %s %s %s %s %s :%s"
40    
41 adx 444 static void *do_etrace(va_list);
42 adx 30 static void mo_etrace(struct Client *, struct Client *, int, char *[]);
43    
44     struct Message etrace_msgtab = {
45     "ETRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
46 michael 171 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
47 adx 30 };
48    
49     static struct Callback *etrace_cb;
50    
51 adx 442 INIT_MODULE(m_etrace, "$Revision$")
52 adx 30 {
53 adx 444 etrace_cb = register_callback("doing_etrace", do_etrace);
54 adx 30 mod_add_cmd(&etrace_msgtab);
55     }
56    
57 adx 442 CLEANUP_MODULE
58 adx 30 {
59     mod_del_cmd(&etrace_msgtab);
60 adx 444 uninstall_hook(etrace_cb, do_etrace);
61 adx 30 }
62    
63     static void report_this_status(struct Client *, struct Client *);
64    
65     /*
66     * do_etrace()
67     */
68 adx 444 static void *
69     do_etrace(va_list args)
70 adx 30 {
71 adx 444 struct Client *source_p = va_arg(args, struct Client *);
72     int parc = va_arg(args, int);
73     char **parv = va_arg(args, char **);
74 adx 30 const char *tname = NULL;
75     struct Client *target_p = NULL;
76     int wilds = 0;
77     int do_all = 0;
78     dlink_node *ptr;
79    
80     if (parc > 0)
81     {
82     tname = parv[1];
83     if (tname != NULL)
84 michael 290 wilds = has_wildcards(tname);
85 adx 30 else
86     tname = "*";
87     }
88     else
89     {
90     do_all = 1;
91     tname = "*";
92     }
93    
94     if (!wilds && !do_all)
95     {
96     target_p = find_client(tname);
97    
98     if (target_p && MyClient(target_p))
99     report_this_status(source_p, target_p);
100    
101     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
102     source_p->name, tname);
103 adx 444 return NULL;
104 adx 30 }
105    
106     DLINK_FOREACH(ptr, local_client_list.head)
107     {
108     target_p = ptr->data;
109    
110     if (wilds)
111     {
112     if (match(tname, target_p->name) || match(target_p->name, tname))
113     report_this_status(source_p, target_p);
114     }
115     else
116     report_this_status(source_p, target_p);
117     }
118    
119     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
120     source_p->name, tname);
121 adx 444 return NULL;
122 adx 30 }
123    
124     /* mo_etrace()
125     * parv[0] = sender prefix
126     * parv[1] = servername
127     */
128     static void
129     mo_etrace(struct Client *client_p, struct Client *source_p,
130     int parc, char *parv[])
131     {
132     execute_callback(etrace_cb, source_p, parc, parv);
133     }
134    
135     /* report_this_status()
136     *
137     * inputs - pointer to client to report to
138     * - pointer to client to report about
139     * output - NONE
140     * side effects - NONE
141     */
142     static void
143     report_this_status(struct Client *source_p, struct Client *target_p)
144     {
145     const char *name;
146     const char *class_name;
147     char ip[HOSTIPLEN];
148    
149     /* Should this be sockhost? - stu */
150     irc_getnameinfo((struct sockaddr*)&target_p->localClient->ip,
151     target_p->localClient->ip.ss_len, ip, HOSTIPLEN, NULL, 0,
152     NI_NUMERICHOST);
153    
154     name = get_client_name(target_p, HIDE_IP);
155 db 128 class_name = get_client_className(target_p);
156 adx 30
157     set_time();
158    
159     if (target_p->status == STAT_CLIENT)
160     {
161     if (ConfigFileEntry.hide_spoof_ips)
162     sendto_one(source_p, FORM_STR_RPL_ETRACE,
163     me.name, source_p->name,
164     IsOper(target_p) ? "Oper" : "User",
165     class_name,
166     target_p->name, target_p->username,
167     IsIPSpoof(target_p) ? "255.255.255.255" : ip,
168     target_p->info);
169     else
170     sendto_one(source_p, FORM_STR_RPL_ETRACE,
171     me.name, source_p->name,
172     IsOper(target_p) ? "Oper" : "User",
173     class_name,
174     target_p->name, target_p->username, ip,
175     target_p->info);
176     }
177     }

Properties

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