Skip to content

Commit

Permalink
fixup: simplify link-local addr check
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Sep 11, 2023
1 parent d292d8d commit ca0ce5b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions talpid-routing/src/unix/macos/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ fn is_active_interface(interface_name: &str, family: Family) -> io::Result<bool>
.find(|addr| {
if let Some(addr) = addr.address {
// Check if family matches; ignore if link-local address
match addr.family() {
Some(AddressFamily::Inet) => family == Family::V4 && matches!(addr.as_sockaddr_in(), Some(ref addr_in) if is_routable_v4(&Ipv4Addr::from(addr_in.ip()))),
Some(AddressFamily::Inet6) => {
family == Family::V6 &&
match family {
Family::V4 => matches!(addr.as_sockaddr_in(), Some(ref addr_in) if is_routable_v4(&Ipv4Addr::from(addr_in.ip()))),
Family::V6 => {
matches!(addr.as_sockaddr_in6(), Some(ref addr_in) if is_routable_v6(&addr_in.ip()))
}
_ => false,
Expand Down

0 comments on commit ca0ce5b

Please sign in to comment.