From 4f52d58d6edcc750ae1d9f297765432bbc02761b Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Tue, 23 Apr 2024 14:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=94=99=E8=AF=AF=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/src/util/dns_query.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/vnt/src/util/dns_query.rs b/vnt/src/util/dns_query.rs index d6941d7..2be1a07 100644 --- a/vnt/src/util/dns_query.rs +++ b/vnt/src/util/dns_query.rs @@ -26,10 +26,19 @@ pub fn address_choose(addrs: Vec) -> anyhow::Result { } Err(anyhow::anyhow!("Unable to connect to address {:?}", addrs)) }; - if let Ok(addr) = check_addr(&v6) { - return Ok(addr); + if v6.is_empty() { + return check_addr(&v4); + } + if v4.is_empty() { + return check_addr(&v6); + } + match check_addr(&v6) { + Ok(addr) => Ok(addr), + Err(e1) => match check_addr(&v4) { + Ok(addr) => Ok(addr), + Err(e2) => Err(anyhow::anyhow!("{} , {}", e1, e2)), + }, } - check_addr(&v4) } pub fn dns_query_all(domain: &str, name_servers: Vec) -> anyhow::Result> {