ftnet_utils/get_endpoint.rs
1pub async fn get_endpoint(secret_key: iroh::SecretKey) -> eyre::Result<iroh::Endpoint> {
2 match iroh::Endpoint::builder()
3 .discovery_n0()
4 .discovery_local_network()
5 .alpns(vec![ftnet_utils::APNS_IDENTITY.into()])
6 .secret_key(secret_key)
7 .bind()
8 .await
9 {
10 Ok(ep) => Ok(ep),
11 Err(e) => {
12 // https://github.com/n0-computer/iroh/issues/2741
13 // this is why you MUST NOT use anyhow::Error etc. in library code.
14 Err(eyre::anyhow!("failed to bind to iroh network2: {e:?}"))
15 }
16 }
17}