diff --git a/io/zenoh-links/zenoh-link-quic/src/unicast.rs b/io/zenoh-links/zenoh-link-quic/src/unicast.rs index 8d4b82c339..8dde380577 100644 --- a/io/zenoh-links/zenoh-link-quic/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-quic/src/unicast.rs @@ -387,7 +387,16 @@ async fn accept_task( } }; + // Get the right source address in case an unsepecified IP (i.e. 0.0.0.0 or [::]) is used + let src_addr = match quic_conn.local_ip() { + Some(ip) => SocketAddr::new(ip, src_addr.port()), + None => { + tracing::debug!("Can not accept QUIC connection: empty local IP"); + continue; + } + }; let dst_addr = quic_conn.remote_address(); + tracing::debug!("Accepted QUIC connection on {:?}: {:?}", src_addr, dst_addr); // Create the new link object let link = Arc::new(LinkUnicastQuic::new( diff --git a/io/zenoh-links/zenoh-link-tcp/src/unicast.rs b/io/zenoh-links/zenoh-link-tcp/src/unicast.rs index 3ef4f235ed..c07d6f15b9 100644 --- a/io/zenoh-links/zenoh-link-tcp/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-tcp/src/unicast.rs @@ -409,6 +409,15 @@ async fn accept_task( res = accept(&socket) => { match res { Ok((stream, dst_addr)) => { + // Get the right source address in case an unsepecified IP (i.e. 0.0.0.0 or [::]) is used + let src_addr = match stream.local_addr() { + Ok(sa) => sa, + Err(e) => { + tracing::debug!("Can not accept TCP connection: {}", e); + continue; + } + }; + tracing::debug!("Accepted TCP connection on {:?}: {:?}", src_addr, dst_addr); // Create the new link object let link = Arc::new(LinkUnicastTcp::new(stream, src_addr, dst_addr)); diff --git a/io/zenoh-links/zenoh-link-tls/src/unicast.rs b/io/zenoh-links/zenoh-link-tls/src/unicast.rs index b12608354e..8776e0ae40 100644 --- a/io/zenoh-links/zenoh-link-tls/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-tls/src/unicast.rs @@ -372,6 +372,15 @@ async fn accept_task( res = accept(&socket) => { match res { Ok((tcp_stream, dst_addr)) => { + // Get the right source address in case an unsepecified IP (i.e. 0.0.0.0 or [::]) is used + let src_addr = match tcp_stream.local_addr() { + Ok(sa) => sa, + Err(e) => { + tracing::debug!("Can not accept TLS connection: {}", e); + continue; + } + }; + // Accept the TLS connection let tls_stream = match acceptor.accept(tcp_stream).await { Ok(stream) => TlsStream::Server(stream), @@ -382,6 +391,8 @@ async fn accept_task( } }; + + tracing::debug!("Accepted TLS connection on {:?}: {:?}", src_addr, dst_addr); // Create the new link object let link = Arc::new(LinkUnicastTls::new(tls_stream, src_addr, dst_addr)); diff --git a/io/zenoh-links/zenoh-link-udp/src/unicast.rs b/io/zenoh-links/zenoh-link-udp/src/unicast.rs index 1fa9f9a7f4..fba3e23b69 100644 --- a/io/zenoh-links/zenoh-link-udp/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-udp/src/unicast.rs @@ -498,6 +498,10 @@ async fn accept_read_task( tracing::trace!("Ready to accept UDP connections on: {:?}", src_addr); + if src_addr.ip().is_unspecified() { + tracing::warn!("Interceptors (e.g. Access Control, Downsampling) are not guaranteed to work on UDP when listening on 0.0.0.0 or [::]. Their usage is discouraged. See https://github.com/eclipse-zenoh/zenoh/issues/1126."); + } + loop { // Buffers for deserialization let mut buff = zenoh_buffers::vec::uninit(UDP_MAX_MTU as usize); diff --git a/io/zenoh-links/zenoh-link-ws/src/unicast.rs b/io/zenoh-links/zenoh-link-ws/src/unicast.rs index e94e4b6868..f1aa0088f0 100644 --- a/io/zenoh-links/zenoh-link-ws/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-ws/src/unicast.rs @@ -498,6 +498,15 @@ async fn accept_task( _ = token.cancelled() => break, }; + // Get the right source address in case an unsepecified IP (i.e. 0.0.0.0 or [::]) is used + let src_addr = match stream.local_addr() { + Ok(sa) => sa, + Err(e) => { + tracing::debug!("Can not accept TCP connection: {}", e); + continue; + } + }; + tracing::debug!( "Accepted TCP (WebSocket) connection on {:?}: {:?}", src_addr,