Skip to content

Commit

Permalink
Fix the permission denied while binding to None interface on some pla…
Browse files Browse the repository at this point in the history
…tforms
  • Loading branch information
YuanYuYuan committed Mar 14, 2024
1 parent 91e0f9e commit d095704
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions commons/zenoh-util/src/std_only/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,17 @@ pub fn get_ipv6_ipaddrs(interface: Option<&str>) -> Vec<IpAddr> {

#[cfg(target_os = "linux")]
pub fn set_bind_to_device_tcp_socket(socket: &TcpSocket, iface: Option<&str>) -> ZResult<()> {
socket.bind_device(iface.map(|x| x.as_bytes()))?;
if let Some(iface) = iface {
socket.bind_device(Some(iface.as_bytes()))?;
}
Ok(())
}

#[cfg(target_os = "linux")]
pub fn set_bind_to_device_udp_socket(socket: &UdpSocket, iface: Option<&str>) -> ZResult<()> {
socket.bind_device(iface.map(|x| x.as_bytes()))?;
if let Some(iface) = iface {
socket.bind_device(Some(iface.as_bytes()))?;
}
Ok(())
}

Expand Down

0 comments on commit d095704

Please sign in to comment.