Skip to content

Commit

Permalink
minor: optimizing annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang committed Jan 4, 2025
1 parent 6e674ae commit a615cd3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async fn run_app(
let mut addrs = Vec::new();
// if multiple is set, get multiple IP addresses for each target
if targets.len() == 1 && multiple > 0 {
// 使用get_host_ipaddrs获取多个IP
// get multiple IP addresses for the target
addrs = network::get_multiple_host_ipaddr(&targets[0], force_ipv6, multiple as usize)?;
} else {
// get IP address for each target
Expand Down
4 changes: 2 additions & 2 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::ip_data::IpData;
// get host ip address default to ipv4
pub(crate) fn resolve_host_ips(host: &str, force_ipv6: bool) -> Result<Vec<IpAddr>, Box<dyn Error>> {

// 获取所有IP地址
// get ip address
let ipaddr: Vec<_> = (host, 80)
.to_socket_addrs()
.with_context(|| format!("failed to resolve host: {}", host))?
Expand All @@ -20,7 +20,7 @@ pub(crate) fn resolve_host_ips(host: &str, force_ipv6: bool) -> Result<Vec<IpAdd
return Err(anyhow!("Could not resolve host: {}", host).into());
}

// 根据 force_ipv6 过滤 IP 地址
// filter ipv4 or ipv6
let filtered_ips:Vec<IpAddr> = if force_ipv6 {
ipaddr.into_iter()
.filter(|ip| matches!(ip, IpAddr::V6(_)))
Expand Down

0 comments on commit a615cd3

Please sign in to comment.