Skip to content

Commit

Permalink
Fix build on non-Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Feb 5, 2024
1 parent f5944ec commit ac42487
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions aggligator-util/src/transport/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,20 +482,21 @@ pub(crate) fn bind_socket_to_interface(socket: &TcpSocket, interface: &[u8], rem
{
for ifn in local_interfaces()? {
if ifn.name.as_bytes() == interface {
let Some(addr) = ifn.addr else { continue };
match (addr.ip(), remote) {
(IpAddr::V4(_), IpAddr::V4(_)) => (),
(IpAddr::V6(_), IpAddr::V6(_)) => (),
_ => continue,
for addr in ifn.addr {
match (addr.ip(), remote) {
(IpAddr::V4(_), IpAddr::V4(_)) => (),
(IpAddr::V6(_), IpAddr::V6(_)) => (),
_ => continue,
}

if addr.ip().is_loopback() != remote.is_loopback() {
continue;
}

tracing::debug!("binding to {addr:?} on interface {}", &ifn.name);
socket.bind(SocketAddr::new(addr.ip(), 0))?;
return Ok(());
}

if addr.ip().is_loopback() != remote.is_loopback() {
continue;
}

tracing::debug!("binding to {addr:?} on interface {}", &ifn.name);
socket.bind(SocketAddr::new(addr.ip(), 0))?;
return Ok(());
}
}

Expand Down

0 comments on commit ac42487

Please sign in to comment.