1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-18 01:33:00 +03:00

Reduce redundant loop

Co-authored-by: Davide Beatrici <github@davidebeatrici.dev>
This commit is contained in:
Yihong Wu 2021-12-04 16:16:22 +08:00 committed by GitHub
parent 9692a8d961
commit b178f26e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -413,7 +413,6 @@ void DnsResolver(THREAD *t, void *param)
else
{
hints.ai_family = AF_INET;
hints.ai_flags = AI_ADDRCONFIG;
}
struct addrinfo *results;
@ -434,21 +433,30 @@ void DnsResolver(THREAD *t, void *param)
Copy(&resolver->IPv6, &ip, sizeof(resolver->IPv6));
resolver->IPv6.ipv6_scope_id = in->sin6_scope_id;
ipv6_ok = true;
if (ipv4_ok)
{
break;
}
}
else if (IsIP4(&ip) && ipv4_ok == false)
{
Copy(&resolver->IPv4, &ip, sizeof(resolver->IPv4));
ipv4_ok = true;
if (ipv6_ok)
{
break;
}
}
}
else
{
const struct sockaddr_in *in = (struct sockaddr_in *)result->ai_addr;
InAddrToIP(&ip, &in->sin_addr);
if (IsIP4(&ip) && ipv4_ok == false)
if (IsIP4(&ip))
{
Copy(&resolver->IPv4, &ip, sizeof(resolver->IPv4));
ipv4_ok = true;
break;
}
}
}

View File

@ -9892,7 +9892,9 @@ bool HasIPv6Address()
if ((type & IPV6_ADDR_GLOBAL_UNICAST) && ((type & IPV6_ADDR_ZERO) == 0) && ((type & IPV6_ADDR_LOOPBACK) == 0))
{
ret = true;
break;
}
}
}