Check k/dlines against underlying IPv4 as well.

This commit is contained in:
Jilles Tjoelker 2012-01-08 15:51:15 +01:00
parent ae52fe0ff7
commit d006b551c8

View file

@ -32,6 +32,7 @@
#include "numeric.h" #include "numeric.h"
#include "send.h" #include "send.h"
#include "match.h" #include "match.h"
#include "ipv4_from_ipv6.h"
#ifdef RB_IPV6 #ifdef RB_IPV6
static unsigned long hash_ipv6(struct sockaddr *, int); static unsigned long hash_ipv6(struct sockaddr *, int);
@ -367,6 +368,9 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
{ {
struct ConfItem *iconf, *kconf; struct ConfItem *iconf, *kconf;
const char *vuser; const char *vuser;
#ifdef RB_IPV6
struct sockaddr_in ip4;
#endif
/* Find the best I-line... If none, return NULL -A1kmm */ /* Find the best I-line... If none, return NULL -A1kmm */
if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user))) if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user)))
@ -417,6 +421,16 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
return kconf; return kconf;
} }
#ifdef RB_IPV6
if(ip->sa_family == AF_INET6 &&
ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)ip, &ip4))
{
kconf = find_conf_by_address(NULL, NULL, NULL, (struct sockaddr *)&ip4, CONF_KILL, AF_INET, vuser, NULL);
if(kconf)
return kconf;
}
#endif /* RB_IPV6 */
return iconf; return iconf;
} }
@ -428,11 +442,27 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
struct ConfItem * struct ConfItem *
find_dline(struct sockaddr *addr, int aftype) find_dline(struct sockaddr *addr, int aftype)
{ {
struct ConfItem *eline; struct ConfItem *aconf;
eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL); #ifdef RB_IPV6
if(eline) struct sockaddr_in addr2;
return eline; #endif
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
aconf = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL);
if(aconf)
return aconf;
aconf = find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
if(aconf)
return aconf;
#ifdef RB_IPV6
if(addr->sa_family == AF_INET6 &&
ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)addr, &addr2))
{
aconf = find_conf_by_address(NULL, NULL, NULL, (struct sockaddr *)&addr2, CONF_DLINE | 1, AF_INET, NULL, NULL);
if(aconf)
return aconf;
}
#endif
return NULL;
} }
/* void find_exact_conf_by_address(const char*, int, const char *) /* void find_exact_conf_by_address(const char*, int, const char *)