[GH-ISSUE #563] check_addrs for error #335

Closed
opened 2026-04-08 16:52:07 +03:00 by zhus · 1 comment
Owner

Originally created by @ByteXiaoTang on GitHub (Mar 31, 2025).
Original GitHub issue: https://github.com/sigoden/dufs/issues/563

fn check_addrs(args: &Args) -> Result<(Vec, Vec)> {
let mut new_addrs = vec![];
let mut print_addrs = vec![];
let (ipv4_addrs, ipv6_addrs) = interface_addrs()?;
for bind_addr in args.addrs.iter() {
match bind_addr {
BindAddr::IpAddr(ip) => match &ip {
IpAddr::V4() => {
if !ipv4_addrs.is_empty() {
new_addrs.push(bind_addr.clone());
if ip.is_unspecified() {
print_addrs.extend(ipv4_addrs.clone());
} else {
print_addrs.push(bind_addr.clone());
}
}
}
IpAddr::V6(
) => {
if !ipv6_addrs.is_empty() {
new_addrs.push(bind_addr.clone());
if ip.is_unspecified() {
print_addrs.extend(ipv6_addrs.clone());
} else {
print_addrs.push(bind_addr.clone())
}
}
}
},
#[cfg(unix)]
_ => {
new_addrs.push(bind_addr.clone());
print_addrs.push(bind_addr.clone())
}
}
}
print_addrs.sort_unstable();
Ok((new_addrs, print_addrs))
} this code will print_addrs.extend(ipv4_addrs.clone()); not remove the same addr, when args.addrs.iter() has many

Originally created by @ByteXiaoTang on GitHub (Mar 31, 2025). Original GitHub issue: https://github.com/sigoden/dufs/issues/563 fn check_addrs(args: &Args) -> Result<(Vec<BindAddr>, Vec<BindAddr>)> { let mut new_addrs = vec![]; let mut print_addrs = vec![]; let (ipv4_addrs, ipv6_addrs) = interface_addrs()?; for bind_addr in args.addrs.iter() { match bind_addr { BindAddr::IpAddr(ip) => match &ip { IpAddr::V4(_) => { if !ipv4_addrs.is_empty() { new_addrs.push(bind_addr.clone()); if ip.is_unspecified() { print_addrs.extend(ipv4_addrs.clone()); } else { print_addrs.push(bind_addr.clone()); } } } IpAddr::V6(_) => { if !ipv6_addrs.is_empty() { new_addrs.push(bind_addr.clone()); if ip.is_unspecified() { print_addrs.extend(ipv6_addrs.clone()); } else { print_addrs.push(bind_addr.clone()) } } } }, #[cfg(unix)] _ => { new_addrs.push(bind_addr.clone()); print_addrs.push(bind_addr.clone()) } } } print_addrs.sort_unstable(); Ok((new_addrs, print_addrs)) } this code will print_addrs.extend(ipv4_addrs.clone()); not remove the same addr, when args.addrs.iter() has many
zhus closed this issue 2026-04-08 16:52:07 +03:00
Author
Owner

@sigoden commented on GitHub (Mar 31, 2025):

@ByteXiaoTang

Just tell me how to reproduce the bug you mentioned.

<!-- gh-comment-id:2766020939 --> @sigoden commented on GitHub (Mar 31, 2025): @ByteXiaoTang Just tell me how to reproduce the bug you mentioned.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#335