7 releases (breaking)
| new 0.7.0 | Nov 5, 2025 |
|---|---|
| 0.6.0 | Oct 21, 2025 |
| 0.5.0 | Oct 9, 2025 |
| 0.4.0 | Sep 19, 2025 |
| 0.1.0 | Jun 26, 2025 |
#11 in #iroh
339 downloads per month
42KB
99 lines
iroh ping
A very simple iroh protocol for pinging a remote node. It's a high level example & easy starting point for new projects:
use anyhow::Result;
use iroh::{protocol::Router, Endpoint, Watcher};
use iroh_ping::Ping;
#[tokio::main]
async fn main() -> Result<()> {
// create the receive side
let recv_ep = Endpoint::builder().discovery_n0().bind().await?;
let recv_router = Router::builder(recv_ep)
.accept(iroh_ping::ALPN, Ping::new())
.spawn();
let addr = recv_router.endpoint().node_addr().initialized().await;
// create a send side & send a ping
let send_ep = Endpoint::builder().discovery_n0().bind().await?;
let send_pinger = Ping::new();
let rtt = send_pinger.ping(&send_ep, addr).await?;
println!("ping took: {:?} to complete", rtt);
Ok(())
}
This is not the "real" ping
Iroh has all sorts of internal ping-type messages, this is a high level demo of a protocol, and in no way necessary for iroh's normal operation.
Dependencies
~38–73MB
~1M SLoC