From 67a08dca27a6a07b36c7f97252e284ca957ff1a5 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Tue, 26 Nov 2019 15:06:31 +0100 Subject: 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 --- lib/hostip4.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/hostip4.c') diff --git a/lib/hostip4.c b/lib/hostip4.c index e6ba710d8..750e0dd5a 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -131,6 +131,16 @@ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, struct in_addr in; struct hostent *buf = NULL; +#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); -- cgit v1.2.3