ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_capture.c
Revision: 405
Committed: Tue Feb 7 19:38:35 2006 UTC (20 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 7398 byte(s)
Log Message:
- Removed now unused llflags parameter from sendto_server()


File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_capture.c: Makes a designated client captive
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 "common.h"
27     #include "handlers.h"
28     #include "client.h"
29     #include "hash.h"
30     #include "channel.h"
31     #include "channel_mode.h"
32     #include "hash.h"
33     #include "ircd.h"
34     #include "numeric.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 knight 113 #include "parse_aline.h"
42 adx 30
43     static void mo_capture(struct Client *, struct Client *, int, char *[]);
44     static void mo_uncapture(struct Client *, struct Client *, int, char *[]);
45    
46     struct Message capture_msgtab = {
47     "CAPTURE", 0, 0, 0, 0, MFLG_SLOW, 0,
48 michael 357 { m_unregistered, m_ignore, mo_capture, mo_capture, mo_capture, m_ignore }
49 adx 30 };
50    
51     struct Message uncapture_msgtab = {
52     "UNCAPTURE", 0, 0, 0, 0, MFLG_SLOW, 0,
53 michael 357 { m_unregistered, m_ignore, mo_uncapture, mo_uncapture, mo_uncapture, m_ignore }
54 adx 30 };
55    
56     #ifndef STATIC_MODULES
57     void
58     _modinit(void)
59     {
60     mod_add_cmd(&capture_msgtab);
61     mod_add_cmd(&uncapture_msgtab);
62     }
63    
64     void
65     _moddeinit(void)
66     {
67     mod_del_cmd(&capture_msgtab);
68     mod_del_cmd(&uncapture_msgtab);
69     }
70    
71 knight 31 const char *_version = "$Revision$";
72 adx 30 #endif
73    
74     /* mo_capture
75     * parv[0] = sender prefix
76     * parv[1] = nickname masklist
77     */
78     static void
79     mo_capture(struct Client *client_p, struct Client *source_p,
80     int parc, char *parv[])
81     {
82     struct Client *target_p = NULL;
83 michael 357 char nick[NICKLEN + 1];
84     char user[USERLEN + 1];
85     char host[HOSTLEN + 1];
86 adx 30 dlink_node *ptr = NULL;
87    
88 michael 357 if (EmptyString(parv[1]))
89 adx 30 {
90     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
91     me.name, source_p->name);
92     return;
93     }
94    
95     /* XXX Add oper flag in future ? */
96    
97     if (MyClient(source_p) && !IsAdmin(source_p))
98     {
99     sendto_one(source_p, form_str(ERR_NOPRIVS),
100     me.name, source_p->name, "CAPTURE");
101     return;
102     }
103    
104 michael 357 if (strchr(parv[1], '@') == NULL)
105 adx 30 {
106     if ((target_p = find_client(parv[1])) != NULL && IsClient(target_p))
107     {
108     if (MyConnect(target_p) && source_p != target_p)
109     {
110     if (IsOper(target_p))
111     {
112     sendto_one(source_p, form_str(ERR_NOPRIVS),
113     me.name, source_p->name, "CAPTURE");
114     return;
115     }
116    
117     if (!IsCaptured(target_p))
118     {
119     sendto_realops_flags(UMODE_ALL, L_ALL, "Captured %s (%s@%s)",
120     target_p->name, target_p->username,
121     target_p->host);
122     SetCaptured(target_p);
123     }
124    
125     sendto_one(source_p, form_str(RPL_ISCAPTURED),
126     me.name, source_p->name, target_p->name);
127     }
128     else if (IsCapable(target_p->from, CAP_ENCAP))
129     sendto_one(target_p, ":%s ENCAP %s CAPTURE %s",
130     source_p->name, target_p->from->name, target_p->name);
131     }
132     else
133     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
134     me.name, source_p->name, parv[1]);
135     }
136     else
137     {
138     unsigned int matches = 0;
139 michael 357 struct split_nuh_item nuh;
140 adx 30
141 michael 357 nuh.nuhmask = parv[1];
142     nuh.nickptr = nick;
143     nuh.userptr = user;
144     nuh.hostptr = host;
145 adx 30
146 michael 357 nuh.nicksize = sizeof(nick);
147     nuh.usersize = sizeof(user);
148     nuh.hostsize = sizeof(host);
149 adx 30
150 michael 357 split_nuh(&nuh);
151    
152 adx 30 if (!valid_wild_card(source_p, YES, 3, nick, user, host))
153     return;
154    
155     if (IsClient(client_p))
156 michael 405 sendto_server(client_p, NULL, NULL, CAP_ENCAP, 0,
157 adx 30 ":%s ENCAP * CAPTURE %s!%s@%s",
158     source_p->name, nick, user, host);
159    
160     DLINK_FOREACH(ptr, local_client_list.head)
161     {
162     target_p = ptr->data;
163    
164 michael 357 if (source_p == target_p || IsOper(target_p) || IsCaptured(target_p))
165 adx 30 continue;
166    
167     if (match(nick, target_p->name) &&
168     match(host, target_p->host) && match(user, target_p->username))
169     {
170     SetCaptured(target_p);
171     ++matches;
172     }
173     }
174    
175     sendto_realops_flags(UMODE_ALL, L_ALL,
176     "Bulk captured %s!%s@%s, %u local match(es)",
177     nick, user, host, matches);
178     }
179     }
180    
181     /* mo_uncapture
182     * parv[0] = sender prefix
183     * parv[1] = nickname masklist
184     */
185     static void
186     mo_uncapture(struct Client *client_p, struct Client *source_p,
187     int parc, char *parv[])
188     {
189     struct Client *target_p = NULL;
190 michael 357 char nick[NICKLEN + 1];
191     char user[USERLEN + 1];
192     char host[HOSTLEN + 1];
193 adx 30 dlink_node *ptr = NULL;
194    
195     if (MyClient(source_p) && !IsAdmin(source_p))
196     {
197     sendto_one(source_p, form_str(ERR_NOPRIVS),
198     me.name, source_p->name, "CAPTURE");
199     return;
200     }
201    
202 michael 357 if (EmptyString(parv[1]))
203 adx 30 {
204     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
205     me.name, source_p->name);
206     return;
207     }
208    
209 michael 357 if (strchr(parv[1], '@') == NULL)
210 adx 30 {
211     if ((target_p = find_client(parv[1])) != NULL && IsClient(target_p))
212     {
213     if (MyConnect(target_p))
214     {
215     if (IsCaptured(target_p))
216     {
217     ClearCaptured(target_p);
218    
219     sendto_realops_flags(UMODE_ALL, L_ALL, "Uncaptured %s (%s@%s)",
220     target_p->name, target_p->username,
221     target_p->host);
222     }
223    
224     sendto_one(source_p, form_str(RPL_ISUNCAPTURED),
225     me.name, source_p->name, target_p->name);
226     }
227     else if (IsCapable(target_p->from, CAP_ENCAP))
228     sendto_one(target_p, ":%s ENCAP %s UNCAPTURE %s",
229     source_p->name, target_p->from->name, target_p->name);
230     }
231     else
232     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
233     me.name, source_p->name, parv[1]);
234     }
235     else
236     {
237     unsigned int matches = 0;
238 michael 357 struct split_nuh_item nuh;
239 adx 30
240 michael 357 nuh.nuhmask = parv[1];
241     nuh.nickptr = nick;
242     nuh.userptr = user;
243     nuh.hostptr = host;
244 adx 30
245 michael 357 nuh.nicksize = sizeof(nick);
246     nuh.usersize = sizeof(user);
247     nuh.hostsize = sizeof(host);
248 adx 30
249 michael 357 split_nuh(&nuh);
250    
251 adx 30 if (IsClient(client_p))
252 michael 405 sendto_server(client_p, NULL, NULL, CAP_ENCAP, 0,
253 adx 30 ":%s ENCAP * UNCAPTURE %s!%s@%s",
254     source_p->name, nick, user, host);
255    
256     DLINK_FOREACH(ptr, local_client_list.head)
257     {
258     target_p = ptr->data;
259    
260     if (!IsCaptured(target_p))
261     continue;
262    
263     if (match(nick, target_p->name) &&
264     match(host, target_p->host) && match(user, target_p->username))
265     {
266     ClearCaptured(target_p);
267     ++matches;
268     }
269     }
270    
271     sendto_realops_flags(UMODE_ALL, L_ALL,
272     "Bulk uncaptured %s!%s@%s, %u local match(es)",
273     nick, user, host, matches);
274     }
275     }

Properties

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