From e833f364a869bf01db2e78b1ed8c9eec8ba9eed9 Mon Sep 17 00:00:00 2001
From: m00557507 <m00557507@notesmail.huawei.com/>
Date: Wed, 14 May 2025 15:46:32 +0800
Subject: [PATCH] TicketNo:DTS2025051419413 Description: record is dns from
netsys cache Team:HarmonyOS Feature or Bugfix:Feature Binary Source:No
PrivateCode(Yes/No):No
Change-Id: Id6608a58ed67c1f5efd9dc48585c676e1df12e12
include/curl/curl.h | 1 +
lib/asyn-ares.c | 4 ++++
lib/easy.c | 1 +
lib/getinfo.c | 3 +++
lib/url.c | 1 +
lib/urldata.h | 1 +
6 files changed, 11 insertions(+)
@@ -3022,6 +3022,7 @@ typedef enum {
CURLINFO_CONNECTED_PORT = CURLINFO_P_UINT16 + 1023,
CURLINFO_CONNECTED_IP_NUM = CURLINFO_LONG + 1024,
CURLINFO_DNS_STATUS = CURLINFO_LONG + 1025,
+ CURLINFO_IS_DNS_FROM_NETSYS_CACHE = CURLINFO_LONG + 1026,
#endif
CURLINFO_LASTONE = 66
} CURLINFO;
@@ -748,6 +748,10 @@ static void addrinfo_cb(void *arg, int status, int timeouts,
if (result) {
if (result->nodes) {
data->dns_status = CURL_DNS_STATUS_GET_IP;
+ // when result is read from cache, cares does not add name filed in result.
+ if (result->name == NULL) {
+ data->is_dns_from_netsys_cache = 1;
+ }
} else if (result->cnames) {
data->dns_status = CURL_DNS_STATUS_GET_CNAME;
} else {
@@ -946,6 +946,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
outcurl->connected_ip_num = 0;
outcurl->dns_status = CURL_DNS_STATUS_INIT;
+ outcurl->is_dns_from_netsys_cache = 0;
#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_IS_DNS_FROM_NETSYS_CACHE:
+ *param_longp = (long) data->is_dns_from_netsys_cache;
+ break;
case CURLINFO_DNS_STATUS:
*param_longp = (long) data->dns_status;
break;
@@ -556,6 +556,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
data->connected_ip_num = 0;
data->dns_status = CURL_DNS_STATUS_INIT;
+ data->is_dns_from_netsys_cache = 0;
#endif
Curl_req_init(&data->req);
@@ -2003,6 +2003,7 @@ struct Curl_easy {
uint16_t connected_port[CURL_MAX_CONNECTED_IP_NUM];
long connected_ip_num;
curl_dns_status_type dns_status;
+ long is_dns_from_netsys_cache;
#endif
};
--
2.45.2.huawei.8