ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_ctrace.c
Revision: 1155
Committed: Tue Aug 9 20:27:45 2011 UTC (14 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 5938 byte(s)
Log Message:
- recreate "trunk"

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_ctrace.c: Traces a given class
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$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "handlers.h"
28 #include "hook.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "s_bsd.h"
35 #include "s_conf.h"
36 #include "s_serv.h"
37 #include "send.h"
38 #include "msg.h"
39 #include "parse.h"
40 #include "modules.h"
41
42 static void do_ctrace(struct Client *, int, char *[]);
43 static void mo_ctrace(struct Client *, struct Client *, int, char *[]);
44
45 struct Message ctrace_msgtab = {
46 "CTRACE", 0, 0, 2, 0, MFLG_SLOW, 0,
47 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ctrace, m_ignore}
48 };
49
50 const char *_version = "$Revision$";
51
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&ctrace_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&ctrace_msgtab);
62 }
63
64 static void report_this_status(struct Client *, struct Client *);
65
66 /*
67 ** mo_ctrace
68 ** parv[0] = sender prefix
69 ** parv[1] = classname
70 */
71 static void
72 mo_ctrace(struct Client *client_p, struct Client *source_p,
73 int parc, char *parv[])
74 {
75 if (EmptyString(parv[1]))
76 {
77 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
78 me.name, parv[0], "CTRACE");
79 return;
80 }
81
82 do_ctrace(source_p, parc, parv);
83 }
84
85 /*
86 * do_ctrace
87 */
88 static void
89 do_ctrace(struct Client *source_p, int parc, char *parv[])
90 {
91 char *class_looking_for;
92 const char *class_name = parv[1];
93 dlink_node *ptr;
94
95 sendto_realops_flags(UMODE_SPY, L_ALL,
96 "CTRACE requested by %s (%s@%s) [%s]",
97 source_p->name, source_p->username,
98 source_p->host, source_p->servptr->name);
99
100 /* report all direct connections */
101 DLINK_FOREACH(ptr, local_client_list.head)
102 {
103 struct Client *target_p = ptr->data;
104
105 class_name = get_client_class(target_p);
106 if ((class_name != NULL) && match(class_looking_for, class_name))
107 report_this_status(source_p, target_p);
108 }
109
110 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
111 parv[0], class_looking_for);
112 }
113
114 /*
115 * report_this_status
116 *
117 * inputs - pointer to client to report to
118 * - pointer to client to report about
119 * output - counter of number of hits
120 * side effects - NONE
121 */
122 static void
123 report_this_status(struct Client *source_p, struct Client *target_p)
124 {
125 const char *name = NULL;
126 const char *class_name = NULL;
127
128 name = get_client_name(target_p, HIDE_IP);
129 class_name = get_client_class(target_p);
130
131 switch(target_p->status)
132 {
133 case STAT_CLIENT:
134
135 if ((IsOper(source_p) &&
136 (MyClient(source_p) || !IsInvisible(target_p)))
137 || IsOper(target_p))
138 {
139 if (IsAdmin(target_p) && !ConfigFileEntry.hide_spoof_ips)
140 sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
141 me.name, source_p->name, class_name, name,
142 IsAdmin(source_p) ? target_p->sockhost : "255.255.255.255",
143 CurrentTime - target_p->lasttime,
144 CurrentTime - target_p->localClient->last);
145 else if (IsOper(target_p))
146 {
147 if (ConfigFileEntry.hide_spoof_ips)
148 sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
149 me.name, source_p->name, class_name, name,
150 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
151 CurrentTime - target_p->lasttime,
152 CurrentTime - target_p->localClient->last);
153 else
154 sendto_one(source_p, form_str(RPL_TRACEOPERATOR),
155 me.name, source_p->name, class_name, name,
156 (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
157 CurrentTime - target_p->lasttime,
158 CurrentTime - target_p->localClient->last);
159 }
160 else
161 {
162 if (ConfigFileEntry.hide_spoof_ips)
163 sendto_one(source_p, form_str(RPL_TRACEUSER),
164 me.name, source_p->name, class_name, name,
165 IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost,
166 CurrentTime - target_p->lasttime,
167 CurrentTime - target_p->localClient->last);
168 else
169 sendto_one(source_p, form_str(RPL_TRACEUSER),
170 me.name, source_p->name, class_name, name,
171 (IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost),
172 CurrentTime - target_p->lasttime,
173 CurrentTime - target_p->localClient->last);
174 }
175 }
176 break;
177 case STAT_SERVER:
178 if (!IsAdmin(source_p))
179 name = get_client_name(target_p, MASK_IP);
180
181 sendto_one(source_p, form_str(RPL_TRACESERVER),
182 me.name, source_p->name, class_name, 0,
183 0, name, *(target_p->serv->by) ?
184 target_p->serv->by : "*", "*",
185 me.name, CurrentTime - target_p->lasttime);
186 break;
187
188 default: /* ...we actually shouldn't come here... --msa */
189 sendto_one(source_p, form_str(RPL_TRACENEWTYPE), me.name,
190 source_p->name, name);
191 break;
192 }
193 }

Properties

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