summaryrefslogtreecommitdiff
path: root/lib/doh.c
diff options
context:
space:
mode:
authorLucas Clemente Vella <lvella@gmail.com>2021-04-24 20:04:53 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-05-20 16:58:31 +0200
commit84d2839740ca78041ac7419d9aaeac55c1e1c729 (patch)
treeaee6202a7815b0cce0e1a2b9179c3b4421e7fb9a /lib/doh.c
parentac54b10933749d4c17d9568532ff2f1ed64c119a (diff)
downloadcurl-84d2839740ca78041ac7419d9aaeac55c1e1c729.tar.gz
CURLOPT_IPRESOLVE: preventing wrong IP version from being used
In some situations, it was possible that a transfer was setup to use an specific IP version, but due do DNS caching or connection reuse, it ended up using a different IP version from requested. This commit changes the effect of CURLOPT_IPRESOLVE from simply restricting address resolution to preventing the wrong connection type being used, when choosing a connection from the pool, and to restricting what addresses could be used when establishing a new connection. It is important that all addresses versions are resolved, even if not used in that transfer in particular, because the result is cached, and could be useful for a different transfer with a different CURLOPT_IPRESOLVE setting. Closes #6853
Diffstat (limited to 'lib/doh.c')
-rw-r--r--lib/doh.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/doh.c b/lib/doh.c
index 18d7221c7..36f8cd58d 100644
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -420,17 +420,15 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
if(!dohp->headers)
goto error;
- if(conn->ip_version != CURL_IPRESOLVE_V6) {
- /* create IPv4 DOH request */
- result = dohprobe(data, &dohp->probe[DOH_PROBE_SLOT_IPADDR_V4],
- DNS_TYPE_A, hostname, data->set.str[STRING_DOH],
- data->multi, dohp->headers);
- if(result)
- goto error;
- dohp->pending++;
- }
+ /* create IPv4 DOH request */
+ result = dohprobe(data, &dohp->probe[DOH_PROBE_SLOT_IPADDR_V4],
+ DNS_TYPE_A, hostname, data->set.str[STRING_DOH],
+ data->multi, dohp->headers);
+ if(result)
+ goto error;
+ dohp->pending++;
- if(conn->ip_version != CURL_IPRESOLVE_V4) {
+ if(Curl_ipv6works(data)) {
/* create IPv6 DOH request */
result = dohprobe(data, &dohp->probe[DOH_PROBE_SLOT_IPADDR_V6],
DNS_TYPE_AAAA, hostname, data->set.str[STRING_DOH],