]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* modules/m_xline.c |
55abcbb2 | 2 | * |
212380e3 AC |
3 | * Copyright (C) 2002-2003 Lee Hardy <lee@leeh.co.uk> |
4 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are | |
8 | * met: | |
9 | * | |
10 | * 1.Redistributions of source code must retain the above copyright notice, | |
11 | * this list of conditions and the following disclaimer. | |
12 | * 2.Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3.The name of the author may not be used to endorse or promote products | |
16 | * derived from this software without specific prior written permission. | |
17 | * | |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
28 | * POSSIBILITY OF SUCH DAMAGE. | |
212380e3 AC |
29 | */ |
30 | ||
31 | #include "stdinc.h" | |
212380e3 AC |
32 | #include "send.h" |
33 | #include "channel.h" | |
34 | #include "client.h" | |
35 | #include "common.h" | |
36 | #include "config.h" | |
37 | #include "class.h" | |
38 | #include "ircd.h" | |
39 | #include "numeric.h" | |
4016731b | 40 | #include "logger.h" |
212380e3 AC |
41 | #include "s_serv.h" |
42 | #include "whowas.h" | |
4562c604 | 43 | #include "match.h" |
212380e3 AC |
44 | #include "hash.h" |
45 | #include "msg.h" | |
46 | #include "parse.h" | |
47 | #include "modules.h" | |
48 | #include "s_conf.h" | |
49 | #include "s_newconf.h" | |
35f6f850 | 50 | #include "reject.h" |
8bbeb278 | 51 | #include "bandbi.h" |
27f616dd | 52 | #include "operhash.h" |
212380e3 | 53 | |
428ca87b AC |
54 | static int mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); |
55 | static int ms_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); | |
56 | static int me_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); | |
57 | static int mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, | |
8bbeb278 | 58 | const char *parv[]); |
428ca87b | 59 | static int ms_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, |
8bbeb278 | 60 | const char *parv[]); |
428ca87b | 61 | static int me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, |
8bbeb278 | 62 | const char *parv[]); |
212380e3 AC |
63 | |
64 | struct Message xline_msgtab = { | |
7baa37a9 | 65 | "XLINE", 0, 0, 0, 0, |
212380e3 AC |
66 | {mg_unreg, mg_not_oper, {ms_xline, 5}, {ms_xline, 5}, {me_xline, 5}, {mo_xline, 3}} |
67 | }; | |
8bbeb278 | 68 | |
212380e3 | 69 | struct Message unxline_msgtab = { |
7baa37a9 | 70 | "UNXLINE", 0, 0, 0, 0, |
212380e3 AC |
71 | {mg_unreg, mg_not_oper, {ms_unxline, 3}, {ms_unxline, 3}, {me_unxline, 2}, {mo_unxline, 2}} |
72 | }; | |
73 | ||
8bbeb278 AC |
74 | mapi_clist_av1 xline_clist[] = { &xline_msgtab, &unxline_msgtab, NULL }; |
75 | ||
105a4985 | 76 | DECLARE_MODULE_AV2(xline, NULL, NULL, xline_clist, NULL, NULL, NULL, NULL, NULL); |
212380e3 | 77 | |
8bbeb278 AC |
78 | static int valid_xline(struct Client *, const char *, const char *); |
79 | static void apply_xline(struct Client *client_p, const char *name, | |
3cbbfb25 | 80 | const char *reason, int temp_time, int propagated); |
212380e3 | 81 | static void propagate_xline(struct Client *source_p, const char *target, |
8bbeb278 | 82 | int temp_time, const char *name, const char *type, const char *reason); |
212380e3 | 83 | static void cluster_xline(struct Client *source_p, int temp_time, |
8bbeb278 | 84 | const char *name, const char *reason); |
212380e3 AC |
85 | |
86 | static void handle_remote_xline(struct Client *source_p, int temp_time, | |
87 | const char *name, const char *reason); | |
88 | static void handle_remote_unxline(struct Client *source_p, const char *name); | |
89 | ||
3cbbfb25 JT |
90 | static void remove_xline(struct Client *source_p, const char *name, |
91 | int propagated); | |
212380e3 AC |
92 | |
93 | ||
94 | /* m_xline() | |
95 | * | |
96 | * parv[1] - thing to xline | |
97 | * parv[2] - optional type/reason | |
98 | * parv[3] - reason | |
99 | */ | |
100 | static int | |
428ca87b | 101 | mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
102 | { |
103 | struct ConfItem *aconf; | |
104 | const char *name; | |
105 | const char *reason; | |
106 | const char *target_server = NULL; | |
107 | int temp_time; | |
108 | int loc = 1; | |
3cbbfb25 | 109 | int propagated = ConfigFileEntry.use_propagated_bans; |
212380e3 AC |
110 | |
111 | if(!IsOperXline(source_p)) | |
112 | { | |
8bbeb278 | 113 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline"); |
212380e3 AC |
114 | return 0; |
115 | } | |
116 | ||
117 | if((temp_time = valid_temp_time(parv[loc])) >= 0) | |
118 | loc++; | |
119 | /* we just set temp_time to -1! */ | |
120 | else | |
121 | temp_time = 0; | |
122 | ||
123 | name = parv[loc]; | |
124 | loc++; | |
125 | ||
126 | /* XLINE <gecos> ON <server> :<reason> */ | |
8bbeb278 | 127 | if(parc >= loc + 2 && !irccmp(parv[loc], "ON")) |
212380e3 AC |
128 | { |
129 | if(!IsOperRemoteBan(source_p)) | |
130 | { | |
131 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 132 | me.name, source_p->name, "remoteban"); |
212380e3 AC |
133 | return 0; |
134 | } | |
135 | ||
8bbeb278 | 136 | target_server = parv[loc + 1]; |
212380e3 AC |
137 | loc += 2; |
138 | } | |
139 | ||
140 | if(parc <= loc || EmptyString(parv[loc])) | |
141 | { | |
142 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), | |
8bbeb278 | 143 | me.name, source_p->name, "XLINE"); |
212380e3 AC |
144 | return 0; |
145 | } | |
146 | ||
147 | reason = parv[loc]; | |
148 | ||
149 | if(target_server != NULL) | |
150 | { | |
8bbeb278 | 151 | propagate_xline(source_p, target_server, temp_time, name, "2", reason); |
212380e3 AC |
152 | |
153 | if(!match(target_server, me.name)) | |
154 | return 0; | |
3cbbfb25 JT |
155 | |
156 | /* Set as local-only. */ | |
157 | propagated = 0; | |
212380e3 | 158 | } |
3cbbfb25 | 159 | else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0) |
8bbeb278 | 160 | cluster_xline(source_p, temp_time, name, reason); |
212380e3 | 161 | |
8bbeb278 | 162 | if((aconf = find_xline_mask(name)) != NULL) |
212380e3 AC |
163 | { |
164 | sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", | |
23959371 | 165 | me.name, source_p->name, name, aconf->host, aconf->passwd); |
212380e3 AC |
166 | return 0; |
167 | } | |
168 | ||
8bbeb278 | 169 | if(!valid_xline(source_p, name, reason)) |
212380e3 AC |
170 | return 0; |
171 | ||
3cbbfb25 JT |
172 | if(propagated && temp_time == 0) |
173 | { | |
174 | sendto_one_notice(source_p, ":Cannot set a permanent global ban"); | |
175 | return 0; | |
176 | } | |
177 | ||
178 | apply_xline(source_p, name, reason, temp_time, propagated); | |
212380e3 AC |
179 | |
180 | return 0; | |
181 | } | |
182 | ||
183 | /* ms_xline() | |
184 | * | |
185 | * handles a remote xline | |
186 | */ | |
187 | static int | |
428ca87b | 188 | ms_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 189 | { |
8bbeb278 AC |
190 | /* parv[0] parv[1] parv[2] parv[3] parv[4] |
191 | * oper target serv xline type reason | |
212380e3 AC |
192 | */ |
193 | propagate_xline(source_p, parv[1], 0, parv[2], parv[3], parv[4]); | |
194 | ||
195 | if(!IsPerson(source_p)) | |
196 | return 0; | |
197 | ||
198 | /* destined for me? */ | |
199 | if(!match(parv[1], me.name)) | |
200 | return 0; | |
201 | ||
202 | handle_remote_xline(source_p, 0, parv[2], parv[4]); | |
203 | return 0; | |
204 | } | |
205 | ||
206 | static int | |
428ca87b | 207 | me_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
208 | { |
209 | /* time name type :reason */ | |
210 | if(!IsPerson(source_p)) | |
211 | return 0; | |
212 | ||
213 | handle_remote_xline(source_p, atoi(parv[1]), parv[2], parv[4]); | |
214 | return 0; | |
215 | } | |
216 | ||
217 | static void | |
8bbeb278 | 218 | handle_remote_xline(struct Client *source_p, int temp_time, const char *name, const char *reason) |
212380e3 AC |
219 | { |
220 | struct ConfItem *aconf; | |
221 | ||
222 | if(!find_shared_conf(source_p->username, source_p->host, | |
8bbeb278 AC |
223 | source_p->servptr->name, |
224 | (temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE)) | |
212380e3 AC |
225 | return; |
226 | ||
8bbeb278 | 227 | if(!valid_xline(source_p, name, reason)) |
212380e3 AC |
228 | return; |
229 | ||
230 | /* already xlined */ | |
0fdb2570 | 231 | if((aconf = find_xline_mask(name)) != NULL) |
212380e3 | 232 | { |
23959371 | 233 | sendto_one_notice(source_p, ":[%s] already X-Lined by [%s] - %s", name, aconf->host, |
8bbeb278 | 234 | aconf->passwd); |
212380e3 AC |
235 | return; |
236 | } | |
237 | ||
3cbbfb25 | 238 | apply_xline(source_p, name, reason, temp_time, 0); |
212380e3 AC |
239 | } |
240 | ||
241 | /* valid_xline() | |
242 | * | |
8bbeb278 | 243 | * inputs - client xlining, gecos, reason and whether to warn |
212380e3 AC |
244 | * outputs - |
245 | * side effects - checks the xline for validity, erroring if needed | |
246 | */ | |
247 | static int | |
8bbeb278 | 248 | valid_xline(struct Client *source_p, const char *gecos, const char *reason) |
212380e3 AC |
249 | { |
250 | if(EmptyString(reason)) | |
251 | { | |
252 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), | |
8bbeb278 | 253 | get_id(&me, source_p), get_id(source_p, source_p), "XLINE"); |
cc169c94 JT |
254 | return 0; |
255 | } | |
256 | ||
212380e3 AC |
257 | if(!valid_wild_card_simple(gecos)) |
258 | { | |
259 | sendto_one_notice(source_p, | |
260 | ":Please include at least %d non-wildcard " | |
261 | "characters with the xline", | |
262 | ConfigFileEntry.min_nonwildcard_simple); | |
263 | return 0; | |
264 | } | |
265 | ||
266 | return 1; | |
267 | } | |
268 | ||
269 | void | |
3cbbfb25 | 270 | apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time, int propagated) |
212380e3 AC |
271 | { |
272 | struct ConfItem *aconf; | |
273 | ||
274 | aconf = make_conf(); | |
275 | aconf->status = CONF_XLINE; | |
b52c2949 | 276 | aconf->created = rb_current_time(); |
4418166c | 277 | aconf->host = rb_strdup(name); |
8bbeb278 | 278 | aconf->passwd = rb_strdup(reason); |
23959371 | 279 | collapse(aconf->host); |
212380e3 | 280 | |
27f616dd JT |
281 | aconf->info.oper = operhash_add(get_oper_name(source_p)); |
282 | ||
3cbbfb25 JT |
283 | if(propagated) |
284 | { | |
285 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
286 | aconf->hold = rb_current_time() + temp_time; | |
287 | aconf->lifetime = aconf->hold; | |
288 | ||
289 | replace_old_ban(aconf); | |
290 | rb_dlinkAddAlloc(aconf, &prop_bans); | |
291 | ||
292 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
293 | "%s added global %d min. X-Line for [%s] [%s]", | |
294 | get_oper_name(source_p), temp_time / 60, | |
295 | aconf->host, reason); | |
296 | ilog(L_KLINE, "X %s %d %s %s", | |
297 | get_oper_name(source_p), temp_time / 60, name, reason); | |
298 | sendto_one_notice(source_p, ":Added global %d min. X-Line [%s]", | |
299 | temp_time / 60, aconf->host); | |
300 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
301 | ":%s BAN X * %s %lu %d %d * :%s", | |
302 | source_p->id, aconf->host, | |
303 | (unsigned long)aconf->created, | |
304 | (int)(aconf->hold - aconf->created), | |
305 | (int)(aconf->lifetime - aconf->created), | |
306 | reason); | |
307 | } | |
308 | else if(temp_time > 0) | |
212380e3 | 309 | { |
8bbeb278 | 310 | aconf->hold = rb_current_time() + temp_time; |
212380e3 | 311 | |
8bbeb278 AC |
312 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
313 | "%s added temporary %d min. X-Line for [%s] [%s]", | |
314 | get_oper_name(source_p), temp_time / 60, | |
23959371 | 315 | aconf->host, reason); |
8bbeb278 AC |
316 | ilog(L_KLINE, "X %s %d %s %s", |
317 | get_oper_name(source_p), temp_time / 60, name, reason); | |
318 | sendto_one_notice(source_p, ":Added temporary %d min. X-Line [%s]", | |
23959371 | 319 | temp_time / 60, aconf->host); |
8bbeb278 AC |
320 | } |
321 | else | |
212380e3 | 322 | { |
8bbeb278 | 323 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s added X-Line for [%s] [%s]", |
23959371 | 324 | get_oper_name(source_p), aconf->host, aconf->passwd); |
8bbeb278 | 325 | sendto_one_notice(source_p, ":Added X-Line for [%s] [%s]", |
23959371 | 326 | aconf->host, aconf->passwd); |
8bbeb278 | 327 | |
23959371 | 328 | bandb_add(BANDB_XLINE, source_p, aconf->host, NULL, aconf->passwd, NULL, 0); |
f36d4fdd | 329 | ilog(L_KLINE, "X %s 0 %s %s", get_oper_name(source_p), name, aconf->passwd); |
212380e3 | 330 | } |
8bbeb278 AC |
331 | |
332 | rb_dlinkAddAlloc(aconf, &xline_conf_list); | |
333 | check_xlines(); | |
212380e3 AC |
334 | } |
335 | ||
8bbeb278 | 336 | static void |
212380e3 | 337 | propagate_xline(struct Client *source_p, const char *target, |
8bbeb278 | 338 | int temp_time, const char *name, const char *type, const char *reason) |
212380e3 AC |
339 | { |
340 | if(!temp_time) | |
341 | { | |
342 | sendto_match_servs(source_p, target, CAP_CLUSTER, NOCAPS, | |
8bbeb278 | 343 | "XLINE %s %s %s :%s", target, name, type, reason); |
212380e3 | 344 | sendto_match_servs(source_p, target, CAP_ENCAP, CAP_CLUSTER, |
8bbeb278 | 345 | "ENCAP %s XLINE %d %s 2 :%s", target, temp_time, name, reason); |
212380e3 AC |
346 | } |
347 | else | |
348 | sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS, | |
8bbeb278 AC |
349 | "ENCAP %s XLINE %d %s %s :%s", |
350 | target, temp_time, name, type, reason); | |
212380e3 | 351 | } |
8bbeb278 | 352 | |
212380e3 | 353 | static void |
8bbeb278 | 354 | cluster_xline(struct Client *source_p, int temp_time, const char *name, const char *reason) |
212380e3 AC |
355 | { |
356 | struct remote_conf *shared_p; | |
5b96d9a6 | 357 | rb_dlink_node *ptr; |
212380e3 | 358 | |
5b96d9a6 | 359 | RB_DLINK_FOREACH(ptr, cluster_conf_list.head) |
212380e3 AC |
360 | { |
361 | shared_p = ptr->data; | |
362 | ||
363 | /* old protocol cant handle temps, and we dont really want | |
364 | * to convert them to perm.. --fl | |
365 | */ | |
366 | if(!temp_time) | |
367 | { | |
368 | if(!(shared_p->flags & SHARED_PXLINE)) | |
369 | continue; | |
370 | ||
371 | sendto_match_servs(source_p, shared_p->server, CAP_CLUSTER, NOCAPS, | |
8bbeb278 | 372 | "XLINE %s %s 2 :%s", shared_p->server, name, reason); |
212380e3 | 373 | sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, CAP_CLUSTER, |
8bbeb278 AC |
374 | "ENCAP %s XLINE 0 %s 2 :%s", |
375 | shared_p->server, name, reason); | |
212380e3 AC |
376 | } |
377 | else if(shared_p->flags & SHARED_TXLINE) | |
378 | sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, NOCAPS, | |
8bbeb278 AC |
379 | "ENCAP %s XLINE %d %s 2 :%s", |
380 | shared_p->server, temp_time, name, reason); | |
212380e3 AC |
381 | } |
382 | } | |
383 | ||
384 | /* mo_unxline() | |
385 | * | |
386 | * parv[1] - thing to unxline | |
387 | */ | |
388 | static int | |
428ca87b | 389 | mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 390 | { |
3cbbfb25 JT |
391 | int propagated = 1; |
392 | ||
212380e3 AC |
393 | if(!IsOperXline(source_p)) |
394 | { | |
8bbeb278 | 395 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline"); |
212380e3 AC |
396 | return 0; |
397 | } | |
398 | ||
399 | if(parc == 4 && !(irccmp(parv[2], "ON"))) | |
400 | { | |
401 | if(!IsOperRemoteBan(source_p)) | |
402 | { | |
403 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
8bbeb278 | 404 | me.name, source_p->name, "remoteban"); |
212380e3 AC |
405 | return 0; |
406 | } | |
407 | ||
8bbeb278 | 408 | propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]); |
212380e3 AC |
409 | |
410 | if(match(parv[3], me.name) == 0) | |
411 | return 0; | |
3cbbfb25 JT |
412 | |
413 | propagated = 0; | |
212380e3 | 414 | } |
3cbbfb25 | 415 | /* cluster{} moved to remove_xline */ |
212380e3 | 416 | |
3cbbfb25 | 417 | remove_xline(source_p, parv[1], propagated); |
212380e3 AC |
418 | |
419 | return 0; | |
420 | } | |
421 | ||
422 | /* ms_unxline() | |
423 | * | |
424 | * handles a remote unxline | |
425 | */ | |
426 | static int | |
428ca87b | 427 | ms_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 428 | { |
8bbeb278 AC |
429 | /* parv[0] parv[1] parv[2] |
430 | * oper target server gecos | |
212380e3 | 431 | */ |
8bbeb278 | 432 | propagate_generic(source_p, "UNXLINE", parv[1], CAP_CLUSTER, "%s", parv[2]); |
212380e3 AC |
433 | |
434 | if(!match(parv[1], me.name)) | |
435 | return 0; | |
436 | ||
437 | if(!IsPerson(source_p)) | |
438 | return 0; | |
439 | ||
440 | handle_remote_unxline(source_p, parv[2]); | |
441 | return 0; | |
442 | } | |
443 | ||
444 | static int | |
428ca87b | 445 | me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
446 | { |
447 | /* name */ | |
448 | if(!IsPerson(source_p)) | |
449 | return 0; | |
450 | ||
451 | handle_remote_unxline(source_p, parv[1]); | |
452 | return 0; | |
453 | } | |
454 | ||
455 | static void | |
456 | handle_remote_unxline(struct Client *source_p, const char *name) | |
457 | { | |
458 | if(!find_shared_conf(source_p->username, source_p->host, | |
8bbeb278 | 459 | source_p->servptr->name, SHARED_UNXLINE)) |
212380e3 AC |
460 | return; |
461 | ||
3cbbfb25 | 462 | remove_xline(source_p, name, 0); |
212380e3 AC |
463 | |
464 | return; | |
465 | } | |
466 | ||
60c96e64 | 467 | static void |
3cbbfb25 | 468 | remove_xline(struct Client *source_p, const char *name, int propagated) |
212380e3 AC |
469 | { |
470 | struct ConfItem *aconf; | |
5b96d9a6 | 471 | rb_dlink_node *ptr; |
483987a4 | 472 | time_t now; |
212380e3 | 473 | |
5b96d9a6 | 474 | RB_DLINK_FOREACH(ptr, xline_conf_list.head) |
212380e3 AC |
475 | { |
476 | aconf = ptr->data; | |
477 | ||
23959371 | 478 | if(!irccmp(aconf->host, name)) |
212380e3 | 479 | { |
3cbbfb25 JT |
480 | if(aconf->lifetime) |
481 | { | |
482 | if(!propagated) | |
483 | { | |
484 | sendto_one_notice(source_p, ":Cannot remove global X-Line %s on specific servers", name); | |
485 | return; | |
486 | } | |
487 | ptr = rb_dlinkFind(aconf, &prop_bans); | |
488 | if(ptr == NULL) | |
489 | return; | |
490 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", name); | |
491 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
492 | "%s has removed the global X-Line for: [%s]", | |
493 | get_oper_name(source_p), name); | |
494 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name); | |
483987a4 JT |
495 | now = rb_current_time(); |
496 | if(aconf->created < now) | |
497 | aconf->created = now; | |
3cbbfb25 JT |
498 | else |
499 | aconf->created++; | |
500 | aconf->hold = aconf->created; | |
501 | operhash_delete(aconf->info.oper); | |
502 | aconf->info.oper = operhash_add(get_oper_name(source_p)); | |
503 | aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY; | |
504 | sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS, | |
505 | ":%s BAN X * %s %lu %d %d * :*", | |
506 | source_p->id, aconf->host, | |
507 | (unsigned long)aconf->created, | |
508 | 0, | |
509 | (int)(aconf->lifetime - aconf->created)); | |
510 | remove_reject_mask(aconf->host, NULL); | |
483987a4 | 511 | deactivate_conf(aconf, ptr, now); |
3cbbfb25 JT |
512 | return; |
513 | } | |
1b5d7c2e | 514 | else if(propagated && rb_dlink_list_length(&cluster_conf_list)) |
3cbbfb25 | 515 | cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name); |
8bbeb278 | 516 | if(!aconf->hold) |
5408b484 | 517 | { |
8bbeb278 AC |
518 | bandb_del(BANDB_XLINE, aconf->host, NULL); |
519 | ||
520 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", aconf->host); | |
521 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
522 | "%s has removed the X-Line for: [%s]", | |
523 | get_oper_name(source_p), aconf->host); | |
524 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), aconf->host); | |
5408b484 JT |
525 | } |
526 | else | |
527 | { | |
8bbeb278 | 528 | sendto_one_notice(source_p, ":X-Line for [%s] is removed", name); |
5408b484 | 529 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
8bbeb278 AC |
530 | "%s has removed the temporary X-Line for: [%s]", |
531 | get_oper_name(source_p), name); | |
532 | ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name); | |
5408b484 | 533 | } |
8bbeb278 | 534 | |
23959371 | 535 | remove_reject_mask(aconf->host, NULL); |
212380e3 | 536 | free_conf(aconf); |
555ac41f | 537 | rb_dlinkDestroy(ptr, &xline_conf_list); |
60c96e64 | 538 | return; |
212380e3 AC |
539 | } |
540 | } | |
541 | ||
1b5d7c2e | 542 | if(propagated && rb_dlink_list_length(&cluster_conf_list)) |
3cbbfb25 JT |
543 | cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name); |
544 | ||
8bbeb278 | 545 | sendto_one_notice(source_p, ":No X-Line for %s", name); |
5408b484 | 546 | |
60c96e64 | 547 | return; |
212380e3 | 548 | } |