[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 84/151: curl_setup: disable IPv6 resolver without `getaddrinfo`
From: |
gnunet |
Subject: |
[gnurl] 84/151: curl_setup: disable IPv6 resolver without `getaddrinfo` |
Date: |
Fri, 20 Dec 2019 14:26:33 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 67a08dca27a6a07b36c7f97252e284ca957ff1a5
Author: Marcel Raad <address@hidden>
AuthorDate: Tue Nov 26 15:06:31 2019 +0100
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/asyn-thread.c | 14 ++++++++++++--
lib/curl_setup.h | 2 +-
lib/hostip4.c | 10 ++++++++++
tests/server/resolve.c | 6 +++---
4 files changed, 26 insertions(+), 6 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
diff --git a/lib/curl_setup.h b/lib/curl_setup.h
index cc36e28ec..5d6e8d6f7 100644
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -585,7 +585,7 @@
# define CURLRES_SYNCH
#endif
-#ifdef ENABLE_IPV6
+#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
# define CURLRES_IPV6
#else
# define CURLRES_IPV4
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);
diff --git a/tests/server/resolve.c b/tests/server/resolve.c
index 4cbdba6ec..993e03125 100644
--- a/tests/server/resolve.c
+++ b/tests/server/resolve.c
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
printf("resolve IPv4%s\n",
-#ifdef ENABLE_IPV6
+#if defined(CURLRES_IPV6)
"/IPv6"
#else
""
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
puts("Usage: resolve [option] <host>\n"
" --version\n"
" --ipv4"
-#ifdef ENABLE_IPV6
+#if defined(CURLRES_IPV6)
"\n --ipv6"
#endif
);
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
atexit(win32_cleanup);
#endif
-#ifdef ENABLE_IPV6
+#if defined(CURLRES_IPV6)
if(use_ipv6) {
/* Check that the system has IPv6 enabled before checking the resolver */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 95/151: RELEASE-NOTES: synced, (continued)
- [gnurl] 95/151: RELEASE-NOTES: synced, gnunet, 2019/12/20
- [gnurl] 104/151: tests: use \r\n for log messages in WSL, gnunet, 2019/12/20
- [gnurl] 88/151: azure: add more builds, gnunet, 2019/12/20
- [gnurl] 93/151: setopt: Fix ALPN / NPN user option when built without HTTP2, gnunet, 2019/12/20
- [gnurl] 100/151: conncache: fix multi-thread use of shared connection cache, gnunet, 2019/12/20
- [gnurl] 111/151: vtls: make BearSSL possible to set with CURL_SSL_BACKEND, gnunet, 2019/12/20
- [gnurl] 109/151: travis: remove "coverage", make it "torture", gnunet, 2019/12/20
- [gnurl] 77/151: azure-pipelines: fix the test script, gnunet, 2019/12/20
- [gnurl] 73/151: build: Disable Visual Studio warning "conditional expression is constant", gnunet, 2019/12/20
- [gnurl] 79/151: OPENSOCKETFUNCTION.3: correct the purpose description, gnunet, 2019/12/20
- [gnurl] 84/151: curl_setup: disable IPv6 resolver without `getaddrinfo`,
gnunet <=
- [gnurl] 80/151: curl: show better error message when no homedir is found, gnunet, 2019/12/20
- [gnurl] 83/151: github action/azure pipeline: run 'make test-nonflaky' for tests, gnunet, 2019/12/20
- [gnurl] 82/151: openssl: CURLSSLOPT_NO_PARTIALCHAIN can disable partial cert chains, gnunet, 2019/12/20
- [gnurl] 85/151: configure: enable IPv6 support without `getaddrinfo`, gnunet, 2019/12/20
- [gnurl] 87/151: CURLOPT_VERBOSE.3: see also ERRORBUFFER, gnunet, 2019/12/20
- [gnurl] 98/151: curl: make the etag load logic work without fseek, gnunet, 2019/12/20
- [gnurl] 103/151: winbuild: Define CARES_STATICLIB when WITH_CARES=static, gnunet, 2019/12/20
- [gnurl] 90/151: test342: make it return a 304 as the tag matches, gnunet, 2019/12/20
- [gnurl] 99/151: azure: add a vanilla macos build, gnunet, 2019/12/20
- [gnurl] 105/151: tests: fix permissions of ssh keys in WSL, gnunet, 2019/12/20