• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From e833f364a869bf01db2e78b1ed8c9eec8ba9eed9 Mon Sep 17 00:00:00 2001
2From: m00557507 <m00557507@notesmail.huawei.com/>
3Date: Wed, 14 May 2025 15:46:32 +0800
4Subject: [PATCH] TicketNo:DTS2025051419413 Description: record is dns from
5 netsys cache Team:HarmonyOS Feature or Bugfix:Feature Binary Source:No
6 PrivateCode(Yes/No):No
7
8Change-Id: Id6608a58ed67c1f5efd9dc48585c676e1df12e12
9---
10 include/curl/curl.h | 1 +
11 lib/asyn-ares.c     | 4 ++++
12 lib/easy.c          | 1 +
13 lib/getinfo.c       | 3 +++
14 lib/url.c           | 1 +
15 lib/urldata.h       | 1 +
16 6 files changed, 11 insertions(+)
17
18diff --git a/include/curl/curl.h b/include/curl/curl.h
19index 459c65ace..8336cb359 100644
20--- a/include/curl/curl.h
21+++ b/include/curl/curl.h
22@@ -3022,6 +3022,7 @@ typedef enum {
23   CURLINFO_CONNECTED_PORT             = CURLINFO_P_UINT16 + 1023,
24   CURLINFO_CONNECTED_IP_NUM           = CURLINFO_LONG + 1024,
25   CURLINFO_DNS_STATUS                 = CURLINFO_LONG + 1025,
26+  CURLINFO_IS_DNS_FROM_NETSYS_CACHE   = CURLINFO_LONG + 1026,
27 #endif
28   CURLINFO_LASTONE          = 66
29 } CURLINFO;
30diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
31index e4f02962c..2f8543bb9 100644
32--- a/lib/asyn-ares.c
33+++ b/lib/asyn-ares.c
34@@ -748,6 +748,10 @@ static void addrinfo_cb(void *arg, int status, int timeouts,
35   if (result) {
36     if (result->nodes) {
37       data->dns_status = CURL_DNS_STATUS_GET_IP;
38+      // when result is read from cache, cares does not add name filed in result.
39+      if (result->name == NULL) {
40+        data->is_dns_from_netsys_cache = 1;
41+      }
42     } else if (result->cnames) {
43       data->dns_status = CURL_DNS_STATUS_GET_CNAME;
44     } else {
45diff --git a/lib/easy.c b/lib/easy.c
46index daafd624c..2125f2180 100644
47--- a/lib/easy.c
48+++ b/lib/easy.c
49@@ -946,6 +946,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
50   outcurl->connected_ip_num = 0;
51
52   outcurl->dns_status = CURL_DNS_STATUS_INIT;
53+  outcurl->is_dns_from_netsys_cache = 0;
54 #endif
55
56   /* copy all userdefined values */
57diff --git a/lib/getinfo.c b/lib/getinfo.c
58index 195c4d60e..f0f1b7b00 100644
59--- a/lib/getinfo.c
60+++ b/lib/getinfo.c
61@@ -281,6 +281,9 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
62
63   switch(info) {
64 #ifdef USE_ARES
65+  case CURLINFO_IS_DNS_FROM_NETSYS_CACHE:
66+    *param_longp = (long) data->is_dns_from_netsys_cache;
67+    break;
68   case CURLINFO_DNS_STATUS:
69     *param_longp = (long) data->dns_status;
70     break;
71diff --git a/lib/url.c b/lib/url.c
72index 6e32a3448..421da573f 100644
73--- a/lib/url.c
74+++ b/lib/url.c
75@@ -556,6 +556,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
76   data->connected_ip_num = 0;
77
78   data->dns_status = CURL_DNS_STATUS_INIT;
79+  data->is_dns_from_netsys_cache = 0;
80 #endif
81
82   Curl_req_init(&data->req);
83diff --git a/lib/urldata.h b/lib/urldata.h
84index 3fcc24e5b..6d7c0733a 100644
85--- a/lib/urldata.h
86+++ b/lib/urldata.h
87@@ -2003,6 +2003,7 @@ struct Curl_easy {
88   uint16_t connected_port[CURL_MAX_CONNECTED_IP_NUM];
89   long connected_ip_num;
90   curl_dns_status_type dns_status;
91+  long is_dns_from_netsys_cache;
92 #endif
93 };
94
95--
962.45.2.huawei.8
97
98