| 20 |
|
*/ |
| 21 |
|
|
| 22 |
|
/*! \file m_dline.c |
| 23 |
< |
* \brief Includes required functions for processing the DLINE/UNDLINE command. |
| 23 |
> |
* \brief Includes required functions for processing the DLINE command. |
| 24 |
|
* \version $Id$ |
| 25 |
|
*/ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 28 |
|
#include "list.h" |
| 29 |
– |
#include "channel.h" |
| 29 |
|
#include "client.h" |
| 30 |
|
#include "irc_string.h" |
| 31 |
|
#include "conf.h" |
| 32 |
|
#include "ircd.h" |
| 33 |
|
#include "hostmask.h" |
| 34 |
|
#include "numeric.h" |
| 36 |
– |
#include "fdlist.h" |
| 37 |
– |
#include "s_bsd.h" |
| 35 |
|
#include "log.h" |
| 36 |
< |
#include "s_misc.h" |
| 36 |
> |
#include "misc.h" |
| 37 |
|
#include "send.h" |
| 38 |
|
#include "hash.h" |
| 39 |
< |
#include "s_serv.h" |
| 39 |
> |
#include "server.h" |
| 40 |
|
#include "parse.h" |
| 41 |
|
#include "modules.h" |
| 42 |
|
#include "conf_db.h" |
| 82 |
|
rehashed_klines = 1; |
| 83 |
|
} |
| 84 |
|
|
| 88 |
– |
/* static int remove_tdline_match(const char *host, const char *user) |
| 89 |
– |
* Input: An ip to undline. |
| 90 |
– |
* Output: returns YES on success, NO if no tdline removed. |
| 91 |
– |
* Side effects: Any matching tdlines are removed. |
| 92 |
– |
*/ |
| 93 |
– |
static int |
| 94 |
– |
remove_dline_match(const char *host) |
| 95 |
– |
{ |
| 96 |
– |
struct irc_ssaddr iphost, *piphost; |
| 97 |
– |
struct MaskItem *conf; |
| 98 |
– |
int t = 0; |
| 99 |
– |
int aftype = 0; |
| 100 |
– |
|
| 101 |
– |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
| 102 |
– |
{ |
| 103 |
– |
#ifdef IPV6 |
| 104 |
– |
if (t == HM_IPV6) |
| 105 |
– |
aftype = AF_INET6; |
| 106 |
– |
else |
| 107 |
– |
#endif |
| 108 |
– |
aftype = AF_INET; |
| 109 |
– |
piphost = &iphost; |
| 110 |
– |
} |
| 111 |
– |
else |
| 112 |
– |
piphost = NULL; |
| 113 |
– |
|
| 114 |
– |
if ((conf = find_conf_by_address(host, piphost, CONF_DLINE, aftype, NULL, NULL, 0))) |
| 115 |
– |
{ |
| 116 |
– |
if (IsConfDatabase(conf)) |
| 117 |
– |
{ |
| 118 |
– |
delete_one_address_conf(host, conf); |
| 119 |
– |
return 1; |
| 120 |
– |
} |
| 121 |
– |
} |
| 122 |
– |
|
| 123 |
– |
return 0; |
| 124 |
– |
} |
| 125 |
– |
|
| 85 |
|
/* mo_dline() |
| 86 |
|
* |
| 87 |
|
* inputs - pointer to server |
| 93 |
|
* |
| 94 |
|
*/ |
| 95 |
|
static int |
| 96 |
< |
mo_dline(struct Client *client_p, struct Client *source_p, |
| 138 |
< |
int parc, char *parv[]) |
| 96 |
> |
mo_dline(struct Client *source_p, int parc, char *parv[]) |
| 97 |
|
{ |
| 98 |
|
char def_reason[] = CONF_NOREASON; |
| 99 |
|
char *dlhost = NULL, *reason = NULL; |
| 105 |
|
time_t tkline_time=0; |
| 106 |
|
int bits = 0, aftype = 0, t = 0; |
| 107 |
|
const char *current_date = NULL; |
| 150 |
– |
time_t cur_time; |
| 108 |
|
char hostip[HOSTIPLEN + 1]; |
| 109 |
|
char buffer[IRCD_BUFSIZE]; |
| 110 |
|
|
| 118 |
|
NULL, &tkline_time, &target_server, &reason) < 0) |
| 119 |
|
return 0; |
| 120 |
|
|
| 121 |
< |
if (target_server != NULL) |
| 121 |
> |
if (target_server) |
| 122 |
|
{ |
| 123 |
|
sendto_match_servs(source_p, target_server, CAP_DLN, "DLINE %s %lu %s :%s", |
| 124 |
|
target_server, (unsigned long)tkline_time, |
| 134 |
|
|
| 135 |
|
if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST) |
| 136 |
|
{ |
| 137 |
< |
if ((target_p = find_chasing(source_p, dlhost, NULL)) == NULL) |
| 137 |
> |
if ((target_p = find_chasing(source_p, dlhost)) == NULL) |
| 138 |
|
return 0; |
| 139 |
|
|
| 140 |
|
if (!MyConnect(target_p)) |
| 141 |
|
{ |
| 142 |
< |
sendto_one_notice(source_p, &me, ":Can't DLINE nick on another server"); |
| 142 |
> |
sendto_one_notice(source_p, &me, ":Cannot DLINE nick on another server"); |
| 143 |
|
return 0; |
| 144 |
|
} |
| 145 |
|
|
| 173 |
|
|
| 174 |
|
parse_netmask(dlhost, &daddr, NULL); |
| 175 |
|
|
| 176 |
< |
if ((conf = find_dline_conf(&daddr, aftype)) != NULL) |
| 176 |
> |
if ((conf = find_dline_conf(&daddr, aftype))) |
| 177 |
|
{ |
| 178 |
|
creason = conf->reason ? conf->reason : def_reason; |
| 179 |
|
|
| 186 |
|
return 0; |
| 187 |
|
} |
| 188 |
|
|
| 189 |
< |
cur_time = CurrentTime; |
| 233 |
< |
current_date = smalldate(cur_time); |
| 189 |
> |
current_date = smalldate(0); |
| 190 |
|
|
| 191 |
|
if (!valid_comment(source_p, reason, 1)) |
| 192 |
|
return 0; |
| 194 |
|
conf = conf_make(CONF_DLINE); |
| 195 |
|
conf->host = xstrdup(dlhost); |
| 196 |
|
|
| 197 |
< |
if (tkline_time != 0) |
| 197 |
> |
if (tkline_time) |
| 198 |
|
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)", |
| 199 |
|
(int)(tkline_time/60), reason, current_date); |
| 200 |
|
else |
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
static int |
| 210 |
< |
ms_dline(struct Client *client_p, struct Client *source_p, |
| 255 |
< |
int parc, char *parv[]) |
| 210 |
> |
ms_dline(struct Client *source_p, int parc, char *parv[]) |
| 211 |
|
{ |
| 212 |
|
char def_reason[] = CONF_NOREASON; |
| 213 |
|
char *dlhost, *reason; |
| 218 |
|
time_t tkline_time=0; |
| 219 |
|
int bits = 0, aftype = 0, t = 0; |
| 220 |
|
const char *current_date = NULL; |
| 266 |
– |
time_t cur_time; |
| 221 |
|
char hostip[HOSTIPLEN + 1]; |
| 222 |
|
char buffer[IRCD_BUFSIZE]; |
| 223 |
|
|
| 247 |
|
|
| 248 |
|
if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST) |
| 249 |
|
{ |
| 250 |
< |
if ((target_p = find_chasing(source_p, dlhost, NULL)) == NULL) |
| 250 |
> |
if ((target_p = find_chasing(source_p, dlhost)) == NULL) |
| 251 |
|
return 0; |
| 252 |
|
|
| 253 |
|
if (!MyConnect(target_p)) |
| 254 |
|
{ |
| 255 |
< |
sendto_one_notice(source_p, &me, ":Can't DLINE nick on another server"); |
| 255 |
> |
sendto_one_notice(source_p, &me, ":Cannot DLINE nick on another server"); |
| 256 |
|
return 0; |
| 257 |
|
} |
| 258 |
|
|
| 285 |
|
|
| 286 |
|
parse_netmask(dlhost, &daddr, NULL); |
| 287 |
|
|
| 288 |
< |
if ((conf = find_dline_conf(&daddr, aftype)) != NULL) |
| 288 |
> |
if ((conf = find_dline_conf(&daddr, aftype))) |
| 289 |
|
{ |
| 290 |
|
creason = conf->reason ? conf->reason : def_reason; |
| 291 |
|
if (IsConfExemptKline(conf)) |
| 297 |
|
return 0; |
| 298 |
|
} |
| 299 |
|
|
| 300 |
< |
cur_time = CurrentTime; |
| 347 |
< |
current_date = smalldate(cur_time); |
| 300 |
> |
current_date = smalldate(0); |
| 301 |
|
|
| 302 |
|
if (!valid_comment(source_p, reason, 1)) |
| 303 |
|
return 0; |
| 305 |
|
conf = conf_make(CONF_DLINE); |
| 306 |
|
conf->host = xstrdup(dlhost); |
| 307 |
|
|
| 308 |
< |
if (tkline_time != 0) |
| 308 |
> |
if (tkline_time) |
| 309 |
|
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)", |
| 310 |
|
(int)(tkline_time/60), reason, current_date); |
| 311 |
|
else |
| 319 |
|
return 0; |
| 320 |
|
} |
| 321 |
|
|
| 369 |
– |
/* |
| 370 |
– |
** m_undline |
| 371 |
– |
** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk> |
| 372 |
– |
** based totally on m_unkline |
| 373 |
– |
** added to hybrid-7 7/11/2000 --is |
| 374 |
– |
** |
| 375 |
– |
** parv[0] = sender nick |
| 376 |
– |
** parv[1] = dline to remove |
| 377 |
– |
*/ |
| 378 |
– |
static int |
| 379 |
– |
mo_undline(struct Client *client_p, struct Client *source_p, |
| 380 |
– |
int parc, char *parv[]) |
| 381 |
– |
{ |
| 382 |
– |
char *addr = NULL, *user = NULL; |
| 383 |
– |
char *target_server = NULL; |
| 384 |
– |
|
| 385 |
– |
if (!HasOFlag(source_p, OPER_FLAG_UNDLINE)) |
| 386 |
– |
{ |
| 387 |
– |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "undline"); |
| 388 |
– |
return 0; |
| 389 |
– |
} |
| 390 |
– |
|
| 391 |
– |
if (parc < 2 || EmptyString(parv[1])) |
| 392 |
– |
{ |
| 393 |
– |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "UNDLINE"); |
| 394 |
– |
return 0; |
| 395 |
– |
} |
| 396 |
– |
|
| 397 |
– |
if (parse_aline("UNDLINE", source_p, parc, parv, 0, &user, |
| 398 |
– |
&addr, NULL, &target_server, NULL) < 0) |
| 399 |
– |
return 0; |
| 400 |
– |
|
| 401 |
– |
if (target_server != NULL) |
| 402 |
– |
{ |
| 403 |
– |
sendto_match_servs(source_p, target_server, CAP_UNDLN, |
| 404 |
– |
"UNDLINE %s %s", target_server, addr); |
| 405 |
– |
|
| 406 |
– |
/* Allow ON to apply local unkline as well if it matches */ |
| 407 |
– |
if (match(target_server, me.name)) |
| 408 |
– |
return 0; |
| 409 |
– |
} |
| 410 |
– |
else |
| 411 |
– |
cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE, |
| 412 |
– |
"%s", addr); |
| 413 |
– |
|
| 414 |
– |
if (remove_dline_match(addr)) |
| 415 |
– |
{ |
| 416 |
– |
sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr); |
| 417 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 418 |
– |
"%s has removed the D-Line for: [%s]", |
| 419 |
– |
get_oper_name(source_p), addr); |
| 420 |
– |
ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]", |
| 421 |
– |
get_oper_name(source_p), addr); |
| 422 |
– |
} |
| 423 |
– |
else |
| 424 |
– |
sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr); |
| 425 |
– |
return 0; |
| 426 |
– |
} |
| 427 |
– |
|
| 428 |
– |
static int |
| 429 |
– |
ms_undline(struct Client *client_p, struct Client *source_p, |
| 430 |
– |
int parc, char *parv[]) |
| 431 |
– |
{ |
| 432 |
– |
const char *addr = parv[1]; |
| 433 |
– |
|
| 434 |
– |
if (parc != 3 || EmptyString(parv[2])) |
| 435 |
– |
return 0; |
| 436 |
– |
|
| 437 |
– |
sendto_match_servs(source_p, parv[1], CAP_UNDLN, |
| 438 |
– |
"UNDLINE %s %s", |
| 439 |
– |
parv[1], parv[2]); |
| 440 |
– |
|
| 441 |
– |
if (!IsClient(source_p) || match(parv[1], me.name)) |
| 442 |
– |
return 0; |
| 443 |
– |
|
| 444 |
– |
if (HasFlag(source_p, FLAGS_SERVICE) || |
| 445 |
– |
find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
| 446 |
– |
source_p->username, source_p->host, |
| 447 |
– |
SHARED_UNDLINE)) |
| 448 |
– |
{ |
| 449 |
– |
if (remove_dline_match(addr)) |
| 450 |
– |
{ |
| 451 |
– |
sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr); |
| 452 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 453 |
– |
"%s has removed the D-Line for: [%s]", |
| 454 |
– |
get_oper_name(source_p), addr); |
| 455 |
– |
ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]", |
| 456 |
– |
get_oper_name(source_p), addr); |
| 457 |
– |
} |
| 458 |
– |
else |
| 459 |
– |
sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr); |
| 460 |
– |
} |
| 461 |
– |
|
| 462 |
– |
return 0; |
| 463 |
– |
} |
| 464 |
– |
|
| 322 |
|
static struct Message dline_msgtab = |
| 323 |
|
{ |
| 324 |
|
"DLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 325 |
|
{ m_unregistered, m_not_oper, ms_dline, m_ignore, mo_dline, m_ignore } |
| 326 |
|
}; |
| 327 |
|
|
| 471 |
– |
static struct Message undline_msgtab = |
| 472 |
– |
{ |
| 473 |
– |
"UNDLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 474 |
– |
{ m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore } |
| 475 |
– |
}; |
| 476 |
– |
|
| 328 |
|
static void |
| 329 |
|
module_init(void) |
| 330 |
|
{ |
| 331 |
|
mod_add_cmd(&dline_msgtab); |
| 481 |
– |
mod_add_cmd(&undline_msgtab); |
| 332 |
|
add_capability("DLN", CAP_DLN, 1); |
| 483 |
– |
add_capability("UNDLN", CAP_UNDLN, 1); |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
static void |
| 336 |
|
module_exit(void) |
| 337 |
|
{ |
| 338 |
|
mod_del_cmd(&dline_msgtab); |
| 490 |
– |
mod_del_cmd(&undline_msgtab); |
| 491 |
– |
delete_capability("UNDLN"); |
| 339 |
|
delete_capability("DLN"); |
| 340 |
|
} |
| 341 |
|
|