1 |
adx |
30 |
/* |
2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
|
|
* m_kline.c: Bans a user. |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
|
* USA |
21 |
|
|
* |
22 |
knight |
31 |
* $Id$ |
23 |
adx |
30 |
*/ |
24 |
|
|
|
25 |
|
|
#include "stdinc.h" |
26 |
michael |
1011 |
#include "list.h" |
27 |
adx |
30 |
#include "channel.h" |
28 |
|
|
#include "client.h" |
29 |
|
|
#include "irc_string.h" |
30 |
|
|
#include "sprintf_irc.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "hostmask.h" |
33 |
|
|
#include "numeric.h" |
34 |
|
|
#include "fdlist.h" |
35 |
|
|
#include "s_bsd.h" |
36 |
michael |
1309 |
#include "conf.h" |
37 |
|
|
#include "log.h" |
38 |
adx |
30 |
#include "s_misc.h" |
39 |
|
|
#include "send.h" |
40 |
|
|
#include "hash.h" |
41 |
|
|
#include "s_serv.h" |
42 |
|
|
#include "s_gline.h" |
43 |
|
|
#include "parse.h" |
44 |
|
|
#include "modules.h" |
45 |
|
|
|
46 |
michael |
611 |
|
47 |
michael |
1058 |
static int already_placed_kline(struct Client *, const char *, const char *, int); |
48 |
|
|
static void apply_kline(struct Client *, struct ConfItem *, const char *, time_t); |
49 |
|
|
static void apply_tkline(struct Client *, struct ConfItem *, int); |
50 |
|
|
|
51 |
|
|
static char buffer[IRCD_BUFSIZE]; |
52 |
adx |
30 |
static int remove_tkline_match(const char *, const char *); |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
/* mo_kline() |
56 |
|
|
* |
57 |
|
|
* inputs - pointer to server |
58 |
|
|
* - pointer to client |
59 |
|
|
* - parameter count |
60 |
|
|
* - parameter list |
61 |
|
|
* output - |
62 |
|
|
* side effects - k line is added |
63 |
|
|
*/ |
64 |
|
|
static void |
65 |
|
|
mo_kline(struct Client *client_p, struct Client *source_p, |
66 |
michael |
1298 |
int parc, char *parv[]) |
67 |
adx |
30 |
{ |
68 |
|
|
char *reason = NULL; |
69 |
|
|
char *oper_reason; |
70 |
|
|
char *user = NULL; |
71 |
|
|
char *host = NULL; |
72 |
|
|
const char *current_date; |
73 |
|
|
char *target_server = NULL; |
74 |
|
|
struct ConfItem *conf; |
75 |
|
|
struct AccessItem *aconf; |
76 |
|
|
time_t tkline_time = 0; |
77 |
|
|
time_t cur_time; |
78 |
|
|
|
79 |
michael |
1219 |
if (!HasOFlag(source_p, OPER_FLAG_K)) |
80 |
adx |
30 |
{ |
81 |
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
82 |
|
|
me.name, source_p->name, "kline"); |
83 |
|
|
return; |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
if (parse_aline("KLINE", source_p, parc, parv, |
87 |
|
|
AWILD, &user, &host, &tkline_time, &target_server, &reason) < 0) |
88 |
|
|
return; |
89 |
|
|
|
90 |
|
|
if (target_server != NULL) |
91 |
|
|
{ |
92 |
|
|
if (HasID(source_p)) |
93 |
|
|
{ |
94 |
michael |
885 |
sendto_server(NULL, NULL, CAP_KLN|CAP_TS6, NOCAPS, |
95 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
96 |
|
|
source_p->id, target_server, (unsigned long)tkline_time, |
97 |
|
|
user, host, reason); |
98 |
michael |
885 |
sendto_server(NULL, NULL, CAP_KLN, CAP_TS6, |
99 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
100 |
|
|
source_p->name, target_server, (unsigned long)tkline_time, |
101 |
|
|
user, host, reason); |
102 |
|
|
} |
103 |
|
|
else |
104 |
michael |
885 |
sendto_server(NULL, NULL, CAP_KLN, NOCAPS, |
105 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
106 |
|
|
source_p->name, target_server, (unsigned long)tkline_time, |
107 |
|
|
user, host, reason); |
108 |
|
|
|
109 |
|
|
/* Allow ON to apply local kline as well if it matches */ |
110 |
|
|
if (!match(target_server, me.name)) |
111 |
|
|
return; |
112 |
|
|
} |
113 |
|
|
else |
114 |
|
|
cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE, |
115 |
michael |
1058 |
"%d %s %s :%s", tkline_time, user, host, reason); |
116 |
adx |
30 |
|
117 |
michael |
1243 |
if (already_placed_kline(source_p, user, host, 1)) |
118 |
adx |
30 |
return; |
119 |
|
|
|
120 |
|
|
/* Look for an oper reason */ |
121 |
|
|
if ((oper_reason = strchr(reason, '|')) != NULL) |
122 |
|
|
*oper_reason++ = '\0'; |
123 |
|
|
|
124 |
|
|
cur_time = CurrentTime; |
125 |
|
|
current_date = smalldate(cur_time); |
126 |
|
|
conf = make_conf_item(KLINE_TYPE); |
127 |
|
|
aconf = map_to_conf(conf); |
128 |
|
|
|
129 |
|
|
DupString(aconf->host, host); |
130 |
|
|
DupString(aconf->user, user); |
131 |
|
|
|
132 |
|
|
if (tkline_time != 0) |
133 |
|
|
{ |
134 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
135 |
|
|
(int)(tkline_time/60), reason, current_date); |
136 |
adx |
30 |
DupString(aconf->reason, buffer); |
137 |
|
|
|
138 |
|
|
if (oper_reason != NULL) |
139 |
|
|
DupString(aconf->oper_reason, oper_reason); |
140 |
|
|
apply_tkline(source_p, conf, tkline_time); |
141 |
|
|
} |
142 |
|
|
else |
143 |
|
|
{ |
144 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); |
145 |
adx |
30 |
DupString(aconf->reason, buffer); |
146 |
|
|
|
147 |
|
|
if (oper_reason != NULL) |
148 |
|
|
DupString(aconf->oper_reason, oper_reason); |
149 |
|
|
apply_kline(source_p, conf, current_date, cur_time); |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
/* me_kline - handle remote kline. no propagation */ |
154 |
|
|
static void |
155 |
|
|
me_kline(struct Client *client_p, struct Client *source_p, |
156 |
|
|
int parc, char *parv[]) |
157 |
|
|
{ |
158 |
|
|
struct ConfItem *conf=NULL; |
159 |
|
|
struct AccessItem *aconf=NULL; |
160 |
|
|
int tkline_time; |
161 |
|
|
const char* current_date; |
162 |
|
|
time_t cur_time; |
163 |
|
|
char *kuser, *khost, *kreason, *oper_reason; |
164 |
|
|
|
165 |
michael |
352 |
if (parc != 6 || EmptyString(parv[5])) |
166 |
adx |
30 |
return; |
167 |
|
|
|
168 |
|
|
if (!match(parv[1], me.name)) |
169 |
|
|
return; |
170 |
|
|
|
171 |
|
|
tkline_time = valid_tkline(parv[2], TK_SECONDS); |
172 |
|
|
kuser = parv[3]; |
173 |
|
|
khost = parv[4]; |
174 |
|
|
kreason = parv[5]; |
175 |
|
|
|
176 |
|
|
if ((oper_reason = strchr(kreason, '|')) != NULL) |
177 |
|
|
*oper_reason++ = '\0'; |
178 |
|
|
|
179 |
|
|
cur_time = CurrentTime; |
180 |
|
|
current_date = smalldate(cur_time); |
181 |
|
|
|
182 |
michael |
1275 |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name, |
183 |
adx |
30 |
source_p->username, source_p->host, |
184 |
|
|
SHARED_KLINE)) |
185 |
|
|
{ |
186 |
|
|
if (!IsClient(source_p) || |
187 |
michael |
1243 |
already_placed_kline(source_p, kuser, khost, 1)) |
188 |
adx |
30 |
return; |
189 |
|
|
|
190 |
|
|
conf = make_conf_item(KLINE_TYPE); |
191 |
|
|
aconf = map_to_conf(conf); |
192 |
|
|
DupString(aconf->host, khost); |
193 |
|
|
DupString(aconf->user, kuser); |
194 |
|
|
|
195 |
|
|
if (tkline_time != 0) |
196 |
|
|
{ |
197 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
198 |
|
|
(int)(tkline_time/60), kreason, current_date); |
199 |
adx |
30 |
DupString(aconf->reason, buffer); |
200 |
|
|
|
201 |
|
|
if (oper_reason != NULL) |
202 |
|
|
DupString(aconf->oper_reason, oper_reason); |
203 |
|
|
apply_tkline(source_p, conf, tkline_time); |
204 |
|
|
} |
205 |
|
|
else |
206 |
|
|
{ |
207 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date); |
208 |
adx |
30 |
DupString(aconf->reason, buffer); |
209 |
|
|
|
210 |
|
|
if (oper_reason != NULL) |
211 |
|
|
DupString(aconf->oper_reason, oper_reason); |
212 |
|
|
apply_kline(source_p, conf, current_date, cur_time); |
213 |
|
|
} |
214 |
|
|
} |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
static void |
218 |
|
|
ms_kline(struct Client *client_p, struct Client *source_p, |
219 |
michael |
1058 |
int parc, char *parv[]) |
220 |
adx |
30 |
{ |
221 |
michael |
352 |
if (parc != 6 || EmptyString(parv[5])) |
222 |
adx |
30 |
return; |
223 |
|
|
|
224 |
|
|
/* parv[0] parv[1] parv[2] parv[3] parv[4] parv[5] */ |
225 |
|
|
/* oper target_server tkline_time user host reason */ |
226 |
|
|
sendto_match_servs(source_p, parv[1], CAP_KLN, |
227 |
|
|
"KLINE %s %s %s %s :%s", |
228 |
|
|
parv[1], parv[2], parv[3], parv[4], parv[5]); |
229 |
|
|
|
230 |
|
|
me_kline(client_p, source_p, parc, parv); |
231 |
|
|
} |
232 |
|
|
|
233 |
|
|
/* apply_kline() |
234 |
|
|
* |
235 |
|
|
* inputs - |
236 |
|
|
* output - NONE |
237 |
|
|
* side effects - kline as given, is added to the hashtable |
238 |
|
|
* and conf file |
239 |
|
|
*/ |
240 |
|
|
static void |
241 |
|
|
apply_kline(struct Client *source_p, struct ConfItem *conf, |
242 |
michael |
1058 |
const char *current_date, time_t cur_time) |
243 |
adx |
30 |
{ |
244 |
|
|
struct AccessItem *aconf = map_to_conf(conf); |
245 |
|
|
|
246 |
michael |
1369 |
add_conf_by_address(CONF_KLINE, aconf); |
247 |
adx |
30 |
write_conf_line(source_p, conf, current_date, cur_time); |
248 |
|
|
/* Now, activate kline against current online clients */ |
249 |
|
|
rehashed_klines = 1; |
250 |
|
|
} |
251 |
|
|
|
252 |
|
|
/* apply_tkline() |
253 |
|
|
* |
254 |
|
|
* inputs - |
255 |
|
|
* output - NONE |
256 |
|
|
* side effects - tkline as given is placed |
257 |
|
|
*/ |
258 |
|
|
static void |
259 |
|
|
apply_tkline(struct Client *source_p, struct ConfItem *conf, |
260 |
|
|
int tkline_time) |
261 |
|
|
{ |
262 |
|
|
struct AccessItem *aconf; |
263 |
|
|
|
264 |
|
|
aconf = (struct AccessItem *)map_to_conf(conf); |
265 |
|
|
aconf->hold = CurrentTime + tkline_time; |
266 |
michael |
1369 |
SetConfTemporary(aconf); |
267 |
|
|
add_conf_by_address(CONF_KLINE, aconf); |
268 |
|
|
|
269 |
adx |
30 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
270 |
|
|
"%s added temporary %d min. K-Line for [%s@%s] [%s]", |
271 |
|
|
get_oper_name(source_p), tkline_time/60, |
272 |
|
|
aconf->user, aconf->host, |
273 |
|
|
aconf->reason); |
274 |
|
|
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]", |
275 |
|
|
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
276 |
|
|
source_p->name, tkline_time/60, aconf->user, aconf->host); |
277 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]", |
278 |
adx |
30 |
source_p->name, tkline_time/60, |
279 |
|
|
aconf->user, aconf->host, aconf->reason); |
280 |
michael |
1247 |
|
281 |
adx |
30 |
rehashed_klines = 1; |
282 |
|
|
} |
283 |
|
|
|
284 |
|
|
/* already_placed_kline() |
285 |
|
|
* inputs - user to complain to, username & host to check for |
286 |
|
|
* outputs - returns 1 on existing K-line, 0 if doesn't exist |
287 |
|
|
* side effects - notifies source_p if the K-line already exists |
288 |
|
|
*/ |
289 |
|
|
/* |
290 |
|
|
* Note: This currently works if the new K-line is a special case of an |
291 |
|
|
* existing K-line, but not the other way round. To do that we would |
292 |
|
|
* have to walk the hash and check every existing K-line. -A1kmm. |
293 |
|
|
*/ |
294 |
|
|
static int |
295 |
|
|
already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int warn) |
296 |
|
|
{ |
297 |
|
|
const char *reason; |
298 |
|
|
struct irc_ssaddr iphost, *piphost; |
299 |
|
|
struct AccessItem *aconf; |
300 |
|
|
int t; |
301 |
|
|
|
302 |
|
|
if ((t = parse_netmask(lhost, &iphost, &t)) != HM_HOST) |
303 |
|
|
{ |
304 |
|
|
#ifdef IPV6 |
305 |
|
|
if (t == HM_IPV6) |
306 |
|
|
t = AF_INET6; |
307 |
|
|
else |
308 |
|
|
#endif |
309 |
|
|
t = AF_INET; |
310 |
|
|
piphost = &iphost; |
311 |
|
|
} |
312 |
|
|
else |
313 |
|
|
{ |
314 |
|
|
t = 0; |
315 |
|
|
piphost = NULL; |
316 |
|
|
} |
317 |
|
|
|
318 |
michael |
1371 |
if ((aconf = find_conf_by_address(lhost, piphost, CONF_KLINE, t, luser, NULL, 0))) |
319 |
adx |
30 |
{ |
320 |
|
|
if (warn) |
321 |
|
|
{ |
322 |
|
|
reason = aconf->reason ? aconf->reason : "No reason"; |
323 |
|
|
sendto_one(source_p, |
324 |
|
|
":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s", |
325 |
|
|
me.name, source_p->name, luser, lhost, aconf->user, |
326 |
|
|
aconf->host, reason); |
327 |
|
|
} |
328 |
michael |
1298 |
|
329 |
|
|
return 1; |
330 |
adx |
30 |
} |
331 |
|
|
|
332 |
michael |
1298 |
return 0; |
333 |
adx |
30 |
} |
334 |
|
|
|
335 |
|
|
/* |
336 |
|
|
** mo_unkline |
337 |
|
|
** Added Aug 31, 1997 |
338 |
|
|
** common (Keith Fralick) fralick@gate.net |
339 |
|
|
** |
340 |
|
|
** parv[0] = sender |
341 |
|
|
** parv[1] = address to remove |
342 |
|
|
* |
343 |
|
|
* |
344 |
|
|
*/ |
345 |
|
|
static void |
346 |
|
|
mo_unkline(struct Client *client_p,struct Client *source_p, |
347 |
|
|
int parc, char *parv[]) |
348 |
|
|
{ |
349 |
|
|
char *target_server = NULL; |
350 |
|
|
char *user, *host; |
351 |
|
|
|
352 |
michael |
1219 |
if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) |
353 |
adx |
30 |
{ |
354 |
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
355 |
|
|
me.name, source_p->name, "unkline"); |
356 |
|
|
return; |
357 |
|
|
} |
358 |
|
|
|
359 |
|
|
if (parc < 2 || EmptyString(parv[1])) |
360 |
|
|
{ |
361 |
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
362 |
|
|
me.name, source_p->name, "UNKLINE"); |
363 |
|
|
return; |
364 |
|
|
} |
365 |
|
|
|
366 |
|
|
if (parse_aline("UNKLINE", source_p, parc, parv, 0, &user, |
367 |
|
|
&host, NULL, &target_server, NULL) < 0) |
368 |
|
|
return; |
369 |
|
|
|
370 |
|
|
if (target_server != NULL) |
371 |
|
|
{ |
372 |
|
|
sendto_match_servs(source_p, target_server, CAP_UNKLN, |
373 |
|
|
"UNKLINE %s %s %s", |
374 |
|
|
target_server, user, host); |
375 |
|
|
|
376 |
|
|
/* Allow ON to apply local unkline as well if it matches */ |
377 |
|
|
if (!match(target_server, me.name)) |
378 |
|
|
return; |
379 |
|
|
} |
380 |
|
|
else |
381 |
|
|
cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE, |
382 |
michael |
1058 |
"%s %s", user, host); |
383 |
adx |
30 |
|
384 |
|
|
if (remove_tkline_match(host, user)) |
385 |
|
|
{ |
386 |
|
|
sendto_one(source_p, |
387 |
|
|
":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines", |
388 |
|
|
me.name, source_p->name, user, host); |
389 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
390 |
|
|
"%s has removed the temporary K-Line for: [%s@%s]", |
391 |
|
|
get_oper_name(source_p), user, host); |
392 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]", |
393 |
adx |
30 |
source_p->name, user, host); |
394 |
|
|
return; |
395 |
|
|
} |
396 |
|
|
|
397 |
|
|
if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0) |
398 |
|
|
{ |
399 |
|
|
sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed", |
400 |
michael |
1058 |
me.name, source_p->name, user,host); |
401 |
adx |
30 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
402 |
michael |
1058 |
"%s has removed the K-Line for: [%s@%s]", |
403 |
|
|
get_oper_name(source_p), user, host); |
404 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]", |
405 |
michael |
1058 |
source_p->name, user, host); |
406 |
adx |
30 |
} |
407 |
|
|
else |
408 |
|
|
sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found", |
409 |
|
|
me.name, source_p->name, user, host); |
410 |
|
|
} |
411 |
|
|
|
412 |
|
|
/* me_unkline() |
413 |
|
|
* |
414 |
|
|
* inputs - server |
415 |
|
|
* - client |
416 |
|
|
* - parc |
417 |
|
|
* - parv |
418 |
|
|
* outputs - none |
419 |
|
|
* side effects - if server is authorized, kline is removed |
420 |
|
|
* does not propagate message |
421 |
|
|
*/ |
422 |
|
|
static void |
423 |
|
|
me_unkline(struct Client *client_p, struct Client *source_p, |
424 |
|
|
int parc, char *parv[]) |
425 |
|
|
{ |
426 |
|
|
const char *kuser, *khost; |
427 |
|
|
|
428 |
|
|
if (parc != 4) |
429 |
|
|
return; |
430 |
|
|
|
431 |
|
|
kuser = parv[2]; |
432 |
|
|
khost = parv[3]; |
433 |
|
|
|
434 |
|
|
if (!IsClient(source_p) || !match(parv[1], me.name)) |
435 |
|
|
return; |
436 |
|
|
|
437 |
michael |
1276 |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, |
438 |
adx |
30 |
source_p->servptr->name, |
439 |
|
|
source_p->username, source_p->host, |
440 |
|
|
SHARED_UNKLINE)) |
441 |
|
|
{ |
442 |
|
|
if (remove_tkline_match(khost, kuser)) |
443 |
|
|
{ |
444 |
|
|
sendto_one(source_p, |
445 |
|
|
":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines", |
446 |
|
|
me.name, source_p->name, kuser, khost); |
447 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
448 |
|
|
"%s has removed the temporary K-Line for: [%s@%s]", |
449 |
|
|
get_oper_name(source_p), kuser, khost); |
450 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]", |
451 |
adx |
30 |
source_p->name, kuser, khost); |
452 |
|
|
return; |
453 |
|
|
} |
454 |
|
|
|
455 |
|
|
if (remove_conf_line(KLINE_TYPE, source_p, kuser, khost) > 0) |
456 |
|
|
{ |
457 |
|
|
sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed", |
458 |
|
|
me.name, source_p->name, kuser, khost); |
459 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
460 |
|
|
"%s has removed the K-Line for: [%s@%s]", |
461 |
|
|
get_oper_name(source_p), kuser, khost); |
462 |
|
|
|
463 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]", |
464 |
adx |
30 |
source_p->name, kuser, khost); |
465 |
|
|
} |
466 |
|
|
else |
467 |
|
|
sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found", |
468 |
|
|
me.name, source_p->name, kuser, khost); |
469 |
|
|
} |
470 |
|
|
} |
471 |
|
|
|
472 |
|
|
/* ms_unkline - propagates and handles a remote unkline message */ |
473 |
|
|
static void |
474 |
|
|
ms_unkline(struct Client *client_p, struct Client *source_p, |
475 |
|
|
int parc, char *parv[]) |
476 |
|
|
{ |
477 |
|
|
if (parc != 4) |
478 |
|
|
return; |
479 |
|
|
|
480 |
|
|
sendto_match_servs(source_p, parv[1], CAP_UNKLN, |
481 |
|
|
"UNKLINE %s %s %s", |
482 |
|
|
parv[1], parv[2], parv[3]); |
483 |
|
|
|
484 |
|
|
me_unkline(client_p, source_p, parc, parv); |
485 |
|
|
} |
486 |
|
|
|
487 |
|
|
/* static int remove_tkline_match(const char *host, const char *user) |
488 |
|
|
* Input: A hostname, a username to unkline. |
489 |
|
|
* Output: returns YES on success, NO if no tkline removed. |
490 |
|
|
* Side effects: Any matching tklines are removed. |
491 |
|
|
*/ |
492 |
|
|
static int |
493 |
|
|
remove_tkline_match(const char *host, const char *user) |
494 |
|
|
{ |
495 |
michael |
1369 |
struct irc_ssaddr iphost, *piphost; |
496 |
|
|
struct AccessItem *aconf; |
497 |
|
|
int t; |
498 |
michael |
1298 |
|
499 |
michael |
1369 |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
500 |
adx |
30 |
{ |
501 |
|
|
#ifdef IPV6 |
502 |
michael |
1369 |
if (t == HM_IPV6) |
503 |
|
|
t = AF_INET6; |
504 |
|
|
else |
505 |
adx |
30 |
#endif |
506 |
michael |
1369 |
t = AF_INET; |
507 |
|
|
piphost = &iphost; |
508 |
adx |
30 |
} |
509 |
michael |
1369 |
else |
510 |
|
|
{ |
511 |
|
|
t = 0; |
512 |
|
|
piphost = NULL; |
513 |
|
|
} |
514 |
adx |
30 |
|
515 |
michael |
1371 |
if ((aconf = find_conf_by_address(host, piphost, CONF_KLINE, t, user, NULL, 0))) |
516 |
michael |
1369 |
{ |
517 |
|
|
if (IsConfTemporary(aconf)) |
518 |
|
|
{ |
519 |
|
|
delete_one_address_conf(host, aconf); |
520 |
|
|
return 1; |
521 |
|
|
} |
522 |
|
|
} |
523 |
|
|
|
524 |
michael |
1058 |
return 0; |
525 |
adx |
30 |
} |
526 |
michael |
1230 |
|
527 |
|
|
static struct Message kline_msgtab = { |
528 |
|
|
"KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
529 |
|
|
{m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore} |
530 |
|
|
}; |
531 |
|
|
|
532 |
|
|
static struct Message unkline_msgtab = { |
533 |
|
|
"UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
534 |
|
|
{m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore} |
535 |
|
|
}; |
536 |
|
|
|
537 |
|
|
static void |
538 |
|
|
module_init(void) |
539 |
|
|
{ |
540 |
|
|
mod_add_cmd(&kline_msgtab); |
541 |
|
|
mod_add_cmd(&unkline_msgtab); |
542 |
|
|
add_capability("KLN", CAP_KLN, 1); |
543 |
|
|
add_capability("UNKLN", CAP_UNKLN, 1); |
544 |
|
|
} |
545 |
|
|
|
546 |
|
|
static void |
547 |
|
|
module_exit(void) |
548 |
|
|
{ |
549 |
|
|
mod_del_cmd(&kline_msgtab); |
550 |
|
|
mod_del_cmd(&unkline_msgtab); |
551 |
|
|
delete_capability("UNKLN"); |
552 |
|
|
delete_capability("KLN"); |
553 |
|
|
} |
554 |
|
|
|
555 |
|
|
struct module module_entry = { |
556 |
|
|
.node = { NULL, NULL, NULL }, |
557 |
|
|
.name = NULL, |
558 |
|
|
.version = "$Revision$", |
559 |
|
|
.handle = NULL, |
560 |
|
|
.modinit = module_init, |
561 |
|
|
.modexit = module_exit, |
562 |
|
|
.flags = 0 |
563 |
|
|
}; |