aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/hostip.c20
-rw-r--r--lib/urldata.h2
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 3f465a0d0..1a881cf9b 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -653,7 +653,7 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
struct addrinfo hints, *res;
int error;
char sbuf[NI_MAXSERV];
- int s, pf = PF_UNSPEC;
+ int s, pf;
struct SessionHandle *data = conn->data;
*waitp=0; /* don't wait, we have the response now */
@@ -665,11 +665,27 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
pf = PF_INET;
- else
+ else {
/* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest
* possible checks. And close the socket again.
*/
sclose(s);
+
+ /*
+ * Check if a more limited name resolve has been requested.
+ */
+ switch(data->set.ip_version) {
+ case CURL_IPRESOLVE_V4:
+ pf = PF_INET;
+ break;
+ case CURL_IPRESOLVE_V6:
+ pf = PF_INET6;
+ break;
+ default:
+ pf = PF_UNSPEC;
+ break;
+ }
+ }
memset(&hints, 0, sizeof(hints));
hints.ai_family = pf;
diff --git a/lib/urldata.h b/lib/urldata.h
index 16c413d61..471049d51 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -826,6 +826,8 @@ struct UserDefined {
char *private; /* Private data */
struct curl_slist *http200aliases; /* linked list of aliases for http200 */
+
+ int ip_version;
/* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially