shared: update nix to 0.24
parent
55671ec80a
commit
c9dbeefaaa
|
@ -661,12 +661,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.23.1"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
|
||||
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset",
|
||||
|
|
|
@ -31,4 +31,4 @@ netlink-packet-route = "0.13"
|
|||
netlink-request = { path = "../netlink-request" }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
nix = "0.23"
|
||||
nix = "0.24"
|
||||
|
|
|
@ -76,7 +76,9 @@ pub fn chmod(file: &File, new_mode: u32) -> Result<bool, io::Error> {
|
|||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn _get_local_addrs() -> Result<impl Iterator<Item = std::net::IpAddr>, io::Error> {
|
||||
use nix::{net::if_::InterfaceFlags, sys::socket::SockAddr};
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use nix::net::if_::InterfaceFlags;
|
||||
|
||||
let addrs = nix::ifaddrs::getifaddrs()?
|
||||
.filter(|addr| {
|
||||
|
@ -87,9 +89,16 @@ pub fn _get_local_addrs() -> Result<impl Iterator<Item = std::net::IpAddr>, io::
|
|||
| InterfaceFlags::IFF_PROMISC,
|
||||
)
|
||||
})
|
||||
.filter_map(|addr| match addr.address {
|
||||
Some(SockAddr::Inet(addr)) => Some(addr.to_std().ip()),
|
||||
_ => None,
|
||||
.filter_map(|interface_addr| {
|
||||
interface_addr.address.and_then(|addr| {
|
||||
if let Some(sockaddr_in) = addr.as_sockaddr_in() {
|
||||
Some(IpAddr::V4(Ipv4Addr::from(sockaddr_in.ip())))
|
||||
} else if let Some(sockaddr_in6) = addr.as_sockaddr_in6() {
|
||||
Some(IpAddr::V6(sockaddr_in6.ip()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Ok(addrs)
|
||||
|
|
Loading…
Reference in New Issue