Skip to content

Commit

Permalink
fix: is_address_exist
Browse files Browse the repository at this point in the history
Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Sep 25, 2024
1 parent c570b88 commit 052b82c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ssl_redir.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,12 @@ check_internet_available_cb(int errcode, struct evutil_addrinfo *addr, void *ptr
static int
is_address_exist(t_ip_trusted *ips, const char *ip, int family) {
t_ip_trusted *ipt = ips;
int ip_len = strlen(ip);
while(ipt) {
if (family == AF_INET && ipt->ip_type == IP_TYPE_IPV4) {
if (strcmp(ipt->ip, ip) == 0)
return 1;
} else if (family == AF_INET6 && ipt->ip_type == IP_TYPE_IPV6) {
if (strcmp(ipt->ip, ip) == 0)
return 1;
int ipt_len = strlen(ipt->ip);
if (ipt_len == ip_len && !strncmp(ipt->ip, ip, ip_len)) {
debug(LOG_DEBUG, "ip [%s] already exist", ip);
return 1;
}
ipt = ipt->next;
}
Expand Down

0 comments on commit 052b82c

Please sign in to comment.