ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_etrace.c
Revision: 30
Committed: Sun Oct 2 20:03:27 2005 UTC (18 years, 6 months ago) by adx
Content type: text/x-csrc
File size: 4809 byte(s)
Log Message:
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

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     * $Id: m_etrace.c,v 1.2 2005/09/27 12:43:33 adx Exp $
23     */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "tools.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     #include "irc_getnameinfo.h"
44    
45     #define FORM_STR_RPL_ETRACE ":%s 709 %s %s %s %s %s %s :%s"
46    
47     static void do_etrace(struct Client *, int, char **);
48     static void mo_etrace(struct Client *, struct Client *, int, char *[]);
49    
50     struct Message etrace_msgtab = {
51     "ETRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
52     {m_unregistered, m_ignore, m_ignore, m_ignore, mo_etrace, m_ignore}
53     };
54    
55     #ifndef STATIC_MODULES
56     const char *_version = "$Revision: 1.2 $";
57     static struct Callback *etrace_cb;
58    
59     static void *
60     va_etrace(va_list args)
61     {
62     struct Client *source_p = va_arg(args, struct Client *);
63     int parc = va_arg(args, int);
64     char **parv = va_arg(args, char **);
65    
66     do_etrace(source_p, parc, parv);
67     return NULL;
68     }
69    
70     void
71     _modinit(void)
72     {
73     etrace_cb = register_callback("doing_etrace", va_etrace);
74     mod_add_cmd(&etrace_msgtab);
75     }
76    
77     void
78     _moddeinit(void)
79     {
80     mod_del_cmd(&etrace_msgtab);
81     uninstall_hook(etrace_cb, va_etrace);
82     }
83     #endif
84    
85     static void report_this_status(struct Client *, struct Client *);
86    
87     /*
88     * do_etrace()
89     */
90     static void
91     do_etrace(struct Client *source_p, int parc, char **parv)
92     {
93     const char *tname = NULL;
94     struct Client *target_p = NULL;
95     int wilds = 0;
96     int do_all = 0;
97     dlink_node *ptr;
98    
99     if (parc > 0)
100     {
101     tname = parv[1];
102     if (tname != NULL)
103     wilds = strchr(tname, '*') || strchr(tname, '?');
104     else
105     tname = "*";
106     }
107     else
108     {
109     do_all = 1;
110     tname = "*";
111     }
112    
113     if (!wilds && !do_all)
114     {
115     target_p = find_client(tname);
116    
117     if (target_p && MyClient(target_p))
118     report_this_status(source_p, target_p);
119    
120     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
121     source_p->name, tname);
122     return;
123     }
124    
125     DLINK_FOREACH(ptr, local_client_list.head)
126     {
127     target_p = ptr->data;
128    
129     if (wilds)
130     {
131     if (match(tname, target_p->name) || match(target_p->name, tname))
132     report_this_status(source_p, target_p);
133     }
134     else
135     report_this_status(source_p, target_p);
136     }
137    
138     sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
139     source_p->name, tname);
140     }
141    
142     /* mo_etrace()
143     * parv[0] = sender prefix
144     * parv[1] = servername
145     */
146     static void
147     mo_etrace(struct Client *client_p, struct Client *source_p,
148     int parc, char *parv[])
149     {
150     #ifdef STATIC_MODULES
151     do_etrace(source_p, parc, parv);
152     #else
153     execute_callback(etrace_cb, source_p, parc, parv);
154     #endif
155     }
156    
157     /* report_this_status()
158     *
159     * inputs - pointer to client to report to
160     * - pointer to client to report about
161     * output - NONE
162     * side effects - NONE
163     */
164     static void
165     report_this_status(struct Client *source_p, struct Client *target_p)
166     {
167     const char *name;
168     const char *class_name;
169     char ip[HOSTIPLEN];
170    
171     /* Should this be sockhost? - stu */
172     irc_getnameinfo((struct sockaddr*)&target_p->localClient->ip,
173     target_p->localClient->ip.ss_len, ip, HOSTIPLEN, NULL, 0,
174     NI_NUMERICHOST);
175    
176     name = get_client_name(target_p, HIDE_IP);
177     class_name = get_client_class(target_p);
178    
179     set_time();
180    
181     if (target_p->status == STAT_CLIENT)
182     {
183     if (ConfigFileEntry.hide_spoof_ips)
184     sendto_one(source_p, FORM_STR_RPL_ETRACE,
185     me.name, source_p->name,
186     IsOper(target_p) ? "Oper" : "User",
187     class_name,
188     target_p->name, target_p->username,
189     IsIPSpoof(target_p) ? "255.255.255.255" : ip,
190     target_p->info);
191     else
192     sendto_one(source_p, FORM_STR_RPL_ETRACE,
193     me.name, source_p->name,
194     IsOper(target_p) ? "Oper" : "User",
195     class_name,
196     target_p->name, target_p->username, ip,
197     target_p->info);
198     }
199     }

Properties

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