| Crates.io | iroh-ping |
| lib.rs | iroh-ping |
| version | 0.7.0 |
| created_at | 2025-06-26 17:46:55.148338+00 |
| updated_at | 2025-11-05 23:51:25.57967+00 |
| description | high level PING-PONG iroh protocol |
| homepage | |
| repository | https://github.com/n0-computer/iroh-ping |
| max_upload_size | |
| id | 1727597 |
| size | 151,247 |
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(())
}
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.