diff options
author | Marcel Raad <Marcel.Raad@teamviewer.com> | 2019-11-26 15:06:31 +0100 |
---|---|---|
committer | Marcel Raad <Marcel.Raad@teamviewer.com> | 2019-12-03 21:37:33 +0100 |
commit | 67a08dca27a6a07b36c7f97252e284ca957ff1a5 (patch) | |
tree | 0c7d64fa489631d4057904ce0482fd86ab56dca7 /lib/asyn-thread.c | |
parent | ab712afa8fb9d2bf7850aa8d031937ca515efa01 (diff) |
curl_setup: disable IPv6 resolver without `getaddrinfo`
Also, use `CURLRES_IPV6` only for actual DNS resolution, not for IPv6
address support. This makes it possible to connect to IPv6 literals by
setting `ENABLE_IPV6` even without `getaddrinfo` support. It also fixes
the CMake build when using the synchronous resolver without
`getaddrinfo` support.
Closes https://github.com/curl/curl/pull/4662
Diffstat (limited to 'lib/asyn-thread.c')
-rwxr-xr-x | lib/asyn-thread.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c index 8c552baa9..b08497aaa 100755 --- a/lib/asyn-thread.c +++ b/lib/asyn-thread.c @@ -698,6 +698,16 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, *waitp = 0; /* default to synchronous response */ +#ifdef ENABLE_IPV6 + { + struct in6_addr in6; + /* check if this is an IPv6 address string */ + if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0) + /* This is an IPv6 address literal */ + return Curl_ip2addr(AF_INET6, &in6, hostname, port); + } +#endif /* ENABLE_IPV6 */ + if(Curl_inet_pton(AF_INET, hostname, &in) > 0) /* This is a dotted IP address 123.123.123.123-style */ return Curl_ip2addr(AF_INET, &in, hostname, port); @@ -741,7 +751,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, /* This is a dotted IP address 123.123.123.123-style */ return Curl_ip2addr(AF_INET, &in, hostname, port); } -#ifdef CURLRES_IPV6 +#ifdef ENABLE_IPV6 { struct in6_addr in6; /* check if this is an IPv6 address string */ @@ -749,7 +759,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, /* This is an IPv6 address literal */ return Curl_ip2addr(AF_INET6, &in6, hostname, port); } -#endif /* CURLRES_IPV6 */ +#endif /* ENABLE_IPV6 */ #endif /* !USE_RESOLVE_ON_IPS */ #ifdef CURLRES_IPV6 |