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 4c171a9c72
commit df7a3250b1
1 changed files with 30 additions and 15 deletions

View File

@ -693,13 +693,16 @@ valid_comment(struct Client *source_p, char *comment)
static int
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 ConfItem *aconf;
int t;
if(ConfigFileEntry.non_redundant_klines)
int t, bits;
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
if(t == HM_IPV6)
@ -713,7 +716,20 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
else
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 */
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 0;
}