]>
Commit | Line | Data |
---|---|---|
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 | * | |
23 | * $Id$ | |
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" | |
39 | #include "logger.h" | |
40 | #include "bandbi.h" | |
41 | #include "operhash.h" | |
42 | ||
43 | static int mo_resv(struct Client *, struct Client *, int, const char **); | |
44 | static int ms_resv(struct Client *, struct Client *, int, const char **); | |
45 | static int me_resv(struct Client *, struct Client *, int, const char **); | |
46 | static int mo_unresv(struct Client *, struct Client *, int, const char **); | |
47 | static int ms_unresv(struct Client *, struct Client *, int, const char **); | |
48 | static int me_unresv(struct Client *, struct Client *, int, const char **); | |
49 | ||
50 | struct Message resv_msgtab = { | |
51 | "RESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
52 | {mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}} | |
53 | }; | |
54 | ||
55 | struct Message unresv_msgtab = { | |
56 | "UNRESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
57 | {mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}} | |
58 | }; | |
59 | ||
60 | mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL }; | |
61 | ||
62 | DECLARE_MODULE_AV1(resv, NULL, NULL, resv_clist, NULL, NULL, "$Revision$"); | |
63 | ||
64 | static void parse_resv(struct Client *source_p, const char *name, | |
65 | const char *reason, int temp_time, int propagated); | |
66 | static void propagate_resv(struct Client *source_p, const char *target, | |
67 | int temp_time, const char *name, const char *reason); | |
68 | static void cluster_resv(struct Client *source_p, int temp_time, | |
69 | const char *name, const char *reason); | |
70 | ||
71 | static void handle_remote_unresv(struct Client *source_p, const char *name); | |
72 | static void remove_resv(struct Client *source_p, const char *name, int propagated); | |
73 | ||
74 | /* | |
75 | * mo_resv() | |
76 | * parv[0] = sender prefix | |
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 | int propagated = ConfigFileEntry.use_propagated_bans; | |
89 | ||
90 | if(!IsOperResv(source_p)) | |
91 | { | |
92 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv"); | |
93 | return 0; | |
94 | } | |
95 | ||
96 | /* RESV [time] <name> [ON <server>] :<reason> */ | |
97 | ||
98 | if((temp_time = valid_temp_time(parv[loc])) >= 0) | |
99 | loc++; | |
100 | /* we just set temp_time to -1! */ | |
101 | else | |
102 | temp_time = 0; | |
103 | ||
104 | name = parv[loc]; | |
105 | loc++; | |
106 | ||
107 | if((parc >= loc + 2) && (irccmp(parv[loc], "ON") == 0)) | |
108 | { | |
109 | if(!IsOperRemoteBan(source_p)) | |
110 | { | |
111 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
112 | me.name, source_p->name, "remoteban"); | |
113 | return 0; | |
114 | } | |
115 | ||
116 | target_server = parv[loc + 1]; | |
117 | loc += 2; | |
118 | ||
119 | /* Set as local-only. */ | |
120 | propagated = 0; | |
121 | } | |
122 | ||
123 | if(parc <= loc || EmptyString(parv[loc])) | |
124 | { | |
125 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "RESV"); | |
126 | return 0; | |
127 | } | |
128 | ||
129 | reason = parv[loc]; | |
130 | ||
131 | /* remote resv.. */ | |
132 | if(target_server) | |
133 | { | |
134 | propagate_resv(source_p, target_server, temp_time, name, reason); | |
135 | ||
136 | if(match(target_server, me.name) == 0) | |
137 | return 0; | |
138 | } | |
139 | else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0) | |
140 | cluster_resv(source_p, temp_time, name, reason); | |
141 | ||
142 | if(propagated && temp_time == 0) | |
143 | { | |
144 | sendto_one_notice(source_p, ":Cannot set a permanent global ban"); | |
145 | return 0; | |
146 | } | |
147 | ||
148 | parse_resv(source_p, name, reason, temp_time, propagated); | |
149 | ||
150 | return 0; | |
151 | } | |
152 | ||
153 | /* ms_resv() | |
154 | * parv[0] = sender prefix | |
155 | * parv[1] = target server | |
156 | * parv[2] = channel/nick to forbid | |
157 | * parv[3] = reason | |
158 | */ | |
159 | static int | |
160 | ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
161 | { | |
162 | /* parv[0] parv[1] parv[2] parv[3] | |
163 | * oper target server resv reason | |
164 | */ | |
165 | propagate_resv(source_p, parv[1], 0, parv[2], parv[3]); | |
166 | ||
167 | if(!match(parv[1], me.name)) | |
168 | return 0; | |
169 | ||
170 | if(!IsPerson(source_p)) | |
171 | return 0; | |
172 | ||
173 | parse_resv(source_p, parv[2], parv[3], 0, 0); | |
174 | return 0; | |
175 | } | |
176 | ||
177 | static int | |
178 | me_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
179 | { | |
180 | /* time name 0 :reason */ | |
181 | if(!IsPerson(source_p)) | |
182 | return 0; | |
183 | ||
184 | parse_resv(source_p, parv[2], parv[4], atoi(parv[1]), 0); | |
185 | return 0; | |
186 | } | |
187 | ||
188 | /* parse_resv() | |
189 | * | |
190 | * inputs - source_p if error messages wanted | |
191 | * - thing to resv | |
192 | * - reason for resv | |
193 | * outputs - | |
194 | * side effects - will parse the resv and create it if valid | |
195 | */ | |
196 | static void | |
197 | parse_resv(struct Client *source_p, const char *name, const char *reason, int temp_time, int propagated) | |
198 | { | |
199 | struct ConfItem *aconf; | |
200 | ||
201 | if(!MyClient(source_p) && | |
202 | !find_shared_conf(source_p->username, source_p->host, | |
203 | source_p->servptr->name, | |
204 | (temp_time > 0) ? SHARED_TRESV : SHARED_PRESV)) | |
205 | return; | |
206 | ||
207 | if(IsChannelName(name)) | |
208 | { | |
209 | if(hash_find_resv(name)) | |
210 | { | |
211 | sendto_one_notice(source_p, | |
212 | ":A RESV has already been placed on channel: %s", name); | |
213 | return; | |
214 | } | |
215 | ||
216 | if(strlen(name) > CHANNELLEN) | |
217 | { | |
218 | sendto_one_notice(source_p, ":Invalid RESV length: %s", name); | |
219 | return; | |
220 | } | |
221 | ||
222 | aconf = make_conf(); | |
223 | aconf->status = CONF_RESV_CHANNEL; | |
224 | aconf->port = 0; | |
225 | aconf->created = rb_current_time(); | |
226 | aconf->host = rb_strdup(name); | |
227 | aconf->passwd = rb_strdup(reason); | |
228 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
229 | ||
230 | if(propagated) | |
231 | { | |
232 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
233 | aconf->hold = rb_current_time() + temp_time; | |
234 | aconf->lifetime = aconf->hold; | |
235 | replace_old_ban(aconf); | |
236 | rb_dlinkAddAlloc(aconf, &prop_bans); | |
237 | ||
238 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
239 | "%s added global %d min. RESV for [%s] [%s]", | |
240 | get_oper_name(source_p), temp_time / 60, | |
241 | name, reason); | |
242 | ilog(L_KLINE, "R %s %d %s %s", | |
243 | get_oper_name(source_p), temp_time / 60, name, reason); | |
244 | sendto_one_notice(source_p, ":Added global %d min. RESV [%s]", | |
245 | temp_time / 60, name); | |
246 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
247 | ":%s BAN R * %s %lu %d %d * :%s", | |
248 | source_p->id, aconf->host, | |
249 | (unsigned long)aconf->created, | |
250 | (int)(aconf->hold - aconf->created), | |
251 | (int)(aconf->lifetime - aconf->created), | |
252 | reason); | |
253 | } | |
254 | else if(temp_time > 0) | |
255 | { | |
256 | aconf->hold = rb_current_time() + temp_time; | |
257 | ||
258 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
259 | "%s added temporary %d min. RESV for [%s] [%s]", | |
260 | get_oper_name(source_p), temp_time / 60, | |
261 | name, reason); | |
262 | ilog(L_KLINE, "R %s %d %s %s", | |
263 | get_oper_name(source_p), temp_time / 60, name, reason); | |
264 | sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]", | |
265 | temp_time / 60, name); | |
266 | } | |
267 | else | |
268 | { | |
269 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
270 | "%s added RESV for [%s] [%s]", | |
271 | get_oper_name(source_p), name, reason); | |
272 | ilog(L_KLINE, "R %s 0 %s %s", | |
273 | get_oper_name(source_p), name, reason); | |
274 | sendto_one_notice(source_p, ":Added RESV [%s]", name); | |
275 | ||
276 | bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); | |
277 | } | |
278 | ||
279 | add_to_resv_hash(aconf->host, aconf); | |
280 | resv_chan_forcepart(aconf->host, aconf->passwd, temp_time); | |
281 | } | |
282 | else if(clean_resv_nick(name)) | |
283 | { | |
284 | if(strlen(name) > NICKLEN * 2) | |
285 | { | |
286 | sendto_one_notice(source_p, ":Invalid RESV length: %s", name); | |
287 | return; | |
288 | } | |
289 | ||
290 | if(!valid_wild_card_simple(name)) | |
291 | { | |
292 | sendto_one_notice(source_p, | |
293 | ":Please include at least %d non-wildcard " | |
294 | "characters with the resv", | |
295 | ConfigFileEntry.min_nonwildcard_simple); | |
296 | return; | |
297 | } | |
298 | ||
299 | if(find_nick_resv_mask(name)) | |
300 | { | |
301 | sendto_one_notice(source_p, | |
302 | ":A RESV has already been placed on nick: %s", name); | |
303 | return; | |
304 | } | |
305 | ||
306 | aconf = make_conf(); | |
307 | aconf->status = CONF_RESV_NICK; | |
308 | aconf->port = 0; | |
309 | aconf->created = rb_current_time(); | |
310 | aconf->host = rb_strdup(name); | |
311 | aconf->passwd = rb_strdup(reason); | |
312 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
313 | ||
314 | if(propagated) | |
315 | { | |
316 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
317 | aconf->hold = rb_current_time() + temp_time; | |
318 | aconf->lifetime = aconf->hold; | |
319 | replace_old_ban(aconf); | |
320 | rb_dlinkAddAlloc(aconf, &prop_bans); | |
321 | ||
322 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
323 | "%s added global %d min. RESV for [%s] [%s]", | |
324 | get_oper_name(source_p), temp_time / 60, | |
325 | name, reason); | |
326 | ilog(L_KLINE, "R %s %d %s %s", | |
327 | get_oper_name(source_p), temp_time / 60, name, reason); | |
328 | sendto_one_notice(source_p, ":Added global %d min. RESV [%s]", | |
329 | temp_time / 60, name); | |
330 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
331 | ":%s BAN R * %s %lu %d %d * :%s", | |
332 | source_p->id, aconf->host, | |
333 | (unsigned long)aconf->created, | |
334 | (int)(aconf->hold - aconf->created), | |
335 | (int)(aconf->lifetime - aconf->created), | |
336 | reason); | |
337 | } | |
338 | else if(temp_time > 0) | |
339 | { | |
340 | aconf->hold = rb_current_time() + temp_time; | |
341 | ||
342 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
343 | "%s added temporary %d min. RESV for [%s] [%s]", | |
344 | get_oper_name(source_p), temp_time / 60, | |
345 | name, reason); | |
346 | ilog(L_KLINE, "R %s %d %s %s", | |
347 | get_oper_name(source_p), temp_time / 60, name, reason); | |
348 | sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]", | |
349 | temp_time / 60, name); | |
350 | } | |
351 | else | |
352 | { | |
353 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
354 | "%s added RESV for [%s] [%s]", | |
355 | get_oper_name(source_p), name, reason); | |
356 | ilog(L_KLINE, "R %s 0 %s %s", | |
357 | get_oper_name(source_p), name, reason); | |
358 | sendto_one_notice(source_p, ":Added RESV [%s]", name); | |
359 | ||
360 | bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); | |
361 | } | |
362 | ||
363 | rb_dlinkAddAlloc(aconf, &resv_conf_list); | |
364 | resv_nick_fnc(aconf->host, aconf->passwd, temp_time); | |
365 | } | |
366 | else | |
367 | sendto_one_notice(source_p, ":You have specified an invalid resv: [%s]", name); | |
368 | } | |
369 | ||
370 | static void | |
371 | propagate_resv(struct Client *source_p, const char *target, | |
372 | int temp_time, const char *name, const char *reason) | |
373 | { | |
374 | if(!temp_time) | |
375 | { | |
376 | sendto_match_servs(source_p, target, | |
377 | CAP_CLUSTER, NOCAPS, "RESV %s %s :%s", target, name, reason); | |
378 | sendto_match_servs(source_p, target, | |
379 | CAP_ENCAP, CAP_CLUSTER, | |
380 | "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason); | |
381 | } | |
382 | else | |
383 | sendto_match_servs(source_p, target, | |
384 | CAP_ENCAP, NOCAPS, | |
385 | "ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason); | |
386 | } | |
387 | ||
388 | static void | |
389 | cluster_resv(struct Client *source_p, int temp_time, const char *name, const char *reason) | |
390 | { | |
391 | struct remote_conf *shared_p; | |
392 | rb_dlink_node *ptr; | |
393 | ||
394 | RB_DLINK_FOREACH(ptr, cluster_conf_list.head) | |
395 | { | |
396 | shared_p = ptr->data; | |
397 | ||
398 | /* old protocol cant handle temps, and we dont really want | |
399 | * to convert them to perm.. --fl | |
400 | */ | |
401 | if(!temp_time) | |
402 | { | |
403 | if(!(shared_p->flags & SHARED_PRESV)) | |
404 | continue; | |
405 | ||
406 | sendto_match_servs(source_p, shared_p->server, | |
407 | CAP_CLUSTER, NOCAPS, | |
408 | "RESV %s %s :%s", shared_p->server, name, reason); | |
409 | sendto_match_servs(source_p, shared_p->server, | |
410 | CAP_ENCAP, CAP_CLUSTER, | |
411 | "ENCAP %s RESV 0 %s 0 :%s", | |
412 | shared_p->server, name, reason); | |
413 | } | |
414 | else if(shared_p->flags & SHARED_TRESV) | |
415 | sendto_match_servs(source_p, shared_p->server, | |
416 | CAP_ENCAP, NOCAPS, | |
417 | "ENCAP %s RESV %d %s 0 :%s", | |
418 | shared_p->server, temp_time, name, reason); | |
419 | } | |
420 | } | |
421 | ||
422 | ||
423 | /* | |
424 | * mo_unresv() | |
425 | * parv[0] = sender prefix | |
426 | * parv[1] = channel/nick to unforbid | |
427 | */ | |
428 | static int | |
429 | mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
430 | { | |
431 | int propagated = 1; | |
432 | ||
433 | if(!IsOperResv(source_p)) | |
434 | { | |
435 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv"); | |
436 | return 0; | |
437 | } | |
438 | ||
439 | if((parc == 4) && (irccmp(parv[2], "ON") == 0)) | |
440 | { | |
441 | if(!IsOperRemoteBan(source_p)) | |
442 | { | |
443 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
444 | me.name, source_p->name, "remoteban"); | |
445 | return 0; | |
446 | } | |
447 | ||
448 | propagate_generic(source_p, "UNRESV", parv[3], CAP_CLUSTER, "%s", parv[1]); | |
449 | ||
450 | if(match(parv[3], me.name) == 0) | |
451 | return 0; | |
452 | ||
453 | propagated = 0; | |
454 | } | |
455 | #if 0 | |
456 | else if(rb_dlink_list_length(&cluster_conf_list) > 0) | |
457 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", parv[1]); | |
458 | #endif | |
459 | /* cluster{} moved to remove_resv */ | |
460 | ||
461 | remove_resv(source_p, parv[1], propagated); | |
462 | return 0; | |
463 | } | |
464 | ||
465 | /* ms_unresv() | |
466 | * parv[0] = sender prefix | |
467 | * parv[1] = target server | |
468 | * parv[2] = resv to remove | |
469 | */ | |
470 | static int | |
471 | ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
472 | { | |
473 | /* parv[0] parv[1] parv[2] | |
474 | * oper target server resv to remove | |
475 | */ | |
476 | propagate_generic(source_p, "UNRESV", parv[1], CAP_CLUSTER, "%s", parv[2]); | |
477 | ||
478 | if(!match(parv[1], me.name)) | |
479 | return 0; | |
480 | ||
481 | if(!IsPerson(source_p)) | |
482 | return 0; | |
483 | ||
484 | handle_remote_unresv(source_p, parv[2]); | |
485 | return 0; | |
486 | } | |
487 | ||
488 | static int | |
489 | me_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
490 | { | |
491 | /* name */ | |
492 | if(!IsPerson(source_p)) | |
493 | return 0; | |
494 | ||
495 | handle_remote_unresv(source_p, parv[1]); | |
496 | return 0; | |
497 | } | |
498 | ||
499 | static void | |
500 | handle_remote_unresv(struct Client *source_p, const char *name) | |
501 | { | |
502 | if(!find_shared_conf(source_p->username, source_p->host, | |
503 | source_p->servptr->name, SHARED_UNRESV)) | |
504 | return; | |
505 | ||
506 | remove_resv(source_p, name, 0); | |
507 | ||
508 | return; | |
509 | } | |
510 | ||
511 | static void | |
512 | remove_resv(struct Client *source_p, const char *name, int propagated) | |
513 | { | |
514 | struct ConfItem *aconf = NULL; | |
515 | rb_dlink_node *ptr; | |
516 | ||
517 | if(IsChannelName(name)) | |
518 | { | |
519 | if((aconf = hash_find_resv(name)) == NULL) | |
520 | { | |
521 | if(propagated && rb_dlink_list_length(&cluster_conf_list)) | |
522 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name); | |
523 | ||
524 | sendto_one_notice(source_p, ":No RESV for %s", name); | |
525 | return; | |
526 | } | |
527 | ||
528 | if(aconf->lifetime) | |
529 | { | |
530 | if(!propagated) | |
531 | { | |
532 | sendto_one_notice(source_p, ":Cannot remove global RESV %s on specific servers", name); | |
533 | return; | |
534 | } | |
535 | ptr = rb_dlinkFind(aconf, &prop_bans); | |
536 | if(ptr == NULL) | |
537 | return; | |
538 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); | |
539 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
540 | "%s has removed the global RESV for: [%s]", | |
541 | get_oper_name(source_p), name); | |
542 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); | |
543 | if(aconf->created < rb_current_time()) | |
544 | aconf->created = rb_current_time(); | |
545 | else | |
546 | aconf->created++; | |
547 | aconf->hold = aconf->created; | |
548 | operhash_delete(aconf->info.oper); | |
549 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
550 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
551 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
552 | ":%s BAN R * %s %lu %d %d * :*", | |
553 | source_p->id, aconf->host, | |
554 | (unsigned long)aconf->created, | |
555 | 0, | |
556 | (int)(aconf->lifetime - aconf->created)); | |
557 | deactivate_conf(aconf, ptr); | |
558 | return; | |
559 | } | |
560 | else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0) | |
561 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name); | |
562 | ||
563 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); | |
564 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); | |
565 | if(!aconf->hold) | |
566 | { | |
567 | bandb_del(BANDB_RESV, aconf->host, NULL); | |
568 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
569 | "%s has removed the RESV for: [%s]", | |
570 | get_oper_name(source_p), name); | |
571 | } | |
572 | else | |
573 | { | |
574 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
575 | "%s has removed the temporary RESV for: [%s]", | |
576 | get_oper_name(source_p), name); | |
577 | } | |
578 | del_from_resv_hash(name, aconf); | |
579 | } | |
580 | else | |
581 | { | |
582 | RB_DLINK_FOREACH(ptr, resv_conf_list.head) | |
583 | { | |
584 | aconf = ptr->data; | |
585 | ||
586 | if(irccmp(aconf->host, name)) | |
587 | aconf = NULL; | |
588 | else | |
589 | break; | |
590 | } | |
591 | ||
592 | if(aconf == NULL) | |
593 | { | |
594 | if(propagated && rb_dlink_list_length(&cluster_conf_list)) | |
595 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name); | |
596 | ||
597 | sendto_one_notice(source_p, ":No RESV for %s", name); | |
598 | return; | |
599 | } | |
600 | ||
601 | if(aconf->lifetime) | |
602 | { | |
603 | if(!propagated) | |
604 | { | |
605 | sendto_one_notice(source_p, ":Cannot remove global RESV %s on specific servers", name); | |
606 | return; | |
607 | } | |
608 | ptr = rb_dlinkFind(aconf, &prop_bans); | |
609 | if(ptr == NULL) | |
610 | return; | |
611 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); | |
612 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
613 | "%s has removed the global RESV for: [%s]", | |
614 | get_oper_name(source_p), name); | |
615 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); | |
616 | if(aconf->created < rb_current_time()) | |
617 | aconf->created = rb_current_time(); | |
618 | else | |
619 | aconf->created++; | |
620 | aconf->hold = aconf->created; | |
621 | operhash_delete(aconf->info.oper); | |
622 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
623 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
624 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
625 | ":%s BAN R * %s %lu %d %d * :*", | |
626 | source_p->id, aconf->host, | |
627 | (unsigned long)aconf->created, | |
628 | 0, | |
629 | (int)(aconf->lifetime - aconf->created)); | |
630 | deactivate_conf(aconf, ptr); | |
631 | return; | |
632 | } | |
633 | else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0) | |
634 | cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name); | |
635 | ||
636 | sendto_one_notice(source_p, ":RESV for [%s] is removed", name); | |
637 | ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name); | |
638 | if(!aconf->hold) | |
639 | { | |
640 | bandb_del(BANDB_RESV, aconf->host, NULL); | |
641 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
642 | "%s has removed the RESV for: [%s]", | |
643 | get_oper_name(source_p), name); | |
644 | } | |
645 | else | |
646 | { | |
647 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
648 | "%s has removed the temporary RESV for: [%s]", | |
649 | get_oper_name(source_p), name); | |
650 | } | |
651 | /* already have ptr from the loop above.. */ | |
652 | rb_dlinkDestroy(ptr, &resv_conf_list); | |
653 | } | |
654 | free_conf(aconf); | |
655 | ||
656 | return; | |
657 | } |