@@ -395,6 +395,12 @@ typedef int (*curl_seek_callback)(void *instream,
#define CURL_MAX_CERT_NUM 4
#define CURL_MAX_IP_LENGTH INET6_ADDRSTRLEN
#define CURL_MAX_CONNECTED_IP_NUM 8
+typedef enum {
+ DNS_STATUS_GET_INIT,
+ DNS_STATUS_GET_IP,
+ DNS_STATUS_GET_CNAME,
+ DNS_STATUS_GET_INVALID,
+} dns_status_type;
#endif
/* This is a return code for the read callback that, when returned, will
signal libcurl to pause sending data on the current transfer. */
@@ -3014,6 +3020,7 @@ typedef enum {
CURLINFO_CONNECTED_IP = CURLINFO_STRING + 1022,
CURLINFO_CONNECTED_PORT = CURLINFO_P_UINT16 + 1023,
CURLINFO_CONNECTED_IP_NUM = CURLINFO_LONG + 1024,
+ CURLINFO_DNS_STATUS = CURLINFO_LONG + 1025,
#endif
CURLINFO_LASTONE = 66
} CURLINFO;
@@ -745,6 +745,17 @@ static void addrinfo_cb(void *arg, int status, int timeouts,
struct Curl_easy *data = (struct Curl_easy *)arg;
struct thread_data *res = data->state.async.tdata;
(void)timeouts;
+ if (result) {
+ if (result->nodes) {
+ data->dns_status = DNS_STATUS_GET_IP;
+ } else if (result->cnames) {
+ data->dns_status = DNS_STATUS_GET_CNAME;
+ } else {
+ data->dns_status = DNS_STATUS_GET_INVALID;
+ }
+ } else {
+ data->dns_status = DNS_STATUS_GET_INVALID;
+ }
if(ARES_SUCCESS == status) {
res->temp_ai = ares2addr(result->nodes);
res->last_status = CURL_ASYNC_SUCCESS;
@@ -944,6 +944,8 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
memset(outcurl->connected_ip, 0, sizeof(outcurl->connected_ip));
memset(outcurl->connected_port, 0, sizeof(outcurl->connected_port));
outcurl->connected_ip_num = 0;
+
+ outcurl->dns_status = DNS_STATUS_GET_INIT;
#endif
/* copy all userdefined values */
@@ -281,6 +281,9 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
switch(info) {
#ifdef USE_ARES
+ case CURLINFO_DNS_STATUS:
+ *param_longp = (long) data->dns_status;
+ break;
case CURLINFO_CONNECTED_IP_NUM:
*param_longp = data->connected_ip_num;
break;
@@ -554,6 +554,8 @@ CURLcode Curl_open(struct Curl_easy **curl)
memset(data->connected_ip, 0, sizeof(data->connected_ip));
memset(data->connected_port, 0, sizeof(data->connected_port));
data->connected_ip_num = 0;
+
+ data->dns_status = DNS_STATUS_GET_INIT;
#endif
Curl_req_init(&data->req);
@@ -2001,6 +2001,7 @@ struct Curl_easy {
char connected_ip[CURL_MAX_CONNECTED_IP_NUM][CURL_MAX_IP_LENGTH];
uint16_t connected_port[CURL_MAX_CONNECTED_IP_NUM];
long connected_ip_num;
+ dns_status_type dns_status;
#endif
};