#ifdef CURLRES_IPV6
if(Curl_ipv6works(data))
/* The stack seems to be IPv6-enabled */
- pf = PF_UNSPEC;
+ if(data->conn->ip_version != CURL_IPRESOLVE_V4)
+ pf = PF_UNSPEC;
#endif /* CURLRES_IPV6 */
hints.ai_family = pf;
hints.ai_socktype = (data->conn->transport == TRNSPRT_TCP)?
#else
#ifdef HAVE_CARES_IPV6
- if(Curl_ipv6works(data)) {
+ if(Curl_ipv6works(data) && data->conn->ip_version != CURL_IPRESOLVE_V4) {
/* The stack seems to be IPv6-enabled */
res->num_pending = 2;
*waitp = 0; /* default to synchronous response */
#ifdef CURLRES_IPV6
- if(Curl_ipv6works(data))
+ if(Curl_ipv6works(data) && data->conn->ip_version != CURL_IPRESOLVE_V4)
/* The stack seems to be IPv6-enabled */
pf = PF_UNSPEC;
#endif /* CURLRES_IPV6 */
goto error;
dohp->pending++;
- if(Curl_ipv6works(data)) {
+ if(Curl_ipv6works(data) && conn->ip_version != CURL_IPRESOLVE_V4) {
/* create IPv6 DoH request */
result = dohprobe(data, &dohp->probe[DOH_PROBE_SLOT_IPADDR_V6],
DNS_TYPE_AAAA, hostname, data->set.str[STRING_DOH],
}
}
+ /* See if the returned entry matches the required resolve mode */
+ if(dns && data->conn->ip_version != CURL_IPRESOLVE_WHATEVER) {
+ int pf = PF_INET;
+ bool found = false;
+ struct Curl_addrinfo *addr = dns->addr;
+
+ if(data->conn->ip_version == CURL_IPRESOLVE_V6)
+ pf = PF_INET6;
+
+ while(addr) {
+ if(addr->ai_family == pf) {
+ found = true;
+ break;
+ }
+ addr = addr->ai_next;
+ }
+
+ if(!found) {
+ infof(data, "Hostname in DNS cache doesn't have needed family, zapped");
+ dns = NULL; /* the memory deallocation is being handled by the hash */
+ Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
+ }
+ }
return dns;
}
*waitp = 0; /* synchronous response only */
- if(Curl_ipv6works(data))
+ if(Curl_ipv6works(data) && data->conn->ip_version != CURL_IPRESOLVE_V4)
/* The stack seems to be IPv6-enabled */
pf = PF_UNSPEC;