ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/contrib/m_ctrace.c
Revision: 1652
Committed: Tue Nov 13 20:28:53 2012 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 6295 byte(s)
Log Message:
- changed match() polarity. match() now returns 0 on match and 1 on non-match
  This cleans up several places where function pointers of different matching
  functions like irccmp/strcmp/match are passed to other functions.
- added improved collapse() to match.c

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

Properties

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