ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_etrace.c
Revision: 442
Committed: Sat Feb 11 23:14:21 2006 UTC (20 years, 6 months ago) by adx
Content type: text/x-csrc
File size: 4555 byte(s)
Log Message:
+ massive rewrite of module init/deinit/version headers,
  we are introducing a new module manager which deals with static
  and dynamic modules exactly the same way. (New possibilities
  include loading/unloading statically compiled modules and
  mixing static/dynamic ones in one build.)

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

Properties

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