mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
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
This commit is contained in:
parent
ab712afa8f
commit
67a08dca27
@ -698,6 +698,16 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
|||||||
|
|
||||||
*waitp = 0; /* default to synchronous response */
|
*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)
|
if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
|
||||||
/* This is a dotted IP address 123.123.123.123-style */
|
/* This is a dotted IP address 123.123.123.123-style */
|
||||||
return Curl_ip2addr(AF_INET, &in, hostname, port);
|
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 */
|
/* This is a dotted IP address 123.123.123.123-style */
|
||||||
return Curl_ip2addr(AF_INET, &in, hostname, port);
|
return Curl_ip2addr(AF_INET, &in, hostname, port);
|
||||||
}
|
}
|
||||||
#ifdef CURLRES_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
{
|
{
|
||||||
struct in6_addr in6;
|
struct in6_addr in6;
|
||||||
/* check if this is an IPv6 address string */
|
/* 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 */
|
/* This is an IPv6 address literal */
|
||||||
return Curl_ip2addr(AF_INET6, &in6, hostname, port);
|
return Curl_ip2addr(AF_INET6, &in6, hostname, port);
|
||||||
}
|
}
|
||||||
#endif /* CURLRES_IPV6 */
|
#endif /* ENABLE_IPV6 */
|
||||||
#endif /* !USE_RESOLVE_ON_IPS */
|
#endif /* !USE_RESOLVE_ON_IPS */
|
||||||
|
|
||||||
#ifdef CURLRES_IPV6
|
#ifdef CURLRES_IPV6
|
||||||
|
@ -585,7 +585,7 @@
|
|||||||
# define CURLRES_SYNCH
|
# define CURLRES_SYNCH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
|
||||||
# define CURLRES_IPV6
|
# define CURLRES_IPV6
|
||||||
#else
|
#else
|
||||||
# define CURLRES_IPV4
|
# define CURLRES_IPV4
|
||||||
|
@ -131,6 +131,16 @@ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
struct hostent *buf = NULL;
|
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)
|
if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
|
||||||
/* This is a dotted IP address 123.123.123.123-style */
|
/* This is a dotted IP address 123.123.123.123-style */
|
||||||
return Curl_ip2addr(AF_INET, &in, hostname, port);
|
return Curl_ip2addr(AF_INET, &in, hostname, port);
|
||||||
|
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
|||||||
while(argc>arg) {
|
while(argc>arg) {
|
||||||
if(!strcmp("--version", argv[arg])) {
|
if(!strcmp("--version", argv[arg])) {
|
||||||
printf("resolve IPv4%s\n",
|
printf("resolve IPv4%s\n",
|
||||||
#ifdef ENABLE_IPV6
|
#if defined(CURLRES_IPV6)
|
||||||
"/IPv6"
|
"/IPv6"
|
||||||
#else
|
#else
|
||||||
""
|
""
|
||||||
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
|||||||
puts("Usage: resolve [option] <host>\n"
|
puts("Usage: resolve [option] <host>\n"
|
||||||
" --version\n"
|
" --version\n"
|
||||||
" --ipv4"
|
" --ipv4"
|
||||||
#ifdef ENABLE_IPV6
|
#if defined(CURLRES_IPV6)
|
||||||
"\n --ipv6"
|
"\n --ipv6"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
|||||||
atexit(win32_cleanup);
|
atexit(win32_cleanup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#if defined(CURLRES_IPV6)
|
||||||
if(use_ipv6) {
|
if(use_ipv6) {
|
||||||
/* Check that the system has IPv6 enabled before checking the resolver */
|
/* Check that the system has IPv6 enabled before checking the resolver */
|
||||||
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user