cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Prepopulate DNS cache with IPv6 and IPv4 address

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 13 Jan 2016 10:18:34 +0100 (CET)

On Wed, 13 Jan 2016, Thomas Glanzmann wrote:

> I would like to prepopulate the DNS cache with a IPv6 (preferred) and a IPv4
> address. When I try to do the same it works perfectly if the host is dual
> stack, but not if it is IPv4 only. How was the usage for such a scenario
> intended? I assumed that it would even try IPv4 if no IPv6 is available.

I can see that it isn't sufficiently documented, and quite frankly I think we
didn't really implement it for that kind of (still sensible) use case. The
(my) thinking was more to make a better version of using the IP in the URL and
providing your own Host: header.

The CURLOPT_RESOLVE feature is actually simpler than so. It stores a *single*
address for a given host+port combo, and it will not overwrite an existing
entry. So in your case:

     host = curl_slist_append(host, "gmvl.de:443:2a01:4f8:b0:2fff::2");
     host = curl_slist_append(host, "gmvl.de:443:88.198.249.254");

libcurl will only store the first address and not the second one, which then
will have it attempt to use the IPv6 address when gmvl.de:443 is used.

There have been work in the past to make it support multiple addresses per
host+port pair, and I think it would be a great addition.

Separately from that, I don't think we deal with the situation where you
populate the cache with an IPv6 adress for a library that otherwise can't use
IPv6 as it cannot otherwise put such an address in there. This is another
issue we should address somehow, at the very least by documenting it.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2016-01-13