curl-library
Prepopulate DNS cache with IPv6 and IPv4 address
Date: Wed, 13 Jan 2016 09:05:02 +0100
Hello,
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.
Programm:
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <fcntl.h>
static CURLcode
prepoulate_dns_cache(CURL *curl)
{
struct curl_slist *host = NULL;
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");
return curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
}
int
main(int argc, char **argv)
{
CURL *curl = NULL;
char *errbuf;
errbuf = malloc(CURL_ERROR_SIZE);
if (errbuf == NULL)
exit(1);
curl = curl_easy_init();
if (! curl) {
exit(1);
}
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
prepoulate_dns_cache(curl);
curl_easy_setopt(curl, CURLOPT_URL, "https://gmvl.de/");
curl_easy_perform(curl);
return 0;
}
C:\Users\carbon\Desktop>test
* Added gmvl.de:443:2a01:4f8:b0:2fff::2 to DNS cache
* Added gmvl.de:443:88.198.249.254 to DNS cache
* timeout on name lookup is not supported
* Hostname gmvl.de was found in DNS cache
* Trying 2a01:4f8:b0:2fff::2...
* connect to 2a01:4f8:b0:2fff::2 port 443 failed: Network unreachable
* Failed to connect to gmvl.de port 443: Network unreachable
* Closing connection 0
Cheers,
Thomas
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2016-01-13