ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_resv.c
Revision: 3368
Committed: Mon Apr 21 14:24:16 2014 UTC (12 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 8413 byte(s)
Log Message:
- Style corrections

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2001-2014 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_resv.c
23 * \brief Includes required functions for processing the RESV command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "irc_string.h"
31 #include "numeric.h"
32 #include "server.h"
33 #include "send.h"
34 #include "parse.h"
35 #include "modules.h"
36 #include "conf.h"
37 #include "log.h"
38 #include "resv.h"
39 #include "hash.h"
40
41
42 static void parse_resv(struct Client *, char *, int, char *);
43
44
45 /* mo_resv()
46 * parv[0] = command
47 * parv[1] = channel/nick to forbid
48 */
49 static int
50 mo_resv(struct Client *source_p, int parc, char *parv[])
51 {
52 char *resv = NULL;
53 char *reason = NULL;
54 char *target_server = NULL;
55 time_t tkline_time = 0;
56
57 /* RESV #channel ON irc.server.com :abuse
58 * RESV kiddie ON irc.server.com :abuse
59 */
60 if (parse_aline("RESV", source_p, parc, parv, AWILD, &resv, NULL,
61 &tkline_time, &target_server, &reason) < 0)
62 return 0;
63
64 if (target_server)
65 {
66 /* if a given expire time is given, ENCAP it */
67 if (tkline_time)
68 sendto_match_servs(source_p, target_server, CAP_ENCAP,
69 "ENCAP %s RESV %d %s 0 :%s",
70 target_server, (int)tkline_time, resv, reason);
71 else
72 sendto_match_servs(source_p, target_server, CAP_CLUSTER,
73 "RESV %s %s :%s",
74 target_server, resv, reason);
75 /* Allow ON to apply local resv as well if it matches */
76 if (match(target_server, me.name))
77 return 0;
78 }
79 else
80 {
81 /* RESV #channel :abuse
82 * RESV kiddie :abuse
83 */
84 if (tkline_time)
85 cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_RESV,
86 "RESV %d %s 0 : %s", (int)tkline_time, resv, reason);
87 else
88 cluster_a_line(source_p, "RESV", CAP_KLN, SHARED_RESV,
89 "%s : %s", resv, reason);
90 }
91
92 parse_resv(source_p, resv, (int)tkline_time, reason);
93 return 0;
94 }
95
96 /* me_resv()
97 *
98 * inputs - server
99 * - client (oper)
100 * - parc number of arguments
101 * - parv list of arguments
102 * via parv[]
103 * parv[0] = command
104 * parv[1] = tkline_time
105 * parv[2] = name
106 * parv[3] = 0
107 * parv[4] = reason
108 * parc should be 5
109 *
110 * outputs - NONE
111 * side effects -
112 */
113 static int
114 me_resv(struct Client *source_p, int parc, char *parv[])
115 {
116 if (parc != 5 || !IsClient(source_p))
117 return 0;
118
119 parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
120 return 0;
121 }
122
123 /* ms_resv()
124 * parv[0] = command
125 * parv[1] = target server
126 * parv[2] = channel/nick to resv
127 * parv[3] = reason
128 */
129 static int
130 ms_resv(struct Client *source_p, int parc, char *parv[])
131 {
132 if (parc != 4 || EmptyString(parv[3]))
133 return 0;
134
135 sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
136 "RESV %s %s :%s",
137 parv[1], parv[2], parv[3]);
138
139 if (!IsClient(source_p) || match(parv[1], me.name))
140 return 0;
141
142 if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
143 source_p->username, source_p->host,
144 SHARED_RESV))
145 parse_resv(source_p, parv[2], 0, parv[3]);
146 return 0;
147 }
148
149 /* parse_resv()
150 *
151 * inputs - source_p, NULL supported
152 * - thing to resv
153 * - time_t if tkline
154 * - reason
155 * outputs - none
156 * side effects - parse resv, create if valid
157 */
158 static void
159 parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
160 {
161 if (IsChanPrefix(*name))
162 {
163 struct MaskItem *conf = NULL;
164
165 if ((conf = create_resv(name, reason, NULL)) == NULL)
166 {
167 sendto_one_notice(source_p, &me, ":A RESV has already been placed on channel: %s",
168 name);
169 return;
170 }
171
172 conf->setat = CurrentTime;
173 SetConfDatabase(conf);
174
175 if (tkline_time)
176 {
177 sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on channel: %s",
178 tkline_time/60, (MyClient(source_p) ? "local" : "remote"), name);
179 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
180 "%s has placed a %d minute %s RESV on channel: %s [%s]",
181 get_oper_name(source_p),
182 tkline_time/60,
183 (MyClient(source_p) ? "local" : "remote"),
184 conf->name, conf->reason);
185 ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
186 source_p->name, (int)tkline_time/60,
187 conf->name, conf->reason);
188 conf->until = CurrentTime + tkline_time;
189 }
190 else
191 {
192 sendto_one_notice(source_p, &me, ":A %s RESV has been placed on channel %s",
193 (MyClient(source_p) ? "local" : "remote"), name);
194 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
195 "%s has placed a %s RESV on channel %s : [%s]",
196 get_oper_name(source_p),
197 (MyClient(source_p) ? "local" : "remote"),
198 conf->name, conf->reason);
199 }
200 }
201 else
202 {
203 struct MaskItem *conf = NULL;
204
205 if (!valid_wild_card_simple(name))
206 {
207 sendto_one_notice(source_p, &me, ":Please include at least %d non-wildcard characters with the resv",
208 ConfigFileEntry.min_nonwildcard_simple);
209 return;
210 }
211
212 if (!HasUMode(source_p, UMODE_ADMIN) && has_wildcards(name))
213 {
214 sendto_one_notice(source_p, &me, ":You must be an admin to perform a wildcard RESV");
215 return;
216 }
217
218 if ((conf = create_resv(name, reason, NULL)) == NULL)
219 {
220 sendto_one_notice(source_p, &me, ":A RESV has already been placed on nick %s",
221 name);
222 return;
223 }
224
225 conf->setat = CurrentTime;
226 SetConfDatabase(conf);
227
228 if (tkline_time)
229 {
230 sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on nick %s : [%s]",
231 tkline_time/60, (MyClient(source_p) ? "local" : "remote"),
232 conf->name, conf->reason);
233 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
234 "%s has placed a %d minute %s RESV on nick %s : [%s]",
235 get_oper_name(source_p), tkline_time/60,
236 (MyClient(source_p) ? "local" : "remote"),
237 conf->name, conf->reason);
238 ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
239 source_p->name, (int)tkline_time/60, conf->name, conf->reason);
240 conf->until = CurrentTime + tkline_time;
241 }
242 else
243 {
244 sendto_one_notice(source_p, &me, ":A %s RESV has been placed on nick %s : [%s]",
245 (MyClient(source_p) ? "local" : "remote"), conf->name, conf->reason);
246 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
247 "%s has placed a %s RESV on nick %s : [%s]",
248 get_oper_name(source_p),
249 (MyClient(source_p) ? "local" : "remote"),
250 conf->name, conf->reason);
251 }
252 }
253 }
254
255 static struct Message resv_msgtab =
256 {
257 "RESV", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
258 { m_ignore, m_not_oper, ms_resv, me_resv, mo_resv, m_ignore }
259 };
260
261 static void
262 module_init(void)
263 {
264 mod_add_cmd(&resv_msgtab);
265 }
266
267 static void
268 module_exit(void)
269 {
270 mod_del_cmd(&resv_msgtab);
271 }
272
273 struct module module_entry =
274 {
275 .node = { NULL, NULL, NULL },
276 .name = NULL,
277 .version = "$Revision$",
278 .handle = NULL,
279 .modinit = module_init,
280 .modexit = module_exit,
281 .flags = 0
282 };

Properties

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