iroh_n0des/lib.rs
1//! iroh-n0des is the client side of interacting with [n0des]. n0des gives
2//! visibility into a running iroh network by pushing metrics aggregations
3//! from [iroh] endpoints into a central hub for monitoring.
4//!
5//! Typical setup looks something like this:
6//! ```no_run
7//! use iroh::Endpoint;
8//! use iroh_n0des::Client;
9//!
10//! #[tokio::main]
11//! async fn main() -> anyhow::Result<()> {
12//! let endpoint = Endpoint::bind().await?;
13//!
14//! // needs N0DES_API_SECRET set to an environment variable
15//! // client will now push endpoint metrics to n0des.
16//! let client = Client::builder(&endpoint)
17//! .api_secret_from_env()?
18//! .build()
19//! .await?;
20//!
21//! // we can also ping the service just to confirm everything is working
22//! client.ping().await?;
23//!
24//! Ok(())
25//! }
26//! ```
27//!
28//! [n0des]: https://n0des.iroh.computer
29//! [iroh]: https://iroh.computer
30
31mod client;
32#[cfg(feature = "client_host")]
33mod client_host;
34
35pub mod api_secret;
36pub mod caps;
37pub mod net_diagnostics;
38pub mod protocol;
39
40mod built_info {
41 include!(concat!(env!("OUT_DIR"), "/built.rs"));
42}
43
44/// Version of this crate.
45pub const IROH_N0DES_VERSION: &str = built_info::PKG_VERSION;
46
47/// Version of iroh this crate was built against.
48pub static IROH_VERSION: std::sync::LazyLock<&str> = std::sync::LazyLock::new(|| {
49 built_info::DEPENDENCIES
50 .iter()
51 .find(|(name, _)| *name == "iroh")
52 .expect("iroh dependency not found")
53 .1
54});
55
56pub use anyhow;
57#[cfg(feature = "client_host")]
58pub use client_host::{CLIENT_HOST_ALPN, ClientHost, ClientHostClient};
59pub use iroh_metrics::Registry;
60
61#[cfg(feature = "tickets")]
62pub use self::client::PublishedTicket;
63#[cfg(feature = "net_diagnostics")]
64pub use self::net_diagnostics::{DiagnosticsReport, checks::run_diagnostics};
65pub use self::{
66 api_secret::ApiSecret,
67 client::{API_SECRET_ENV_VAR_NAME, Client, ClientBuilder},
68 protocol::ALPN,
69};