ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_resv.c
Revision: 5347
Committed: Sun Jan 11 12:42:20 2015 UTC (11 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 8782 byte(s)
Log Message:
- Update copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2001-2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
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
40
41 /* parse_resv()
42 *
43 * inputs - source_p, NULL supported
44 * - thing to resv
45 * - time_t if tkline
46 * - reason
47 * outputs - none
48 * side effects - parse resv, create if valid
49 */
50 static void
51 parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
52 {
53 if (IsChanPrefix(*name))
54 {
55 struct MaskItem *conf = NULL;
56
57 if ((conf = create_resv(name, reason, NULL)) == NULL)
58 {
59 if (IsClient(source_p))
60 sendto_one_notice(source_p, &me, ":A RESV has already been placed on channel: %s", name);
61
62 return;
63 }
64
65 conf->setat = CurrentTime;
66 SetConfDatabase(conf);
67
68 if (tkline_time)
69 {
70 if (IsClient(source_p))
71 sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on channel: %s",
72 tkline_time/60, (MyClient(source_p) ? "local" : "remote"), name);
73
74 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
75 "%s has placed a %d minute %s RESV on channel: %s [%s]",
76 get_oper_name(source_p),
77 tkline_time/60,
78 (MyClient(source_p) ? "local" : "remote"),
79 conf->name, conf->reason);
80 ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
81 get_oper_name(source_p), (int)tkline_time/60,
82 conf->name, conf->reason);
83 conf->until = CurrentTime + tkline_time;
84 }
85 else
86 {
87 if (IsClient(source_p))
88 sendto_one_notice(source_p, &me, ":A %s RESV has been placed on channel %s",
89 (MyClient(source_p) ? "local" : "remote"), name);
90
91 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
92 "%s has placed a %s RESV on channel %s : [%s]",
93 get_oper_name(source_p),
94 (MyClient(source_p) ? "local" : "remote"),
95 conf->name, conf->reason);
96 ilog(LOG_TYPE_RESV, "%s added RESV for [%s] [%s]",
97 get_oper_name(source_p), conf->name, conf->reason);
98 }
99 }
100 else
101 {
102 struct MaskItem *conf = NULL;
103
104 if (!valid_wild_card_simple(name))
105 {
106 if (IsClient(source_p))
107 sendto_one_notice(source_p, &me, ":Please include at least %u non-wildcard characters with the resv",
108 ConfigGeneral.min_nonwildcard_simple);
109
110 return;
111 }
112
113 if (!HasUMode(source_p, UMODE_ADMIN) && has_wildcards(name))
114 {
115 if (IsClient(source_p))
116 sendto_one_notice(source_p, &me, ":You must be an admin to perform a wildcard RESV");
117
118 return;
119 }
120
121 if ((conf = create_resv(name, reason, NULL)) == NULL)
122 {
123 if (IsClient(source_p))
124 sendto_one_notice(source_p, &me, ":A RESV has already been placed on nick %s", name);
125
126 return;
127 }
128
129 conf->setat = CurrentTime;
130 SetConfDatabase(conf);
131
132 if (tkline_time)
133 {
134 if (IsClient(source_p))
135 sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on nick %s : [%s]",
136 tkline_time/60, (MyClient(source_p) ? "local" : "remote"),
137 conf->name, conf->reason);
138
139 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
140 "%s has placed a %d minute %s RESV on nick %s : [%s]",
141 get_oper_name(source_p), tkline_time/60,
142 (MyClient(source_p) ? "local" : "remote"),
143 conf->name, conf->reason);
144 ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
145 get_oper_name(source_p), (int)tkline_time/60, conf->name, conf->reason);
146 conf->until = CurrentTime + tkline_time;
147 }
148 else
149 {
150 if (IsClient(source_p))
151 sendto_one_notice(source_p, &me, ":A %s RESV has been placed on nick %s : [%s]",
152 (MyClient(source_p) ? "local" : "remote"), conf->name, conf->reason);
153
154 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
155 "%s has placed a %s RESV on nick %s : [%s]",
156 get_oper_name(source_p),
157 (MyClient(source_p) ? "local" : "remote"),
158 conf->name, conf->reason);
159 ilog(LOG_TYPE_RESV, "%s added RESV for [%s] [%s]",
160 get_oper_name(source_p), conf->name, conf->reason);
161 }
162 }
163 }
164
165 /* mo_resv()
166 * parv[0] = command
167 * parv[1] = channel/nick to forbid
168 */
169 static int
170 mo_resv(struct Client *source_p, int parc, char *parv[])
171 {
172 char *resv = NULL;
173 char *reason = NULL;
174 char *target_server = NULL;
175 time_t tkline_time = 0;
176
177 /* RESV #channel ON irc.server.com :abuse
178 * RESV kiddie ON irc.server.com :abuse
179 */
180 if (parse_aline("RESV", source_p, parc, parv, 0, &resv, NULL,
181 &tkline_time, &target_server, &reason) < 0)
182 return 0;
183
184 if (target_server)
185 {
186 /* if a given expire time is given, ENCAP it */
187 if (tkline_time)
188 sendto_match_servs(source_p, target_server, CAP_ENCAP,
189 "ENCAP %s RESV %d %s 0 :%s",
190 target_server, (int)tkline_time, resv, reason);
191 else
192 sendto_match_servs(source_p, target_server, CAP_CLUSTER,
193 "RESV %s %s :%s",
194 target_server, resv, reason);
195 /* Allow ON to apply local resv as well if it matches */
196 if (match(target_server, me.name))
197 return 0;
198 }
199 else
200 {
201 /* RESV #channel :abuse
202 * RESV kiddie :abuse
203 */
204 if (tkline_time)
205 cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_RESV,
206 "RESV %d %s 0 :%s", (int)tkline_time, resv, reason);
207 else
208 cluster_a_line(source_p, "RESV", CAP_KLN, SHARED_RESV,
209 "%s :%s", resv, reason);
210 }
211
212 parse_resv(source_p, resv, (int)tkline_time, reason);
213 return 0;
214 }
215
216 /* me_resv()
217 *
218 * inputs - server
219 * - client (oper)
220 * - parc number of arguments
221 * - parv list of arguments
222 * via parv[]
223 * parv[0] = command
224 * parv[1] = tkline_time
225 * parv[2] = name
226 * parv[3] = 0
227 * parv[4] = reason
228 * parc should be 5
229 *
230 * outputs - NONE
231 * side effects -
232 */
233 static int
234 me_resv(struct Client *source_p, int parc, char *parv[])
235 {
236 if (parc != 5 || EmptyString(parv[4]))
237 return 0;
238
239 parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
240 return 0;
241 }
242
243 /* ms_resv()
244 * parv[0] = command
245 * parv[1] = target server
246 * parv[2] = channel/nick to resv
247 * parv[3] = reason
248 */
249 static int
250 ms_resv(struct Client *source_p, int parc, char *parv[])
251 {
252 if (parc != 4 || EmptyString(parv[3]))
253 return 0;
254
255 sendto_match_servs(source_p, parv[1], CAP_CLUSTER, "RESV %s %s :%s",
256 parv[1], parv[2], parv[3]);
257
258 if (match(parv[1], me.name))
259 return 0;
260
261 if (HasFlag(source_p, FLAGS_SERVICE) ||
262 find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
263 source_p->username, source_p->host,
264 SHARED_RESV))
265 parse_resv(source_p, parv[2], 0, parv[3]);
266 return 0;
267 }
268
269 static struct Message resv_msgtab =
270 {
271 "RESV", NULL, 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
272 { m_ignore, m_not_oper, ms_resv, me_resv, mo_resv, m_ignore }
273 };
274
275 static void
276 module_init(void)
277 {
278 mod_add_cmd(&resv_msgtab);
279 }
280
281 static void
282 module_exit(void)
283 {
284 mod_del_cmd(&resv_msgtab);
285 }
286
287 struct module module_entry =
288 {
289 .node = { NULL, NULL, NULL },
290 .name = NULL,
291 .version = "$Revision$",
292 .handle = NULL,
293 .modinit = module_init,
294 .modexit = module_exit,
295 .flags = 0
296 };

Properties

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