1diff --git a/include/curl/curl.h b/include/curl/curl.h 2index 090a0acfe..63af4c932 100644 3--- a/include/curl/curl.h 4+++ b/include/curl/curl.h 5@@ -395,6 +395,12 @@ typedef int (*curl_seek_callback)(void *instream, 6 #define CURL_MAX_CERT_NUM 4 7 #define CURL_MAX_IP_LENGTH INET6_ADDRSTRLEN 8 #define CURL_MAX_CONNECTED_IP_NUM 8 9+typedef enum { 10+ DNS_STATUS_GET_INIT, 11+ DNS_STATUS_GET_IP, 12+ DNS_STATUS_GET_CNAME, 13+ DNS_STATUS_GET_INVALID, 14+} dns_status_type; 15 #endif 16 /* This is a return code for the read callback that, when returned, will 17 signal libcurl to pause sending data on the current transfer. */ 18@@ -3014,6 +3020,7 @@ typedef enum { 19 CURLINFO_CONNECTED_IP = CURLINFO_STRING + 1022, 20 CURLINFO_CONNECTED_PORT = CURLINFO_P_UINT16 + 1023, 21 CURLINFO_CONNECTED_IP_NUM = CURLINFO_LONG + 1024, 22+ CURLINFO_DNS_STATUS = CURLINFO_LONG + 1025, 23 #endif 24 CURLINFO_LASTONE = 66 25 } CURLINFO; 26diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c 27index 8fed61760..d4fe0ac44 100644 28--- a/lib/asyn-ares.c 29+++ b/lib/asyn-ares.c 30@@ -745,6 +745,17 @@ static void addrinfo_cb(void *arg, int status, int timeouts, 31 struct Curl_easy *data = (struct Curl_easy *)arg; 32 struct thread_data *res = data->state.async.tdata; 33 (void)timeouts; 34+ if (result) { 35+ if (result->nodes) { 36+ data->dns_status = DNS_STATUS_GET_IP; 37+ } else if (result->cnames) { 38+ data->dns_status = DNS_STATUS_GET_CNAME; 39+ } else { 40+ data->dns_status = DNS_STATUS_GET_INVALID; 41+ } 42+ } else { 43+ data->dns_status = DNS_STATUS_GET_INVALID; 44+ } 45 if(ARES_SUCCESS == status) { 46 res->temp_ai = ares2addr(result->nodes); 47 res->last_status = CURL_ASYNC_SUCCESS; 48diff --git a/lib/easy.c b/lib/easy.c 49index 78a8af099..220467e22 100644 50--- a/lib/easy.c 51+++ b/lib/easy.c 52@@ -944,6 +944,8 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) 53 memset(outcurl->connected_ip, 0, sizeof(outcurl->connected_ip)); 54 memset(outcurl->connected_port, 0, sizeof(outcurl->connected_port)); 55 outcurl->connected_ip_num = 0; 56+ 57+ outcurl->dns_status = DNS_STATUS_GET_INIT; 58 #endif 59 60 /* copy all userdefined values */ 61diff --git a/lib/getinfo.c b/lib/getinfo.c 62index 3e82cdaf0..195c4d60e 100644 63--- a/lib/getinfo.c 64+++ b/lib/getinfo.c 65@@ -281,6 +281,9 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info, 66 67 switch(info) { 68 #ifdef USE_ARES 69+ case CURLINFO_DNS_STATUS: 70+ *param_longp = (long) data->dns_status; 71+ break; 72 case CURLINFO_CONNECTED_IP_NUM: 73 *param_longp = data->connected_ip_num; 74 break; 75diff --git a/lib/url.c b/lib/url.c 76index c749a1885..48121eee0 100644 77--- a/lib/url.c 78+++ b/lib/url.c 79@@ -554,6 +554,8 @@ CURLcode Curl_open(struct Curl_easy **curl) 80 memset(data->connected_ip, 0, sizeof(data->connected_ip)); 81 memset(data->connected_port, 0, sizeof(data->connected_port)); 82 data->connected_ip_num = 0; 83+ 84+ data->dns_status = DNS_STATUS_GET_INIT; 85 #endif 86 87 Curl_req_init(&data->req); 88diff --git a/lib/urldata.h b/lib/urldata.h 89index afc79e864..c9a0537dd 100644 90--- a/lib/urldata.h 91+++ b/lib/urldata.h 92@@ -2001,6 +2001,7 @@ struct Curl_easy { 93 char connected_ip[CURL_MAX_CONNECTED_IP_NUM][CURL_MAX_IP_LENGTH]; 94 uint16_t connected_port[CURL_MAX_CONNECTED_IP_NUM]; 95 long connected_ip_num; 96+ dns_status_type dns_status; 97 #endif 98 }; 99 100