| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
< |
#include "tools.h" |
| 26 |
> |
#include "list.h" |
| 27 |
|
#include "channel.h" |
| 28 |
|
#include "client.h" |
| 29 |
– |
#include "common.h" |
| 29 |
|
#include "irc_string.h" |
| 30 |
|
#include "sprintf_irc.h" |
| 31 |
|
#include "ircd.h" |
| 32 |
|
#include "hostmask.h" |
| 33 |
|
#include "numeric.h" |
| 35 |
– |
#include "list.h" |
| 34 |
|
#include "fdlist.h" |
| 35 |
|
#include "s_bsd.h" |
| 36 |
|
#include "s_conf.h" |
| 38 |
|
#include "s_misc.h" |
| 39 |
|
#include "send.h" |
| 40 |
|
#include "hash.h" |
| 43 |
– |
#include "handlers.h" |
| 41 |
|
#include "s_serv.h" |
| 45 |
– |
#include "msg.h" |
| 42 |
|
#include "s_gline.h" |
| 43 |
|
#include "parse.h" |
| 44 |
|
#include "modules.h" |
| 49 |
– |
#include "tools.h" |
| 50 |
– |
|
| 51 |
– |
static void me_kline(struct Client *, struct Client *, int, char **); |
| 52 |
– |
static void mo_kline(struct Client *, struct Client *, int, char **); |
| 53 |
– |
static void ms_kline(struct Client *, struct Client *, int, char **); |
| 54 |
– |
static void mo_dline(struct Client *, struct Client *, int, char **); |
| 55 |
– |
static void me_unkline(struct Client *, struct Client *, int, char **); |
| 56 |
– |
static void mo_unkline(struct Client *, struct Client *, int, char **); |
| 57 |
– |
static void ms_unkline(struct Client *, struct Client *, int, char **); |
| 58 |
– |
static void mo_undline(struct Client *, struct Client *, int, char **); |
| 59 |
– |
|
| 60 |
– |
#ifndef IPV6 |
| 61 |
– |
static char *make_cidr(char *dlhost, struct Client *); |
| 62 |
– |
#endif |
| 63 |
– |
|
| 64 |
– |
static int remove_tkline_match(const char *, const char *); |
| 65 |
– |
static int remove_tdline_match(const char *); |
| 66 |
– |
|
| 67 |
– |
struct Message kline_msgtab = { |
| 68 |
– |
"KLINE", 0, 0, 2, 0, MFLG_SLOW, 0, |
| 69 |
– |
{m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore} |
| 70 |
– |
}; |
| 71 |
– |
|
| 72 |
– |
struct Message dline_msgtab = { |
| 73 |
– |
"DLINE", 0, 0, 2, 0, MFLG_SLOW, 0, |
| 74 |
– |
{m_unregistered, m_not_oper, m_error, m_ignore, mo_dline, m_ignore} |
| 75 |
– |
}; |
| 76 |
– |
|
| 77 |
– |
struct Message unkline_msgtab = { |
| 78 |
– |
"UNKLINE", 0, 0, 2, 0, MFLG_SLOW, 0, |
| 79 |
– |
{m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore} |
| 80 |
– |
}; |
| 81 |
– |
|
| 82 |
– |
struct Message undline_msgtab = { |
| 83 |
– |
"UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0, |
| 84 |
– |
{m_unregistered, m_not_oper, m_error, m_ignore, mo_undline, m_ignore} |
| 85 |
– |
}; |
| 86 |
– |
|
| 87 |
– |
#ifndef STATIC_MODULES |
| 88 |
– |
void |
| 89 |
– |
_modinit(void) |
| 90 |
– |
{ |
| 91 |
– |
mod_add_cmd(&kline_msgtab); |
| 92 |
– |
mod_add_cmd(&unkline_msgtab); |
| 93 |
– |
mod_add_cmd(&dline_msgtab); |
| 94 |
– |
mod_add_cmd(&undline_msgtab); |
| 95 |
– |
add_capability("KLN", CAP_KLN, 1); |
| 96 |
– |
add_capability("UNKLN", CAP_UNKLN, 1); |
| 97 |
– |
} |
| 45 |
|
|
| 99 |
– |
void |
| 100 |
– |
_moddeinit(void) |
| 101 |
– |
{ |
| 102 |
– |
mod_del_cmd(&kline_msgtab); |
| 103 |
– |
mod_del_cmd(&unkline_msgtab); |
| 104 |
– |
mod_del_cmd(&dline_msgtab); |
| 105 |
– |
mod_del_cmd(&undline_msgtab); |
| 106 |
– |
delete_capability("UNKLN"); |
| 107 |
– |
delete_capability("KLN"); |
| 108 |
– |
} |
| 46 |
|
|
| 110 |
– |
const char *_version = "$Revision$"; |
| 111 |
– |
#endif |
| 112 |
– |
|
| 113 |
– |
/* Local function prototypes */ |
| 47 |
|
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 |
+ |
static int remove_tkline_match(const char *, const char *); |
| 53 |
+ |
|
| 54 |
|
|
| 55 |
|
/* mo_kline() |
| 56 |
|
* |
| 63 |
|
*/ |
| 64 |
|
static void |
| 65 |
|
mo_kline(struct Client *client_p, struct Client *source_p, |
| 66 |
< |
int parc, char **parv) |
| 66 |
> |
int parc, char **parv) |
| 67 |
|
{ |
| 68 |
|
char *reason = NULL; |
| 69 |
|
char *oper_reason; |
| 76 |
|
time_t tkline_time = 0; |
| 77 |
|
time_t cur_time; |
| 78 |
|
|
| 79 |
< |
if (!IsOperK(source_p)) |
| 79 |
> |
if (!HasOFlag(source_p, OPER_FLAG_K)) |
| 80 |
|
{ |
| 81 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 82 |
|
me.name, source_p->name, "kline"); |
| 91 |
|
{ |
| 92 |
|
if (HasID(source_p)) |
| 93 |
|
{ |
| 94 |
< |
sendto_server(NULL, source_p, NULL, CAP_KLN|CAP_TS6, NOCAPS, LL_ICLIENT, |
| 94 |
> |
sendto_server(NULL, NULL, CAP_KLN|CAP_TS6, NOCAPS, |
| 95 |
|
":%s KLINE %s %lu %s %s :%s", |
| 96 |
|
source_p->id, target_server, (unsigned long)tkline_time, |
| 97 |
|
user, host, reason); |
| 98 |
< |
sendto_server(NULL, source_p, NULL, CAP_KLN, CAP_TS6, LL_ICLIENT, |
| 98 |
> |
sendto_server(NULL, NULL, CAP_KLN, CAP_TS6, |
| 99 |
|
":%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 |
< |
sendto_server(NULL, source_p, NULL, CAP_KLN, NOCAPS, LL_ICLIENT, |
| 104 |
> |
sendto_server(NULL, NULL, CAP_KLN, NOCAPS, |
| 105 |
|
":%s KLINE %s %lu %s %s :%s", |
| 106 |
|
source_p->name, target_server, (unsigned long)tkline_time, |
| 107 |
|
user, host, reason); |
| 112 |
|
} |
| 113 |
|
else |
| 114 |
|
cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE, |
| 115 |
< |
"%d %s %s :%s", tkline_time, user, host, reason); |
| 115 |
> |
"%d %s %s :%s", tkline_time, user, host, reason); |
| 116 |
|
|
| 117 |
< |
if (already_placed_kline(source_p, user, host, YES)) |
| 117 |
> |
if (already_placed_kline(source_p, user, host, 1)) |
| 118 |
|
return; |
| 119 |
|
|
| 120 |
|
/* Look for an oper reason */ |
| 131 |
|
|
| 132 |
|
if (tkline_time != 0) |
| 133 |
|
{ |
| 134 |
< |
ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)", |
| 135 |
< |
(int)(tkline_time/60), reason, current_date); |
| 134 |
> |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
| 135 |
> |
(int)(tkline_time/60), reason, current_date); |
| 136 |
|
DupString(aconf->reason, buffer); |
| 137 |
|
|
| 138 |
|
if (oper_reason != NULL) |
| 141 |
|
} |
| 142 |
|
else |
| 143 |
|
{ |
| 144 |
< |
ircsprintf(buffer, "%s (%s)", reason, current_date); |
| 144 |
> |
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); |
| 145 |
|
DupString(aconf->reason, buffer); |
| 146 |
|
|
| 147 |
|
if (oper_reason != NULL) |
| 162 |
|
time_t cur_time; |
| 163 |
|
char *kuser, *khost, *kreason, *oper_reason; |
| 164 |
|
|
| 165 |
< |
if (parc != 6) |
| 165 |
> |
if (parc != 6 || EmptyString(parv[5])) |
| 166 |
|
return; |
| 167 |
|
|
| 168 |
|
if (!match(parv[1], me.name)) |
| 184 |
|
SHARED_KLINE)) |
| 185 |
|
{ |
| 186 |
|
if (!IsClient(source_p) || |
| 187 |
< |
already_placed_kline(source_p, kuser, khost, YES)) |
| 187 |
> |
already_placed_kline(source_p, kuser, khost, 1)) |
| 188 |
|
return; |
| 189 |
|
|
| 190 |
|
conf = make_conf_item(KLINE_TYPE); |
| 194 |
|
|
| 195 |
|
if (tkline_time != 0) |
| 196 |
|
{ |
| 197 |
< |
ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)", |
| 198 |
< |
(int)(tkline_time/60), kreason, current_date); |
| 197 |
> |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
| 198 |
> |
(int)(tkline_time/60), kreason, current_date); |
| 199 |
|
DupString(aconf->reason, buffer); |
| 200 |
|
|
| 201 |
|
if (oper_reason != NULL) |
| 204 |
|
} |
| 205 |
|
else |
| 206 |
|
{ |
| 207 |
< |
ircsprintf(buffer, "%s (%s)", kreason, current_date); |
| 207 |
> |
snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date); |
| 208 |
|
DupString(aconf->reason, buffer); |
| 209 |
|
|
| 210 |
|
if (oper_reason != NULL) |
| 216 |
|
|
| 217 |
|
static void |
| 218 |
|
ms_kline(struct Client *client_p, struct Client *source_p, |
| 219 |
< |
int parc, char *parv[]) |
| 219 |
> |
int parc, char *parv[]) |
| 220 |
|
{ |
| 221 |
< |
if (parc != 6) |
| 221 |
> |
if (parc != 6 || EmptyString(parv[5])) |
| 222 |
|
return; |
| 223 |
|
|
| 224 |
|
/* parv[0] parv[1] parv[2] parv[3] parv[4] parv[5] */ |
| 239 |
|
*/ |
| 240 |
|
static void |
| 241 |
|
apply_kline(struct Client *source_p, struct ConfItem *conf, |
| 242 |
< |
const char *current_date, time_t cur_time) |
| 242 |
> |
const char *current_date, time_t cur_time) |
| 243 |
|
{ |
| 244 |
|
struct AccessItem *aconf = map_to_conf(conf); |
| 245 |
|
|
| 280 |
|
rehashed_klines = 1; |
| 281 |
|
} |
| 282 |
|
|
| 348 |
– |
/* apply_tdline() |
| 349 |
– |
* |
| 350 |
– |
* inputs - |
| 351 |
– |
* output - NONE |
| 352 |
– |
* side effects - tkline as given is placed |
| 353 |
– |
*/ |
| 354 |
– |
static void |
| 355 |
– |
apply_tdline(struct Client *source_p, struct ConfItem *conf, |
| 356 |
– |
const char *current_date, int tkline_time) |
| 357 |
– |
{ |
| 358 |
– |
struct AccessItem *aconf; |
| 359 |
– |
|
| 360 |
– |
aconf = map_to_conf(conf); |
| 361 |
– |
aconf->hold = CurrentTime + tkline_time; |
| 362 |
– |
|
| 363 |
– |
add_temp_line(conf); |
| 364 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 365 |
– |
"%s added temporary %d min. D-Line for [%s] [%s]", |
| 366 |
– |
get_oper_name(source_p), tkline_time/60, |
| 367 |
– |
aconf->host, aconf->reason); |
| 368 |
– |
|
| 369 |
– |
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]", |
| 370 |
– |
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
| 371 |
– |
source_p->name, tkline_time/60, aconf->host); |
| 372 |
– |
ilog(L_TRACE, "%s added temporary %d min. D-Line for [%s] [%s]", |
| 373 |
– |
source_p->name, tkline_time/60, aconf->host, aconf->reason); |
| 374 |
– |
log_oper_action(LOG_TEMP_DLINE_TYPE, source_p, "[%s@%s] [%s]\n", |
| 375 |
– |
aconf->user, aconf->host, aconf->reason); |
| 376 |
– |
rehashed_klines = 1; |
| 377 |
– |
} |
| 378 |
– |
|
| 379 |
– |
/* mo_dline() |
| 380 |
– |
* |
| 381 |
– |
* inputs - pointer to server |
| 382 |
– |
* - pointer to client |
| 383 |
– |
* - parameter count |
| 384 |
– |
* - parameter list |
| 385 |
– |
* output - |
| 386 |
– |
* side effects - D line is added |
| 387 |
– |
* |
| 388 |
– |
*/ |
| 389 |
– |
static void |
| 390 |
– |
mo_dline(struct Client *client_p, struct Client *source_p, |
| 391 |
– |
int parc, char *parv[]) |
| 392 |
– |
{ |
| 393 |
– |
char def_reason[] = "No reason"; |
| 394 |
– |
char *dlhost, *oper_reason, *reason; |
| 395 |
– |
const char *creason; |
| 396 |
– |
#ifndef IPV6 |
| 397 |
– |
struct Client *target_p; |
| 398 |
– |
#endif |
| 399 |
– |
struct irc_ssaddr daddr; |
| 400 |
– |
struct ConfItem *conf=NULL; |
| 401 |
– |
struct AccessItem *aconf=NULL; |
| 402 |
– |
time_t tkline_time=0; |
| 403 |
– |
int bits, t; |
| 404 |
– |
const char* current_date; |
| 405 |
– |
time_t cur_time; |
| 406 |
– |
|
| 407 |
– |
if (!IsOperK(source_p)) |
| 408 |
– |
{ |
| 409 |
– |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 410 |
– |
me.name, source_p->name, "kline"); |
| 411 |
– |
return; |
| 412 |
– |
} |
| 413 |
– |
|
| 414 |
– |
if (parse_aline("DLINE", source_p, parc, parv, |
| 415 |
– |
AWILD, &dlhost, NULL, &tkline_time, NULL, &reason) < 0) |
| 416 |
– |
return; |
| 417 |
– |
|
| 418 |
– |
if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST) |
| 419 |
– |
{ |
| 420 |
– |
#ifdef IPV6 |
| 421 |
– |
sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.", |
| 422 |
– |
me.name, parv[0]); |
| 423 |
– |
return; |
| 424 |
– |
#else |
| 425 |
– |
if ((target_p = find_chasing(client_p, source_p, dlhost, NULL)) == NULL) |
| 426 |
– |
return; |
| 427 |
– |
|
| 428 |
– |
t = HM_IPV4; |
| 429 |
– |
if (IsServer(target_p)) |
| 430 |
– |
{ |
| 431 |
– |
sendto_one(source_p, |
| 432 |
– |
":%s NOTICE %s :Can't DLINE a server silly", |
| 433 |
– |
me.name, source_p->name); |
| 434 |
– |
return; |
| 435 |
– |
} |
| 436 |
– |
|
| 437 |
– |
if (!MyConnect(target_p)) |
| 438 |
– |
{ |
| 439 |
– |
sendto_one(source_p, |
| 440 |
– |
":%s NOTICE %s :Can't DLINE nick on another server", |
| 441 |
– |
me.name, source_p->name); |
| 442 |
– |
return; |
| 443 |
– |
} |
| 444 |
– |
|
| 445 |
– |
if (IsExemptKline(target_p)) |
| 446 |
– |
{ |
| 447 |
– |
sendto_one(source_p, |
| 448 |
– |
":%s NOTICE %s :%s is E-lined",me.name, |
| 449 |
– |
source_p->name, target_p->name); |
| 450 |
– |
return; |
| 451 |
– |
} |
| 452 |
– |
|
| 453 |
– |
if ((dlhost = make_cidr(dlhost, target_p)) == NULL) |
| 454 |
– |
return; |
| 455 |
– |
|
| 456 |
– |
bits = 0xFFFFFF00UL; |
| 457 |
– |
#endif |
| 458 |
– |
} |
| 459 |
– |
|
| 460 |
– |
if (bits < 8) |
| 461 |
– |
{ |
| 462 |
– |
sendto_one(source_p, |
| 463 |
– |
":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.", |
| 464 |
– |
me.name, source_p->name); |
| 465 |
– |
return; |
| 466 |
– |
} |
| 467 |
– |
|
| 468 |
– |
|
| 469 |
– |
#ifdef IPV6 |
| 470 |
– |
if (t == HM_IPV6) |
| 471 |
– |
t = AF_INET6; |
| 472 |
– |
else |
| 473 |
– |
#endif |
| 474 |
– |
t = AF_INET; |
| 475 |
– |
|
| 476 |
– |
parse_netmask(dlhost, &daddr, NULL); |
| 477 |
– |
|
| 478 |
– |
if ((aconf = find_dline_conf(&daddr, t)) != NULL) |
| 479 |
– |
{ |
| 480 |
– |
creason = aconf->reason ? aconf->reason : def_reason; |
| 481 |
– |
if (IsConfExemptKline(aconf)) |
| 482 |
– |
sendto_one(source_p, |
| 483 |
– |
":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s", |
| 484 |
– |
me.name, source_p->name, dlhost, aconf->host, creason); |
| 485 |
– |
else |
| 486 |
– |
sendto_one(source_p, |
| 487 |
– |
":%s NOTICE %s :[%s] already D-lined by [%s] - %s", |
| 488 |
– |
me.name, source_p->name, dlhost, aconf->host, creason); |
| 489 |
– |
return; |
| 490 |
– |
} |
| 491 |
– |
|
| 492 |
– |
cur_time = CurrentTime; |
| 493 |
– |
current_date = smalldate(cur_time); |
| 494 |
– |
|
| 495 |
– |
/* Look for an oper reason */ |
| 496 |
– |
if ((oper_reason = strchr(reason, '|')) != NULL) |
| 497 |
– |
*oper_reason++ = '\0'; |
| 498 |
– |
|
| 499 |
– |
if (!valid_comment(source_p, reason, YES)) |
| 500 |
– |
return; |
| 501 |
– |
|
| 502 |
– |
conf = make_conf_item(DLINE_TYPE); |
| 503 |
– |
aconf = map_to_conf(conf); |
| 504 |
– |
DupString(aconf->host, dlhost); |
| 505 |
– |
|
| 506 |
– |
if (tkline_time != 0) |
| 507 |
– |
{ |
| 508 |
– |
ircsprintf(buffer, "Temporary D-line %d min. - %s (%s)", |
| 509 |
– |
(int)(tkline_time/60), reason, current_date); |
| 510 |
– |
DupString(aconf->reason, buffer); |
| 511 |
– |
if (oper_reason != NULL) |
| 512 |
– |
DupString(aconf->oper_reason, oper_reason); |
| 513 |
– |
apply_tdline(source_p, conf, current_date, tkline_time); |
| 514 |
– |
} |
| 515 |
– |
else |
| 516 |
– |
{ |
| 517 |
– |
ircsprintf(buffer, "%s (%s)", reason, current_date); |
| 518 |
– |
DupString(aconf->reason, buffer); |
| 519 |
– |
if (oper_reason != NULL) |
| 520 |
– |
DupString(aconf->oper_reason, oper_reason); |
| 521 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
| 522 |
– |
write_conf_line(source_p, conf, current_date, cur_time); |
| 523 |
– |
} |
| 524 |
– |
|
| 525 |
– |
rehashed_klines = 1; |
| 526 |
– |
} /* mo_dline() */ |
| 527 |
– |
|
| 528 |
– |
|
| 283 |
|
/* already_placed_kline() |
| 284 |
|
* inputs - user to complain to, username & host to check for |
| 285 |
|
* outputs - returns 1 on existing K-line, 0 if doesn't exist |
| 330 |
|
return(0); |
| 331 |
|
} |
| 332 |
|
|
| 579 |
– |
#ifndef IPV6 |
| 580 |
– |
static char * |
| 581 |
– |
make_cidr(char *dlhost, struct Client *target_p) |
| 582 |
– |
{ |
| 583 |
– |
static char cidr_form_host[HOSTLEN + 2]; |
| 584 |
– |
char *p; |
| 585 |
– |
|
| 586 |
– |
strlcpy(cidr_form_host, inetntoa((const char *)&target_p->localClient->ip), |
| 587 |
– |
sizeof(cidr_form_host)); |
| 588 |
– |
|
| 589 |
– |
if ((p = strchr(cidr_form_host,'.')) == NULL) |
| 590 |
– |
return(NULL); |
| 591 |
– |
|
| 592 |
– |
/* 192. <- p */ |
| 593 |
– |
p++; |
| 594 |
– |
if ((p = strchr(p,'.')) == NULL) |
| 595 |
– |
return(NULL); |
| 596 |
– |
|
| 597 |
– |
/* 192.168. <- p */ |
| 598 |
– |
p++; |
| 599 |
– |
if ((p = strchr(p,'.')) == NULL) |
| 600 |
– |
return(NULL); |
| 601 |
– |
|
| 602 |
– |
/* 192.168.0. <- p */ |
| 603 |
– |
p++; |
| 604 |
– |
*p++ = '0'; |
| 605 |
– |
*p++ = '/'; |
| 606 |
– |
*p++ = '2'; |
| 607 |
– |
*p++ = '4'; |
| 608 |
– |
*p++ = '\0'; |
| 609 |
– |
|
| 610 |
– |
return(cidr_form_host); |
| 611 |
– |
} |
| 612 |
– |
#endif |
| 613 |
– |
|
| 333 |
|
/* |
| 334 |
|
** mo_unkline |
| 335 |
|
** Added Aug 31, 1997 |
| 347 |
|
char *target_server = NULL; |
| 348 |
|
char *user, *host; |
| 349 |
|
|
| 350 |
< |
if (!IsOperUnkline(source_p)) |
| 350 |
> |
if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) |
| 351 |
|
{ |
| 352 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 353 |
|
me.name, source_p->name, "unkline"); |
| 377 |
|
} |
| 378 |
|
else |
| 379 |
|
cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE, |
| 380 |
< |
"%s %s", user, host); |
| 380 |
> |
"%s %s", user, host); |
| 381 |
|
|
| 382 |
|
if (remove_tkline_match(host, user)) |
| 383 |
|
{ |
| 395 |
|
if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0) |
| 396 |
|
{ |
| 397 |
|
sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed", |
| 398 |
< |
me.name, source_p->name, user,host); |
| 398 |
> |
me.name, source_p->name, user,host); |
| 399 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 400 |
< |
"%s has removed the K-Line for: [%s@%s]", |
| 401 |
< |
get_oper_name(source_p), user, host); |
| 400 |
> |
"%s has removed the K-Line for: [%s@%s]", |
| 401 |
> |
get_oper_name(source_p), user, host); |
| 402 |
|
ilog(L_NOTICE, "%s removed K-Line for [%s@%s]", |
| 403 |
< |
source_p->name, user, host); |
| 403 |
> |
source_p->name, user, host); |
| 404 |
|
} |
| 405 |
|
else |
| 406 |
|
sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found", |
| 503 |
|
if (cnm_t != nm_t || irccmp(user, tk_c->user)) |
| 504 |
|
continue; |
| 505 |
|
if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) || |
| 506 |
< |
(nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits)) |
| 506 |
> |
(nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits)) |
| 507 |
|
#ifdef IPV6 |
| 508 |
< |
|| (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits)) |
| 508 |
> |
|| (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits)) |
| 509 |
|
#endif |
| 510 |
< |
) |
| 510 |
> |
) |
| 511 |
|
{ |
| 512 |
< |
dlinkDelete(tk_n, &temporary_klines); |
| 513 |
< |
delete_one_address_conf(tk_c->host, tk_c); |
| 514 |
< |
return(YES); |
| 512 |
> |
dlinkDelete(tk_n, &temporary_klines); |
| 513 |
> |
delete_one_address_conf(tk_c->host, tk_c); |
| 514 |
> |
return 1; |
| 515 |
|
} |
| 516 |
|
} |
| 517 |
|
|
| 518 |
< |
return(NO); |
| 518 |
> |
return 0; |
| 519 |
|
} |
| 520 |
|
|
| 521 |
< |
/* static int remove_tdline_match(const char *host, const char *user) |
| 522 |
< |
* Input: An ip to undline. |
| 523 |
< |
* Output: returns YES on success, NO if no tdline removed. |
| 524 |
< |
* Side effects: Any matching tdlines are removed. |
| 806 |
< |
*/ |
| 807 |
< |
static int |
| 808 |
< |
remove_tdline_match(const char *cidr) |
| 809 |
< |
{ |
| 810 |
< |
struct AccessItem *td_conf; |
| 811 |
< |
dlink_node *td_node; |
| 812 |
< |
struct irc_ssaddr addr, caddr; |
| 813 |
< |
int nm_t, cnm_t, bits, cbits; |
| 814 |
< |
nm_t = parse_netmask(cidr, &addr, &bits); |
| 815 |
< |
|
| 816 |
< |
DLINK_FOREACH(td_node, temporary_dlines.head) |
| 817 |
< |
{ |
| 818 |
< |
td_conf = map_to_conf(td_node->data); |
| 819 |
< |
cnm_t = parse_netmask(td_conf->host, &caddr, &cbits); |
| 820 |
< |
|
| 821 |
< |
if (cnm_t != nm_t) |
| 822 |
< |
continue; |
| 521 |
> |
static struct Message kline_msgtab = { |
| 522 |
> |
"KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 523 |
> |
{m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore} |
| 524 |
> |
}; |
| 525 |
|
|
| 526 |
< |
if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) || |
| 527 |
< |
(nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits)) |
| 528 |
< |
#ifdef IPV6 |
| 529 |
< |
|| (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits)) |
| 828 |
< |
#endif |
| 829 |
< |
) |
| 830 |
< |
{ |
| 831 |
< |
dlinkDelete(td_node, &temporary_dlines); |
| 832 |
< |
delete_one_address_conf(td_conf->host, td_conf); |
| 833 |
< |
return(YES); |
| 834 |
< |
} |
| 835 |
< |
} |
| 526 |
> |
static struct Message unkline_msgtab = { |
| 527 |
> |
"UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 528 |
> |
{m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore} |
| 529 |
> |
}; |
| 530 |
|
|
| 531 |
< |
return(NO); |
| 531 |
> |
static void |
| 532 |
> |
module_init(void) |
| 533 |
> |
{ |
| 534 |
> |
mod_add_cmd(&kline_msgtab); |
| 535 |
> |
mod_add_cmd(&unkline_msgtab); |
| 536 |
> |
add_capability("KLN", CAP_KLN, 1); |
| 537 |
> |
add_capability("UNKLN", CAP_UNKLN, 1); |
| 538 |
|
} |
| 539 |
|
|
| 840 |
– |
/* |
| 841 |
– |
** m_undline |
| 842 |
– |
** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk> |
| 843 |
– |
** based totally on m_unkline |
| 844 |
– |
** added to hybrid-7 7/11/2000 --is |
| 845 |
– |
** |
| 846 |
– |
** parv[0] = sender nick |
| 847 |
– |
** parv[1] = dline to remove |
| 848 |
– |
*/ |
| 540 |
|
static void |
| 541 |
< |
mo_undline(struct Client *client_p, struct Client *source_p, |
| 851 |
< |
int parc, char *parv[]) |
| 541 |
> |
module_exit(void) |
| 542 |
|
{ |
| 543 |
< |
const char *cidr; |
| 544 |
< |
|
| 545 |
< |
if (!IsOperUnkline(source_p)) |
| 546 |
< |
{ |
| 857 |
< |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 858 |
< |
me.name, source_p->name, "undline"); |
| 859 |
< |
return; |
| 860 |
< |
} |
| 861 |
< |
|
| 862 |
< |
cidr = parv[1]; |
| 863 |
< |
|
| 864 |
< |
if (remove_tdline_match(cidr)) |
| 865 |
< |
{ |
| 866 |
< |
sendto_one(source_p, |
| 867 |
< |
":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines", |
| 868 |
< |
me.name, source_p->name, cidr); |
| 869 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 870 |
< |
"%s has removed the temporary D-Line for: [%s]", |
| 871 |
< |
get_oper_name(source_p), cidr); |
| 872 |
< |
ilog(L_NOTICE, "%s removed temporary D-Line for [%s]", source_p->name, cidr); |
| 873 |
< |
return; |
| 874 |
< |
} |
| 875 |
< |
|
| 876 |
< |
if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0) |
| 877 |
< |
{ |
| 878 |
< |
sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", |
| 879 |
< |
me.name, source_p->name, cidr); |
| 880 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 881 |
< |
"%s has removed the D-Line for: [%s]", |
| 882 |
< |
get_oper_name(source_p), cidr); |
| 883 |
< |
ilog(L_NOTICE, "%s removed D-Line for [%s]", |
| 884 |
< |
get_oper_name(source_p), cidr); |
| 885 |
< |
} |
| 886 |
< |
else |
| 887 |
< |
sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found", |
| 888 |
< |
me.name, source_p->name, cidr); |
| 543 |
> |
mod_del_cmd(&kline_msgtab); |
| 544 |
> |
mod_del_cmd(&unkline_msgtab); |
| 545 |
> |
delete_capability("UNKLN"); |
| 546 |
> |
delete_capability("KLN"); |
| 547 |
|
} |
| 548 |
+ |
|
| 549 |
+ |
struct module module_entry = { |
| 550 |
+ |
.node = { NULL, NULL, NULL }, |
| 551 |
+ |
.name = NULL, |
| 552 |
+ |
.version = "$Revision$", |
| 553 |
+ |
.handle = NULL, |
| 554 |
+ |
.modinit = module_init, |
| 555 |
+ |
.modexit = module_exit, |
| 556 |
+ |
.flags = 0 |
| 557 |
+ |
}; |