socks: make SOCKS5 use the CURLOPT_IPRESOLVE choice

Fixes #11949
Reported-by: Ammar Faizi
Closes #12163
This commit is contained in:
Daniel Stenberg 2023-10-20 10:20:12 +02:00
parent fc077bc786
commit 24c495a52f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -823,10 +823,19 @@ CONNECT_REQ_INIT:
/* FALLTHROUGH */
CONNECT_RESOLVED:
case CONNECT_RESOLVED: {
char dest[MAX_IPADR_LEN] = "unknown"; /* printable address */
char dest[MAX_IPADR_LEN]; /* printable address */
struct Curl_addrinfo *hp = NULL;
if(dns)
hp = dns->addr;
#ifdef ENABLE_IPV6
if(data->set.ipver != CURL_IPRESOLVE_WHATEVER) {
int wanted_family = data->set.ipver == CURL_IPRESOLVE_V4 ?
AF_INET : AF_INET6;
/* scan for the first proper address */
while(hp && (hp->ai_family != wanted_family))
hp = hp->ai_next;
}
#endif
if(!hp) {
failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
sx->hostname);