Skip to content

Commit

Permalink
调整错误输出
Browse files Browse the repository at this point in the history
  • Loading branch information
vnt-dev committed Apr 23, 2024
1 parent 441e374 commit 4f52d58
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions vnt/src/util/dns_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ pub fn address_choose(addrs: Vec<SocketAddr>) -> anyhow::Result<SocketAddr> {
}
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<String>) -> anyhow::Result<Vec<SocketAddr>> {
Expand Down

0 comments on commit 4f52d58

Please sign in to comment.