Handle kline_spoof_ip in check_one_kline

This commit is contained in:
Ed Kellett 2020-04-14 23:51:23 +01:00
parent 67e05d5b67
commit 40e76ac76c
No known key found for this signature in database
GPG key ID: CB9986DEF342FABC

View file

@ -602,13 +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 && case HM_IPV6:
if (IsConfDoSpoofIp(client_p->localClient->att_conf) &&
IsConfKlineSpoof(client_p->localClient->att_conf))
continue;
if (client_p->localClient->ip.ss_family == AF_INET6 && sockaddr.ss_family == AF_INET &&
rb_ipv4_from_ipv6((struct sockaddr_in6 *)&client_p->localClient->ip, &ip4) rb_ipv4_from_ipv6((struct sockaddr_in6 *)&client_p->localClient->ip, &ip4)
&& comp_with_mask_sock((struct sockaddr *)&ip4, (struct sockaddr *)&sockaddr, bits)) && comp_with_mask_sock((struct sockaddr *)&ip4, (struct sockaddr *)&sockaddr, bits))
matched = 1; matched = 1;
/* fallthrough */ else if (client_p->localClient->ip.ss_family == sockaddr.ss_family &&
case HM_IPV6:
if (client_p->localClient->ip.ss_family == sockaddr.ss_family &&
comp_with_mask_sock((struct sockaddr *)&client_p->localClient->ip, comp_with_mask_sock((struct sockaddr *)&client_p->localClient->ip,
(struct sockaddr *)&sockaddr, bits)) (struct sockaddr *)&sockaddr, bits))
matched = 1; matched = 1;
@ -616,6 +618,9 @@ check_one_kline(struct ConfItem *kline)
case HM_HOST: case HM_HOST:
if (match(kline->host, client_p->orighost)) if (match(kline->host, client_p->orighost))
matched = 1; matched = 1;
if (IsConfDoSpoofIp(client_p->localClient->att_conf) &&
IsConfKlineSpoof(client_p->localClient->att_conf))
continue;
if (match(kline->host, client_p->sockhost)) if (match(kline->host, client_p->sockhost))
matched = 1; matched = 1;
break; break;