From 7a0880fc02adc53772e792f9faf06a4933f78743 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Wed, 8 Dec 2021 21:40:03 -0600 Subject: [PATCH] do it similar on the client --- src/client.rs | 18 ++++++++++++------ src/server.rs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/client.rs b/src/client.rs index 6e0c39b..4fa34fb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -9,23 +9,29 @@ pub async fn client > (mut args: I) -> Result <(), Ap use rand::RngCore; let common_params = app_common::Params::default (); - let mut bind_addr = "0.0.0.0".to_string (); + let mut bind_addrs = vec! []; while let Some (arg) = args.next () { match arg.as_str () { "--bind-addr" => { - bind_addr = match args.next () { + bind_addrs.push (match args.next () { None => return Err (CliArgError::MissingArgumentValue (arg).into ()), - Some (x) => x - }; + Some (x) => Ipv4Addr::from_str (&x)? + }); }, _ => return Err (CliArgError::UnrecognizedArgument (arg).into ()), } } - let socket = UdpSocket::bind (&format! ("{}:0", bind_addr)).await?; + if bind_addrs.is_empty () { + bind_addrs = get_ips ()?; + } - socket.join_multicast_v4 (common_params.multicast_addr, Ipv4Addr::from_str (&bind_addr)?)?; + let socket = UdpSocket::bind (SocketAddrV4::new (Ipv4Addr::UNSPECIFIED, 0)).await?; + + for bind_addr in bind_addrs { + socket.join_multicast_v4 (common_params.multicast_addr, bind_addr)?; + } let mut idem_id = [0u8; 8]; rand::thread_rng ().fill_bytes (&mut idem_id); diff --git a/src/server.rs b/src/server.rs index 261a593..e8baab6 100644 --- a/src/server.rs +++ b/src/server.rs @@ -53,7 +53,7 @@ fn configure > (mut args: I) -> Result