Skip to content

Commit

Permalink
Debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
inetic committed Jan 20, 2025
1 parent 665a42b commit a6f0e52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions utils/local-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ log = "0.4.17"
rand = { workspace = true }
tokio = { workspace = true }
hex = "0.4.3"
chrono = "0"
11 changes: 8 additions & 3 deletions utils/local-discovery/src/local-discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}

0 comments on commit a6f0e52

Please sign in to comment.