mirror of
https://github.com/openharmony/third_party_curl.git
synced 2026-08-24 09:22:56 -04:00
458cf2dd4c
Signed-off-by: maosiping <maosiping@huawei.com>
100 lines
3.3 KiB
Diff
100 lines
3.3 KiB
Diff
diff --git a/include/curl/curl.h b/include/curl/curl.h
|
|
index 090a0acfe..63af4c932 100644
|
|
--- a/include/curl/curl.h
|
|
+++ b/include/curl/curl.h
|
|
@@ -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;
|
|
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
|
|
index 8fed61760..d4fe0ac44 100644
|
|
--- a/lib/asyn-ares.c
|
|
+++ b/lib/asyn-ares.c
|
|
@@ -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;
|
|
diff --git a/lib/easy.c b/lib/easy.c
|
|
index 78a8af099..220467e22 100644
|
|
--- a/lib/easy.c
|
|
+++ b/lib/easy.c
|
|
@@ -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 */
|
|
diff --git a/lib/getinfo.c b/lib/getinfo.c
|
|
index 3e82cdaf0..195c4d60e 100644
|
|
--- a/lib/getinfo.c
|
|
+++ b/lib/getinfo.c
|
|
@@ -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;
|
|
diff --git a/lib/url.c b/lib/url.c
|
|
index c749a1885..48121eee0 100644
|
|
--- a/lib/url.c
|
|
+++ b/lib/url.c
|
|
@@ -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);
|
|
diff --git a/lib/urldata.h b/lib/urldata.h
|
|
index afc79e864..c9a0537dd 100644
|
|
--- a/lib/urldata.h
|
|
+++ b/lib/urldata.h
|
|
@@ -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
|
|
};
|
|
|