Never allow a duplicate kline; always allow a wider kline.

Duplicate klines are now disallowed regardless of
no_redundant_klines.  There is a somewhat hackish check
to see if the new kline is wider than the existing one.
This commit is contained in:
Jilles Tjoelker 2007-12-26 00:51:22 +01:00
parent d922ddedfd
commit 7f27e3163d

View file

@ -693,13 +693,16 @@ valid_comment(struct Client *source_p, char *comment)
static int static int
already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int tkline) already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int tkline)
{ {
const char *reason; const char *reason, *p;
struct irc_sockaddr_storage iphost, *piphost; struct irc_sockaddr_storage iphost, *piphost;
struct ConfItem *aconf; struct ConfItem *aconf;
int t; int t, bits;
if(ConfigFileEntry.non_redundant_klines)
aconf = find_exact_conf_by_address(lhost, CONF_KILL, luser);
if (aconf == NULL && ConfigFileEntry.non_redundant_klines)
{ {
if((t = parse_netmask(lhost, (struct sockaddr *)&iphost, NULL)) != HM_HOST) bits = 0;
if((t = parse_netmask(lhost, (struct sockaddr *)&iphost, &bits)) != HM_HOST)
{ {
#ifdef IPV6 #ifdef IPV6
if(t == HM_IPV6) if(t == HM_IPV6)
@ -713,7 +716,20 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
else else
piphost = NULL; piphost = NULL;
if((aconf = find_conf_by_address(lhost, NULL, NULL, (struct sockaddr *)piphost, CONF_KILL, t, luser))) aconf = find_conf_by_address(lhost, NULL, NULL, (struct sockaddr *)piphost, CONF_KILL, t, luser);
if (aconf != NULL)
{
/* The above was really a lookup of a single IP,
* so check if the new kline is wider than the
* existing one.
* -- jilles
*/
p = strchr(aconf->host, '/');
if (bits > 0 && (p == NULL || bits < atoi(p + 1)))
aconf = NULL;
}
}
if (aconf != NULL)
{ {
/* setting a tkline, or existing one is perm */ /* setting a tkline, or existing one is perm */
if(tkline || ((aconf->flags & CONF_FLAGS_TEMPORARY) == 0)) if(tkline || ((aconf->flags & CONF_FLAGS_TEMPORARY) == 0))
@ -727,7 +743,6 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
return 1; return 1;
} }
} }
}
return 0; return 0;
} }