From a6f0e5294a3ff0661e9a8db53b76521ec0b16ba9 Mon Sep 17 00:00:00 2001 From: Peter Jankuliak Date: Mon, 20 Jan 2025 08:49:40 +0100 Subject: [PATCH] Debug output --- Cargo.lock | 1 + utils/local-discovery/Cargo.toml | 1 + utils/local-discovery/src/local-discovery.rs | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71ac045a..3fe88ed2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2941,6 +2941,7 @@ name = "ouisync-local-discovery" version = "0.8.10" dependencies = [ "async-trait", + "chrono", "env_logger", "futures-util", "hex", diff --git a/utils/local-discovery/Cargo.toml b/utils/local-discovery/Cargo.toml index 0d98ba7e..c83dd5bc 100644 --- a/utils/local-discovery/Cargo.toml +++ b/utils/local-discovery/Cargo.toml @@ -22,3 +22,4 @@ log = "0.4.17" rand = { workspace = true } tokio = { workspace = true } hex = "0.4.3" +chrono = "0" diff --git a/utils/local-discovery/src/local-discovery.rs b/utils/local-discovery/src/local-discovery.rs index 2782a45f..9ececaee 100644 --- a/utils/local-discovery/src/local-discovery.rs +++ b/utils/local-discovery/src/local-discovery.rs @@ -29,12 +29,13 @@ async fn main() -> io::Result<()> { return Ok(()); }; - println!("ARGS: {args:?}"); // Create a socket just to get a random and unique port, so that running two or more instances // of this utility don't clash. let sock = UdpSocket::bind("0.0.0.0:0").await?; let addr = sock.local_addr()?; + println!("Our port is {:?}", addr.port()); + let port = PeerPort::Quic(addr.port()); let mut discovery = match discovery_type { @@ -45,11 +46,15 @@ async fn main() -> io::Result<()> { loop { let peer = discovery.recv().await; - println!("Found peer {:?}", peer.initial_addr()); + println!("{}: Found peer {:?}", time_str(), peer.initial_addr()); task::spawn(async move { peer.on_unseen().await; - println!("Lost peer {:?}", peer.initial_addr()); + println!("{}: Lost peer {:?}", time_str(), peer.initial_addr()); }); } } + +fn time_str() -> String { + chrono::Local::now().format("%Y-%m-%dT%H:%M:%S").to_string() +}