From f7e21cfb2d99d24ff1d5d432b18273536baa0c0b Mon Sep 17 00:00:00 2001 From: maosiping Date: Wed, 14 May 2025 15:52:41 +0800 Subject: [PATCH] add judge dns from netsys patch Signed-off-by: maosiping --- 0005-JudgeIsDnsFromNetsysCache.patch | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 0005-JudgeIsDnsFromNetsysCache.patch diff --git a/0005-JudgeIsDnsFromNetsysCache.patch b/0005-JudgeIsDnsFromNetsysCache.patch new file mode 100644 index 000000000..9903a4880 --- /dev/null +++ b/0005-JudgeIsDnsFromNetsysCache.patch @@ -0,0 +1,97 @@ +From e833f364a869bf01db2e78b1ed8c9eec8ba9eed9 Mon Sep 17 00:00:00 2001 +From: m00557507 +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(+) + +diff --git a/include/curl/curl.h b/include/curl/curl.h +index 459c65ace..8336cb359 100644 +--- a/include/curl/curl.h ++++ b/include/curl/curl.h +@@ -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; +diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c +index e4f02962c..2f8543bb9 100644 +--- a/lib/asyn-ares.c ++++ b/lib/asyn-ares.c +@@ -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 { +diff --git a/lib/easy.c b/lib/easy.c +index daafd624c..2125f2180 100644 +--- a/lib/easy.c ++++ b/lib/easy.c +@@ -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 */ +diff --git a/lib/getinfo.c b/lib/getinfo.c +index 195c4d60e..f0f1b7b00 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_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; +diff --git a/lib/url.c b/lib/url.c +index 6e32a3448..421da573f 100644 +--- a/lib/url.c ++++ b/lib/url.c +@@ -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); +diff --git a/lib/urldata.h b/lib/urldata.h +index 3fcc24e5b..6d7c0733a 100644 +--- a/lib/urldata.h ++++ b/lib/urldata.h +@@ -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 + -- Gitee