From 3e160f00aa5f1e7fc492aaaddeb2c33798803311 Mon Sep 17 00:00:00 2001 From: XieHan Date: Tue, 17 Aug 2021 14:11:43 +0800 Subject: [PATCH 1/3] Fix problem when resolv.conf doesn't contain any nameserver. --- src/manager/WFGlobal.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/manager/WFGlobal.cc b/src/manager/WFGlobal.cc index 9f4d2ff4..22882790 100644 --- a/src/manager/WFGlobal.cc +++ b/src/manager/WFGlobal.cc @@ -690,17 +690,17 @@ private: std::string url; std::string search; - if (__parse_resolv_conf(path, url, search, &ndots, &attempts, - &rotate) >= 0) - { - client = new WFDnsClient; - if (client->init(url, search, ndots, attempts, rotate) >= 0) - return; + __parse_resolv_conf(path, url, search, &ndots, &attempts, + &rotate); + if (url.size() == 0) + url = "8.8.8.8"; - delete client; - client = NULL; - } + client = new WFDnsClient; + if (client->init(url, search, ndots, attempts, rotate) >= 0) + return; + delete client; + client = NULL; abort(); } } From bcf1317ed9f6d7ac25bbf4e993c71fa12e89da9c Mon Sep 17 00:00:00 2001 From: XieHan Date: Tue, 17 Aug 2021 14:16:36 +0800 Subject: [PATCH 2/3] fix format --- src/manager/WFGlobal.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/manager/WFGlobal.cc b/src/manager/WFGlobal.cc index 22882790..f6a4e3dd 100644 --- a/src/manager/WFGlobal.cc +++ b/src/manager/WFGlobal.cc @@ -690,8 +690,7 @@ private: std::string url; std::string search; - __parse_resolv_conf(path, url, search, &ndots, &attempts, - &rotate); + __parse_resolv_conf(path, url, search, &ndots, &attempts, &rotate); if (url.size() == 0) url = "8.8.8.8"; From 02c65e6934d05649e363f61db270381217c5d7b9 Mon Sep 17 00:00:00 2001 From: XieHan Date: Tue, 17 Aug 2021 14:17:47 +0800 Subject: [PATCH 3/3] remove abort() --- src/manager/WFGlobal.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/manager/WFGlobal.cc b/src/manager/WFGlobal.cc index f6a4e3dd..6a15adcb 100644 --- a/src/manager/WFGlobal.cc +++ b/src/manager/WFGlobal.cc @@ -700,7 +700,6 @@ private: delete client; client = NULL; - abort(); } }