Add ipv4-in-ipv6 logic to check_one_kline
This commit is contained in:
parent
9274c0f3f4
commit
485d245ec0
1 changed files with 9 additions and 2 deletions
|
@ -583,6 +583,7 @@ check_one_kline(struct ConfItem *kline)
|
||||||
int masktype;
|
int masktype;
|
||||||
int bits;
|
int bits;
|
||||||
struct rb_sockaddr_storage sockaddr;
|
struct rb_sockaddr_storage sockaddr;
|
||||||
|
struct sockaddr_in ip4;
|
||||||
|
|
||||||
masktype = parse_netmask(kline->host, (struct sockaddr_storage *)&sockaddr, &bits);
|
masktype = parse_netmask(kline->host, (struct sockaddr_storage *)&sockaddr, &bits);
|
||||||
|
|
||||||
|
@ -601,9 +602,15 @@ check_one_kline(struct ConfItem *kline)
|
||||||
/* match one kline */
|
/* match one kline */
|
||||||
switch (masktype) {
|
switch (masktype) {
|
||||||
case HM_IPV4:
|
case HM_IPV4:
|
||||||
|
if (client_p->localClient->ip.ss_family == AF_INET6 &&
|
||||||
|
rb_ipv4_from_ipv6((struct sockaddr_in6 *)&client_p->localClient->ip, &ip4)
|
||||||
|
&& comp_with_mask_sock((struct sockaddr *)&ip4, (struct sockaddr *)&sockaddr, bits))
|
||||||
|
matched = 1;
|
||||||
|
/* fallthrough */
|
||||||
case HM_IPV6:
|
case HM_IPV6:
|
||||||
if (comp_with_mask_sock((struct sockaddr *)&client_p->localClient->ip,
|
if (client_p->localClient->ip.ss_family == sockaddr.ss_family &&
|
||||||
(struct sockaddr *)&sockaddr, bits))
|
comp_with_mask_sock((struct sockaddr *)&client_p->localClient->ip,
|
||||||
|
(struct sockaddr *)&sockaddr, bits))
|
||||||
matched = 1;
|
matched = 1;
|
||||||
break;
|
break;
|
||||||
case HM_HOST:
|
case HM_HOST:
|
||||||
|
|
Loading…
Reference in a new issue