]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_resv.c: Reserves(jupes) a nickname or channel. | |
4 | * | |
5 | * Copyright (C) 2001-2002 Hybrid Development Team | |
6 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
21 | * USA | |
22 | * | |
8bbeb278 | 23 | * $Id$ |
212380e3 AC |
24 | */ |
25 | ||
26 | #include "stdinc.h" | |
27 | #include "client.h" | |
28 | #include "channel.h" | |
29 | #include "ircd.h" | |
30 | #include "numeric.h" | |
31 | #include "s_serv.h" | |
32 | #include "send.h" | |
33 | #include "msg.h" | |
34 | #include "parse.h" | |
35 | #include "modules.h" | |
36 | #include "s_conf.h" | |
37 | #include "s_newconf.h" | |
38 | #include "hash.h" | |
4016731b | 39 | #include "logger.h" |
8bbeb278 | 40 | #include "bandbi.h" |
212380e3 AC |
41 | |
42 | static int mo_resv(struct Client *, struct Client *, int, const char **); | |
43 | static int ms_resv(struct Client *, struct Client *, int, const char **); | |
44 | static int me_resv(struct Client *, struct Client *, int, const char **); | |
45 | static int mo_unresv(struct Client *, struct Client *, int, const char **); | |
46 | static int ms_unresv(struct Client *, struct Client *, int, const char **); | |
47 | static int me_unresv(struct Client *, struct Client *, int, const char **); | |
48 | ||
49 | struct Message resv_msgtab = { | |
50 | "RESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
51 | {mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}} | |
52 | }; | |
8bbeb278 | 53 | |
212380e3 AC |
54 | struct Message unresv_msgtab = { |
55 | "UNRESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
56 | {mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}} | |
57 | }; | |
58 | ||
8bbeb278 AC |
59 | mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL }; |
60 | ||
61 | DECLARE_MODULE_AV1(resv, NULL, NULL, resv_clist, NULL, NULL, "$Revision$"); | |
212380e3 AC |
62 | |
63 | static void parse_resv(struct Client *source_p, const char *name, | |
8bbeb278 | 64 | const char *reason, int temp_time); |
212380e3 | 65 | static void propagate_resv(struct Client *source_p, const char *target, |
8bbeb278 AC |
66 | int temp_time, const char *name, const char *reason); |
67 | static void cluster_resv(struct Client *source_p, int temp_time, | |
68 | const char *name, const char *reason); | |
212380e3 AC |
69 | |
70 | static void handle_remote_unresv(struct Client *source_p, const char *name); | |
71 | static void remove_resv(struct Client *source_p, const char *name); | |
43d4d72c | 72 | static void resv_chan_forcepart(const char *name, const char *reason, int temp_time); |
212380e3 AC |
73 | |
74 | /* | |
75 | * mo_resv() | |
8bbeb278 | 76 | * parv[0] = sender prefix |
212380e3 AC |
77 | * parv[1] = channel/nick to forbid |
78 | * parv[2] = reason | |
79 | */ | |
80 | static int | |
81 | mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
82 | { | |
83 | const char *name; | |
84 | const char *reason; | |
85 | const char *target_server = NULL; | |
86 | int temp_time; | |
87 | int loc = 1; | |
88 | ||
1ebe6ffc JT |
89 | if(!IsOperResv(source_p)) |
90 | { | |
8bbeb278 | 91 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv"); |
1ebe6ffc JT |
92 | return 0; |
93 | } | |
94 | ||
212380e3 AC |
95 | /* RESV [time] <name> [ON <server>] :<reason> */ |
96 | ||
97 | if((temp_time = valid_temp_time(parv[loc])) >= 0) | |
98 | loc++; | |
99 | /* we just set temp_time to -1! */ | |
100 | else | |
101 | temp_time = 0; | |
102 | ||
103 | name = parv[loc]; | |
104 | loc++; | |
105 | ||
8bbeb278 | 106 | if((parc >= loc + 2) && (irccmp(parv[loc], "ON") == 0)) |
212380e3 AC |
107 | { |
108 | if(!IsOperRemoteBan(source_p)) | |
109 | { | |
110 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 111 | me.name, source_p->name, "remoteban"); |
212380e3 AC |
112 | return 0; |
113 | } | |
114 | ||
8bbeb278 | 115 | target_server = parv[loc + 1]; |
212380e3 AC |
116 | loc += 2; |
117 | } | |
118 | ||
119 | if(parc <= loc || EmptyString(parv[loc])) | |
120 | { | |
8bbeb278 | 121 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "RESV"); |
212380e3 AC |
122 | return 0; |
123 | } | |
124 | ||
125 | reason = parv[loc]; | |
126 | ||
127 | /* remote resv.. */ | |
128 | if(target_server) | |
129 | { | |
130 | propagate_resv(source_p, target_server, temp_time, name, reason); | |
131 | ||
132 | if(match(target_server, me.name) == 0) | |
133 | return 0; | |
134 | } | |
5b96d9a6 | 135 | else if(rb_dlink_list_length(&cluster_conf_list) > 0) |
212380e3 AC |
136 | cluster_resv(source_p, temp_time, name, reason); |
137 | ||
138 | parse_resv(source_p, name, reason, temp_time); | |
139 | ||
140 | return 0; | |
141 | } | |
142 | ||
143 | /* ms_resv() | |
8bbeb278 | 144 | * parv[0] = sender prefix |
212380e3 AC |
145 | * parv[1] = target server |
146 | * parv[2] = channel/nick to forbid | |
147 | * parv[3] = reason | |
148 | */ | |
149 | static int | |
8bbeb278 | 150 | ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 151 | { |
8bbeb278 AC |
152 | /* parv[0] parv[1] parv[2] parv[3] |
153 | * oper target server resv reason | |
212380e3 AC |
154 | */ |
155 | propagate_resv(source_p, parv[1], 0, parv[2], parv[3]); | |
156 | ||
157 | if(!match(parv[1], me.name)) | |
158 | return 0; | |
159 | ||
160 | if(!IsPerson(source_p)) | |
161 | return 0; | |
162 | ||
163 | parse_resv(source_p, parv[2], parv[3], 0); | |
164 | return 0; | |
165 | } | |
166 | ||
167 | static int | |
8bbeb278 | 168 | me_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
169 | { |
170 | /* time name 0 :reason */ | |
171 | if(!IsPerson(source_p)) | |
172 | return 0; | |
173 | ||
174 | parse_resv(source_p, parv[2], parv[4], atoi(parv[1])); | |
175 | return 0; | |
176 | } | |
177 | ||
178 | /* parse_resv() | |
179 | * | |
180 | * inputs - source_p if error messages wanted | |
181 | * - thing to resv | |
182 | * - reason for resv | |
183 | * outputs - | |
184 | * side effects - will parse the resv and create it if valid | |
185 | */ | |
186 | static void | |
8bbeb278 | 187 | parse_resv(struct Client *source_p, const char *name, const char *reason, int temp_time) |
212380e3 AC |
188 | { |
189 | struct ConfItem *aconf; | |
190 | ||
8bbeb278 | 191 | if(!MyClient(source_p) && |
212380e3 | 192 | !find_shared_conf(source_p->username, source_p->host, |
8bbeb278 AC |
193 | source_p->servptr->name, |
194 | (temp_time > 0) ? SHARED_TRESV : SHARED_PRESV)) | |
212380e3 AC |
195 | return; |
196 | ||
197 | if(IsChannelName(name)) | |
198 | { | |
199 | if(hash_find_resv(name)) | |
200 | { | |
201 | sendto_one_notice(source_p, | |
8bbeb278 | 202 | ":A RESV has already been placed on channel: %s", name); |
212380e3 AC |
203 | return; |
204 | } | |
205 | ||
206 | if(strlen(name) > CHANNELLEN) | |
207 | { | |
8bbeb278 | 208 | sendto_one_notice(source_p, ":Invalid RESV length: %s", name); |
b0f30fa1 JT |
209 | return; |
210 | } | |
212380e3 AC |
211 | |
212 | if(strchr(reason, '"')) | |
213 | { | |
8bbeb278 | 214 | sendto_one_notice(source_p, ":Invalid character '\"' in comment"); |
212380e3 AC |
215 | return; |
216 | } | |
217 | ||
218 | aconf = make_conf(); | |
219 | aconf->status = CONF_RESV_CHANNEL; | |
220 | aconf->port = 0; | |
b52c2949 | 221 | aconf->created = rb_current_time(); |
23959371 | 222 | aconf->host = rb_strdup(name); |
47a03750 | 223 | aconf->passwd = rb_strdup(reason); |
23959371 | 224 | add_to_resv_hash(aconf->host, aconf); |
43d4d72c | 225 | resv_chan_forcepart(aconf->host, aconf->passwd, temp_time); |
212380e3 AC |
226 | |
227 | if(temp_time > 0) | |
228 | { | |
e3354945 | 229 | aconf->hold = rb_current_time() + temp_time; |
212380e3 AC |
230 | |
231 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
8bbeb278 AC |
232 | "%s added temporary %d min. RESV for [%s] [%s]", |
233 | get_oper_name(source_p), temp_time / 60, | |
234 | name, reason); | |
212380e3 | 235 | ilog(L_KLINE, "R %s %d %s %s", |
8bbeb278 | 236 | get_oper_name(source_p), temp_time / 60, name, reason); |
212380e3 | 237 | sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]", |
8bbeb278 | 238 | temp_time / 60, name); |
212380e3 AC |
239 | } |
240 | else | |
00c036b1 AC |
241 | { |
242 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
243 | "%s added RESV for [%s] [%s]", | |
244 | get_oper_name(source_p), name, reason); | |
245 | ilog(L_KLINE, "R %s 0 %s %s", | |
246 | get_oper_name(source_p), name, reason); | |
247 | sendto_one_notice(source_p, ":Added RESV [%s]", name); | |
248 | ||
23959371 | 249 | bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); |
00c036b1 | 250 | } |
212380e3 AC |
251 | } |
252 | else if(clean_resv_nick(name)) | |
253 | { | |
8bbeb278 | 254 | if(strlen(name) > NICKLEN * 2) |
212380e3 | 255 | { |
8bbeb278 | 256 | sendto_one_notice(source_p, ":Invalid RESV length: %s", name); |
212380e3 AC |
257 | return; |
258 | } | |
259 | ||
260 | if(strchr(reason, '"')) | |
261 | { | |
8bbeb278 | 262 | sendto_one_notice(source_p, ":Invalid character '\"' in comment"); |
212380e3 AC |
263 | return; |
264 | } | |
265 | ||
266 | if(!valid_wild_card_simple(name)) | |
267 | { | |
268 | sendto_one_notice(source_p, | |
8bbeb278 AC |
269 | ":Please include at least %d non-wildcard " |
270 | "characters with the resv", | |
271 | ConfigFileEntry.min_nonwildcard_simple); | |
212380e3 AC |
272 | return; |
273 | } | |
274 | ||
0fdb2570 | 275 | if(find_nick_resv_mask(name)) |
212380e3 AC |
276 | { |
277 | sendto_one_notice(source_p, | |
8bbeb278 | 278 | ":A RESV has already been placed on nick: %s", name); |
212380e3 AC |
279 | return; |
280 | } | |
281 | ||
282 | aconf = make_conf(); | |
283 | aconf->status = CONF_RESV_NICK; | |
284 | aconf->port = 0; | |
b52c2949 | 285 | aconf->created = rb_current_time(); |
23959371 | 286 | aconf->host = rb_strdup(name); |
47a03750 | 287 | aconf->passwd = rb_strdup(reason); |
7018b86a | 288 | rb_dlinkAddAlloc(aconf, &resv_conf_list); |
212380e3 AC |
289 | |
290 | if(temp_time > 0) | |
291 | { | |
e3354945 | 292 | aconf->hold = rb_current_time() + temp_time; |
212380e3 AC |
293 | |
294 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
8bbeb278 AC |
295 | "%s added temporary %d min. RESV for [%s] [%s]", |
296 | get_oper_name(source_p), temp_time / 60, | |
297 | name, reason); | |
212380e3 | 298 | ilog(L_KLINE, "R %s %d %s %s", |
8bbeb278 | 299 | get_oper_name(source_p), temp_time / 60, name, reason); |
212380e3 | 300 | sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]", |
8bbeb278 | 301 | temp_time / 60, name); |
212380e3 AC |
302 | } |
303 | else | |
00c036b1 AC |
304 | { |
305 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
306 | "%s added RESV for [%s] [%s]", | |
307 | get_oper_name(source_p), name, reason); | |
308 | ilog(L_KLINE, "R %s 0 %s %s", | |
309 | get_oper_name(source_p), name, reason); | |
310 | sendto_one_notice(source_p, ":Added RESV [%s]", name); | |
311 | ||
23959371 | 312 | bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); |
00c036b1 | 313 | } |
212380e3 AC |
314 | } |
315 | else | |
8bbeb278 | 316 | sendto_one_notice(source_p, ":You have specified an invalid resv: [%s]", name); |
212380e3 AC |
317 | } |
318 | ||
8bbeb278 | 319 | static void |
212380e3 | 320 | propagate_resv(struct Client *source_p, const char *target, |
8bbeb278 | 321 | int temp_time, const char *name, const char *reason) |
212380e3 AC |
322 | { |
323 | if(!temp_time) | |
324 | { | |
325 | sendto_match_servs(source_p, target, | |
8bbeb278 | 326 | CAP_CLUSTER, NOCAPS, "RESV %s %s :%s", target, name, reason); |
212380e3 | 327 | sendto_match_servs(source_p, target, |
8bbeb278 AC |
328 | CAP_ENCAP, CAP_CLUSTER, |
329 | "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason); | |
212380e3 AC |
330 | } |
331 | else | |
332 | sendto_match_servs(source_p, target, | |
8bbeb278 AC |
333 | CAP_ENCAP, NOCAPS, |
334 | "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason); | |
212380e3 AC |
335 | } |
336 | ||
337 | static void | |
8bbeb278 | 338 | cluster_resv(struct Client *source_p, int temp_time, const char *name, const char *reason) |
212380e3 AC |
339 | { |
340 | struct remote_conf *shared_p; | |
5b96d9a6 | 341 | rb_dlink_node *ptr; |
212380e3 | 342 | |
5b96d9a6 | 343 | RB_DLINK_FOREACH(ptr, cluster_conf_list.head) |
212380e3 AC |
344 | { |
345 | shared_p = ptr->data; | |
346 | ||
347 | /* old protocol cant handle temps, and we dont really want | |
348 | * to convert them to perm.. --fl | |
349 | */ | |
350 | if(!temp_time) | |
351 | { | |
352 | if(!(shared_p->flags & SHARED_PRESV)) | |
353 | continue; | |
354 | ||
355 | sendto_match_servs(source_p, shared_p->server, | |
8bbeb278 AC |
356 | CAP_CLUSTER, NOCAPS, |
357 | "RESV %s %s :%s", shared_p->server, name, reason); | |
212380e3 | 358 | sendto_match_servs(source_p, shared_p->server, |
8bbeb278 AC |
359 | CAP_ENCAP, CAP_CLUSTER, |
360 | "ENCAP %s RESV 0 %s 0 :%s", | |
361 | shared_p->server, name, reason); | |
212380e3 AC |
362 | } |
363 | else if(shared_p->flags & SHARED_TRESV) | |
364 | sendto_match_servs(source_p, shared_p->server, | |
8bbeb278 AC |
365 | CAP_ENCAP, NOCAPS, |
366 | "ENCAP %s RESV %d %s 0 :%s", | |
367 | shared_p->server, temp_time, name, reason); | |
212380e3 AC |
368 | } |
369 | } | |
370 | ||
371 | ||
372 | /* | |
373 | * mo_unresv() | |
8bbeb278 | 374 | * parv[0] = sender prefix |
212380e3 AC |
375 | * parv[1] = channel/nick to unforbid |
376 | */ | |
377 | static int | |
378 | mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
379 | { | |
1ebe6ffc JT |
380 | if(!IsOperResv(source_p)) |
381 | { | |
8bbeb278 | 382 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv"); |
1ebe6ffc JT |
383 | return 0; |
384 | } | |
385 | ||
212380e3 AC |
386 | if((parc == 4) && (irccmp(parv[2], "ON") == 0)) |
387 | { | |
388 | if(!IsOperRemoteBan(source_p)) | |
389 | { | |
390 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 391 | me.name, source_p->name, "remoteban"); |
212380e3 AC |
392 | return 0; |
393 | } | |
394 | ||
8bbeb278 | 395 | propagate_generic(source_p, "UNRESV", parv[3], CAP_CLUSTER, "%s", parv[1]); |
212380e3 AC |
396 | |
397 | if(match(parv[3], me.name) == 0) | |
398 | return 0; | |
399 | } | |
5b96d9a6 | 400 | else if(rb_dlink_list_length(&cluster_conf_list) > 0) |
8bbeb278 | 401 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", parv[1]); |
212380e3 | 402 | |
212380e3 AC |
403 | remove_resv(source_p, parv[1]); |
404 | return 0; | |
405 | } | |
406 | ||
407 | /* ms_unresv() | |
8bbeb278 | 408 | * parv[0] = sender prefix |
212380e3 AC |
409 | * parv[1] = target server |
410 | * parv[2] = resv to remove | |
411 | */ | |
412 | static int | |
413 | ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
414 | { | |
8bbeb278 AC |
415 | /* parv[0] parv[1] parv[2] |
416 | * oper target server resv to remove | |
212380e3 | 417 | */ |
8bbeb278 | 418 | propagate_generic(source_p, "UNRESV", parv[1], CAP_CLUSTER, "%s", parv[2]); |
212380e3 AC |
419 | |
420 | if(!match(parv[1], me.name)) | |
421 | return 0; | |
422 | ||
423 | if(!IsPerson(source_p)) | |
424 | return 0; | |
425 | ||
426 | handle_remote_unresv(source_p, parv[2]); | |
427 | return 0; | |
428 | } | |
429 | ||
430 | static int | |
431 | me_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
432 | { | |
433 | /* name */ | |
434 | if(!IsPerson(source_p)) | |
435 | return 0; | |
436 | ||
437 | handle_remote_unresv(source_p, parv[1]); | |
438 | return 0; | |
439 | } | |
440 | ||
441 | static void | |
442 | handle_remote_unresv(struct Client *source_p, const char *name) | |
443 | { | |
444 | if(!find_shared_conf(source_p->username, source_p->host, | |
8bbeb278 | 445 | source_p->servptr->name, SHARED_UNRESV)) |
212380e3 AC |
446 | return; |
447 | ||
212380e3 AC |
448 | remove_resv(source_p, name); |
449 | ||
450 | return; | |
451 | } | |
452 | ||
1328da86 JT |
453 | static void |
454 | remove_resv(struct Client *source_p, const char *name) | |
212380e3 AC |
455 | { |
456 | struct ConfItem *aconf = NULL; | |
457 | ||
458 | if(IsChannelName(name)) | |
459 | { | |
460 | if((aconf = hash_find_resv(name)) == NULL) | |
1328da86 JT |
461 | { |
462 | sendto_one_notice(source_p, ":No RESV for %s", name); | |
463 | return; | |
464 | } | |
212380e3 | 465 | |
a990586f JT |
466 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); |
467 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); | |
212380e3 | 468 | if(!aconf->hold) |
1a9ea263 | 469 | { |
8bbeb278 | 470 | bandb_del(BANDB_RESV, aconf->host, NULL); |
1a9ea263 JT |
471 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
472 | "%s has removed the RESV for: [%s]", | |
473 | get_oper_name(source_p), name); | |
1a9ea263 | 474 | } |
1328da86 JT |
475 | else |
476 | { | |
1328da86 | 477 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
a990586f | 478 | "%s has removed the temporary RESV for: [%s]", |
8bbeb278 | 479 | get_oper_name(source_p), name); |
1328da86 | 480 | } |
212380e3 | 481 | del_from_resv_hash(name, aconf); |
212380e3 AC |
482 | } |
483 | else | |
484 | { | |
5b96d9a6 | 485 | rb_dlink_node *ptr; |
212380e3 | 486 | |
5b96d9a6 | 487 | RB_DLINK_FOREACH(ptr, resv_conf_list.head) |
212380e3 AC |
488 | { |
489 | aconf = ptr->data; | |
490 | ||
23959371 | 491 | if(irccmp(aconf->host, name)) |
212380e3 AC |
492 | aconf = NULL; |
493 | else | |
494 | break; | |
495 | } | |
496 | ||
497 | if(aconf == NULL) | |
1328da86 JT |
498 | { |
499 | sendto_one_notice(source_p, ":No RESV for %s", name); | |
500 | return; | |
501 | } | |
212380e3 | 502 | |
212380e3 | 503 | if(!aconf->hold) |
8bbeb278 | 504 | bandb_del(BANDB_RESV, aconf->host, NULL); |
1328da86 JT |
505 | else |
506 | { | |
507 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); | |
508 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
8bbeb278 AC |
509 | "%s has removed the RESV for: [%s]", |
510 | get_oper_name(source_p), name); | |
1328da86 JT |
511 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); |
512 | } | |
212380e3 | 513 | /* already have ptr from the loop above.. */ |
555ac41f | 514 | rb_dlinkDestroy(ptr, &resv_conf_list); |
212380e3 | 515 | } |
1328da86 | 516 | free_conf(aconf); |
212380e3 | 517 | |
1328da86 | 518 | return; |
212380e3 | 519 | } |
43d4d72c JT |
520 | |
521 | static void | |
522 | resv_chan_forcepart(const char *name, const char *reason, int temp_time) | |
523 | { | |
524 | rb_dlink_node *ptr; | |
525 | rb_dlink_node *next_ptr; | |
526 | struct Channel *chptr; | |
527 | struct membership *msptr; | |
528 | struct Client *target_p; | |
529 | ||
530 | if(!ConfigChannel.resv_forcepart) | |
531 | return; | |
532 | ||
533 | /* for each user on our server in the channel list | |
534 | * send them a PART, and notify opers. | |
535 | */ | |
536 | chptr = find_channel(name); | |
537 | if(chptr != NULL) | |
538 | { | |
539 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) | |
540 | { | |
541 | msptr = ptr->data; | |
542 | target_p = msptr->client_p; | |
543 | ||
544 | if(IsExemptResv(target_p)) | |
545 | continue; | |
546 | ||
547 | sendto_server(target_p, chptr, CAP_TS6, NOCAPS, | |
548 | ":%s PART %s", target_p->id, chptr->chname); | |
549 | ||
550 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s", | |
551 | target_p->name, target_p->username, | |
552 | target_p->host, chptr->chname, target_p->name); | |
553 | ||
554 | remove_user_from_channel(msptr); | |
555 | ||
556 | /* notify opers & user they were removed from the channel */ | |
557 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
558 | "Forced PART for %s!%s@%s from %s (%s)", | |
559 | target_p->name, target_p->username, | |
560 | target_p->host, name, reason); | |
561 | ||
562 | if(temp_time > 0) | |
563 | sendto_one_notice(target_p, ":*** Channel %s is temporarily unavailable on this server.", | |
564 | name); | |
565 | else | |
566 | sendto_one_notice(target_p, ":*** Channel %s is no longer available on this server.", | |
567 | name); | |
568 | } | |
569 | } | |
570 | } |