#[non_exhaustive]pub enum BindError {
+BindError in iroh::endpoint - Rust BindError
#[non_exhaustive]pub enum BindError {
MagicSpawn {
source: CreateHandleError,
meta: Meta,
@@ -9,7 +9,7 @@
},
}
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.Trait Implementations§
Source§impl Error for BindError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more1.0.0 · Source§fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()Source§impl From<IntoDiscoveryError> for BindError
Source§fn from(source: IntoDiscoveryError) -> Self
Converts to this type from the input type.Auto Trait Implementations§
§impl Freeze for BindError
§impl !RefUnwindSafe for BindError
§impl Send for BindError
§impl Sync for BindError
§impl Unpin for BindError
§impl !UnwindSafe for BindError
Blanket Implementations§
Trait Implementations§
Source§impl Error for BindError
impl Error for BindError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<IntoDiscoveryError> for BindError
impl From<IntoDiscoveryError> for BindError
Source§fn from(source: IntoDiscoveryError) -> Self
fn from(source: IntoDiscoveryError) -> Self
Auto Trait Implementations§
impl !Freeze for BindError
impl !RefUnwindSafe for BindError
impl Send for BindError
impl Sync for BindError
impl Unpin for BindError
impl !UnwindSafe for BindError
Blanket Implementations§
§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
Endpoint, which allows you to connect to other endpoints:
use iroh::{Endpoint, EndpointAddr};
-use n0_snafu::{Result, ResultExt};
+use n0_error::{Result, StackResultExt};
async fn connect(addr: EndpointAddr) -> Result<()> {
// The Endpoint is the central object that manages an iroh node.
@@ -151,7 +151,7 @@ connecting using only the use iroh::{Endpoint, EndpointAddr};
use n0_future::StreamExt;
-use n0_snafu::{Result, ResultExt};
+use n0_error::{Result, StackResultExt};
async fn accept() -> Result<()> {
// To accept connections at least one ALPN must be configured.
diff --git a/pr/3561/docs/iroh_dns_server/config/index.html b/pr/3561/docs/iroh_dns_server/config/index.html
index c7f87fe392..7a806fdf29 100644
--- a/pr/3561/docs/iroh_dns_server/config/index.html
+++ b/pr/3561/docs/iroh_dns_server/config/index.html
@@ -1,2 +1,2 @@
-iroh_dns_server::config - Rust Module config
Expand description
Configuration for the server
+iroh_dns_server::config - Rust Module config
Expand description
Configuration for the server
Structs§
- Config
- Server configuration
- Mainline
Config - The config for the metrics server.
- Metrics
Config - The config for the metrics server.
- Store
Config - The config for the store.
Enums§
- Bootstrap
Option - Configure the bootstrap servers for mainline DHT resolution.
\ No newline at end of file
diff --git a/pr/3561/docs/iroh_dns_server/config/struct.Config.html b/pr/3561/docs/iroh_dns_server/config/struct.Config.html
index 6594f3ed0a..6d45f8db58 100644
--- a/pr/3561/docs/iroh_dns_server/config/struct.Config.html
+++ b/pr/3561/docs/iroh_dns_server/config/struct.Config.html
@@ -21,10 +21,10 @@ and testing.
§mainline: Option<MainlineConfig>Config for the mainline lookup.
§zone_store: Option<StoreConfig>Config for the zone store.
§pkarr_put_rate_limit: RateLimitConfigConfig for pkarr rate limit
-Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
+Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreAuto Trait Implementations§
§impl Freeze for Config
§impl RefUnwindSafe for Config
§impl Send for Config
§impl Sync for Config
§impl Unpin for Config
§impl UnwindSafe for Config
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3561/docs/iroh_dns_server/http/enum.CertMode.html b/pr/3561/docs/iroh_dns_server/http/enum.CertMode.html
index aa2ba319a6..839f80274e 100644
--- a/pr/3561/docs/iroh_dns_server/http/enum.CertMode.html
+++ b/pr/3561/docs/iroh_dns_server/http/enum.CertMode.html
@@ -1,4 +1,4 @@
-CertMode in iroh_dns_server::http - Rust CertMode
pub enum CertMode {
+CertMode in iroh_dns_server::http - Rust CertMode
pub enum CertMode {
Manual,
LetsEncrypt,
SelfSigned,
@@ -6,10 +6,10 @@
Variants§
§Manual
Certs are loaded from a the cert_cache path
§LetsEncrypt
ACME with LetsEncrypt servers
§SelfSigned
Create self-signed certificates and store them in the cert_cache path
-Trait Implementations§
Source§impl<'de> Deserialize<'de> for CertMode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
- __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreSource§impl Eq for CertMode
Source§impl StructuralPartialEq for CertMode
Auto Trait Implementations§
§impl Freeze for CertMode
§impl RefUnwindSafe for CertMode
§impl Send for CertMode
§impl Sync for CertMode
§impl Unpin for CertMode
§impl UnwindSafe for CertMode
Blanket Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CertMode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
+ __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreSource§impl Eq for CertMode
Source§impl StructuralPartialEq for CertMode
Auto Trait Implementations§
§impl Freeze for CertMode
§impl RefUnwindSafe for CertMode
§impl Send for CertMode
§impl Sync for CertMode
§impl Unpin for CertMode
§impl UnwindSafe for CertMode
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3561/docs/iroh_dns_server/http/index.html b/pr/3561/docs/iroh_dns_server/http/index.html
index 879ea42a0e..112ec2459d 100644
--- a/pr/3561/docs/iroh_dns_server/http/index.html
+++ b/pr/3561/docs/iroh_dns_server/http/index.html
@@ -1,2 +1,2 @@
-iroh_dns_server::http - Rust Module http
Expand description
HTTP server part of iroh-dns-server
+iroh_dns_server::http - Rust Module http
Expand description
HTTP server part of iroh-dns-server
Structs§
- Http
Config - Config for the HTTP server
- Http
Server - The HTTP(S) server part of iroh-dns-server
- Https
Config - Config for the HTTPS server
Enums§
- Cert
Mode - The mode how SSL certificates should be created.
- Rate
LimitConfig - Config for http server rate limit.
\ No newline at end of file
diff --git a/pr/3561/docs/iroh_dns_server/http/struct.HttpConfig.html b/pr/3561/docs/iroh_dns_server/http/struct.HttpConfig.html
index 11e949dbeb..fea9ecfeb6 100644
--- a/pr/3561/docs/iroh_dns_server/http/struct.HttpConfig.html
+++ b/pr/3561/docs/iroh_dns_server/http/struct.HttpConfig.html
@@ -1,11 +1,11 @@
-HttpConfig in iroh_dns_server::http - Rust HttpConfig
pub struct HttpConfig {
+HttpConfig in iroh_dns_server::http - Rust HttpConfig
pub struct HttpConfig {
pub port: u16,
pub bind_addr: Option<IpAddr>,
}
Expand description
Config for the HTTP server
Fields§
§port: u16Port to bind to
§bind_addr: Option<IpAddr>Optionally set a custom bind address (will use 0.0.0.0 if unset)
-Trait Implementations§
Source§impl Clone for HttpConfig
Source§fn clone(&self) -> HttpConfig
Returns a duplicate of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for HttpConfig
Source§impl<'de> Deserialize<'de> for HttpConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
- __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreSource§impl Serialize for HttpConfig
Source§fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
+Trait Implementations§
Source§impl Clone for HttpConfig
Source§fn clone(&self) -> HttpConfig
Returns a duplicate of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for HttpConfig
Source§impl<'de> Deserialize<'de> for HttpConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
+ __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreAuto Trait Implementations§
§impl Freeze for HttpConfig
§impl RefUnwindSafe for HttpConfig
§impl Send for HttpConfig
§impl Sync for HttpConfig
§impl Unpin for HttpConfig
§impl UnwindSafe for HttpConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
diff --git a/pr/3561/docs/iroh_dns_server/http/struct.HttpServer.html b/pr/3561/docs/iroh_dns_server/http/struct.HttpServer.html
index c7b0daa6c8..827895b05e 100644
--- a/pr/3561/docs/iroh_dns_server/http/struct.HttpServer.html
+++ b/pr/3561/docs/iroh_dns_server/http/struct.HttpServer.html
@@ -1,14 +1,14 @@
-HttpServer in iroh_dns_server::http - Rust HttpServer
pub struct HttpServer { /* private fields */ }
Expand description
The HTTP(S) server part of iroh-dns-server
-Implementations§
Source§impl HttpServer
Sourcepub async fn spawn(
+HttpServer in iroh_dns_server::http - Rust HttpServer
pub struct HttpServer { /* private fields */ }
Expand description
The HTTP(S) server part of iroh-dns-server
+Implementations§
Source§impl HttpServer
Sourcepub async fn spawn(
http_config: Option<HttpConfig>,
https_config: Option<HttpsConfig>,
rate_limit_config: RateLimitConfig,
state: AppState,
) -> Result<HttpServer>
Spawn the server
-Sourcepub fn http_addr(&self) -> Option<SocketAddr>
Get the bound address of the HTTP socket.
-Sourcepub fn https_addr(&self) -> Option<SocketAddr>
Get the bound address of the HTTPS socket.
-Sourcepub async fn shutdown(self) -> Result<()>
Shutdown the server and wait for all tasks to complete.
-Sourcepub async fn run_until_done(self) -> Result<()>
Wait for all tasks to complete.
+Sourcepub fn http_addr(&self) -> Option<SocketAddr>
Get the bound address of the HTTP socket.
+Sourcepub fn https_addr(&self) -> Option<SocketAddr>
Get the bound address of the HTTPS socket.
+Sourcepub async fn shutdown(self) -> Result<()>
Shutdown the server and wait for all tasks to complete.
+Sourcepub async fn run_until_done(self) -> Result<()>
Wait for all tasks to complete.
Runs forever unless tasks fail.
Auto Trait Implementations§
§impl Freeze for HttpServer
§impl !RefUnwindSafe for HttpServer
§impl Send for HttpServer
§impl Sync for HttpServer
§impl Unpin for HttpServer
§impl !UnwindSafe for HttpServer
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3561/docs/iroh_dns_server/http/struct.HttpsConfig.html b/pr/3561/docs/iroh_dns_server/http/struct.HttpsConfig.html
index 2e9af50e2b..37b5c6470b 100644
--- a/pr/3561/docs/iroh_dns_server/http/struct.HttpsConfig.html
+++ b/pr/3561/docs/iroh_dns_server/http/struct.HttpsConfig.html
@@ -1,4 +1,4 @@
-HttpsConfig in iroh_dns_server::http - Rust HttpsConfig
pub struct HttpsConfig {
+HttpsConfig in iroh_dns_server::http - Rust HttpsConfig
pub struct HttpsConfig {
pub port: u16,
pub bind_addr: Option<IpAddr>,
pub domains: Vec<String>,
@@ -12,8 +12,8 @@
§cert_mode: CertModeThe mode of SSL certificate creation
§letsencrypt_contact: Option<String>Letsencrypt contact email address (required if using CertMode::LetsEncrypt)
§letsencrypt_prod: Option<bool>Whether to use the letsenrypt production servers (only applies to CertMode::LetsEncrypt)
-Trait Implementations§
Source§impl Clone for HttpsConfig
Source§fn clone(&self) -> HttpsConfig
Returns a duplicate of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for HttpsConfig
Source§impl<'de> Deserialize<'de> for HttpsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
- __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreSource§impl Serialize for HttpsConfig
Source§fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
+Trait Implementations§
Source§impl Clone for HttpsConfig
Source§fn clone(&self) -> HttpsConfig
Returns a duplicate of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for HttpsConfig
Source§impl<'de> Deserialize<'de> for HttpsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
+ __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read moreAuto Trait Implementations§
§impl Freeze for HttpsConfig
§impl RefUnwindSafe for HttpsConfig
§impl Send for HttpsConfig
§impl Sync for HttpsConfig
§impl Unpin for HttpsConfig
§impl UnwindSafe for HttpsConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
diff --git a/pr/3561/docs/iroh_dns_server/index.html b/pr/3561/docs/iroh_dns_server/index.html
index 6f323b55d4..8702974b68 100644
--- a/pr/3561/docs/iroh_dns_server/index.html
+++ b/pr/3561/docs/iroh_dns_server/index.html
@@ -1,2 +1,2 @@
-iroh_dns_server - Rust Crate iroh_dns_server
Expand description
A DNS server and pkarr relay
+iroh_dns_server - Rust Crate iroh_dns_server
Expand description
A DNS server and pkarr relay
Modules§
- config
- Configuration for the server
- dns
- Implementation of a DNS name server for iroh endpoint announces
- http
- HTTP server part of iroh-dns-server
- metrics
- Metrics support for the server
- server
- The main server which combines the DNS and HTTP(S) servers.
- state
- Shared state and store for the iroh-dns-server
Structs§
- Zone
Store - A store for pkarr signed packets.
\ No newline at end of file
diff --git a/pr/3561/docs/search.index/path/9b8788cabd79.js b/pr/3561/docs/search.index/path/9b8788cabd79.js
new file mode 100644
index 0000000000..c14e5124b6
--- /dev/null
+++ b/pr/3561/docs/search.index/path/9b8788cabd79.js
@@ -0,0 +1 @@
+rd_("f[1,\"\"]0Al[10,\"core::cmp\",\"core::cmp\"]Al[10,\"core::ops\",\"core::ops\"]Ce[5,\"clap_builder::util::id\",\"clap_builder::util::id\"]Bd[15,\"iroh_relay::client::DialError\"]Cg[5,\"iroh::endpoint::presets\",\"iroh::endpoint::presets\"]Eg[5,\"tower_http::follow_redirect::policy::or\",\"tower_http::follow_redirect::policy::or\"]66Ei[5,\"tower_http::follow_redirect::policy::and\",\"tower_http::follow_redirect::policy::and\"]A`[10,\"core::any\"]Ao[5,\"alloc::sync\",\"alloc::sync\"]Ba[5,\"alloc::boxed\",\"alloc::boxed\"]Cb[10,\"bytes::buf::buf_impl\",\"bytes::buf::buf_impl\"]Bi[6,\"iroh_quinn_proto\",\"iroh_quinn_proto\"]8Al[15,\"iroh::KeyParsingError\"]Ba[15,\"iroh_base::KeyParsingError\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Am[5,\"iroh_bench\",\"iroh_bench\"]Bg[5,\"iroh_bench::s2n\",\"iroh_bench::s2n\"]A`[10,\"core::cmp\"]Ak[5,\"core::pin\",\"core::pin\"]Bg[15,\"iroh_relay::client::ConnectError\"]o[5,\"url\",\"url\"]Am[5,\"alloc::vec\",\"alloc::vec\"]Al[2,\"iroh::discovery::pkarr\"]j[2,\"iroh\"]Ae[2,\"iroh::discovery\"]A`[2,\"iroh_relay\"]Ae[2,\"iroh_dns_server\"]f[1,\"\"]00Ao[2,\"iroh::net_report::options\"]o[2,\"iroh_base\"]f[0,\"\"]A`[2,\"iroh_bench\"]4Ak[2,\"iroh_dns_server::http\"]555Ak[10,\"clap_builder::derive\"]>Af[10,\"core::ops::drop\"]Ad[10,\"core::convert\"]Aa[10,\"core::hash\"]1g[17,\"\"]Ci[5,\"iroh_quinn_proto::crypto\",\"iroh_quinn_proto::crypto\"]Bd[15,\"iroh_base::ticket::ParseError\"]Be[5,\"n0_error::meta\",\"n0_error::meta\"]Cc[5,\"reqwest::dns::resolve\",\"reqwest::dns::resolve\"]Dg[5,\"hickory_proto::rr::domain::name\",\"hickory_proto::rr::domain::name\"]Ak[5,\"std::path\",\"std::path\"]Bi[6,\"core::task::poll\",\"core::task::poll\"]Bb[10,\"core::marker\",\"core::marker\"]Bi[6,\"iroh_quinn_proto\",\"iroh_quinn_proto\"]Ac[10,\"futures_sink\"]2Bf[15,\"iroh::discovery::DiscoveryError\"]Bj[15,\"iroh::discovery::IntoDiscoveryError\"]Bb[15,\"iroh::protocol::AcceptError\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ah[10,\"ppv_lite86::types\"]f[1,\"\"]f[3,\"\"]Ah[2,\"iroh_relay::client\"]A`[2,\"iroh_relay\"]Ae[2,\"iroh_dns_server\"]A`[2,\"iroh_bench\"]4Ae[2,\"iroh::discovery\"]Ad[2,\"iroh::defaults\"]4Bk[2,\"iroh_quinn_proto::connection::streams\"]88Ad[10,\"core::convert\"]Ca[8,\"futures_lite::future\",\"futures_lite::future\"]Ca[8,\"futures_lite::stream\",\"futures_lite::stream\"]Ba[5,\"bytes::bytes\",\"bytes::bytes\"]Ad[5,\"iroh::endpoint\"]Ab[10,\"core::clone\"]Cg[6,\"iroh_quinn_proto::frame\",\"iroh_quinn_proto::frame\"]Ao[10,\"iroh_quinn_proto::coding\"]A`[10,\"core::fmt\"]Ag[10,\"core::ops::deref\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Ak[5,\"core::fmt\",\"core::fmt\"]Ab[10,\"core::error\"]Be[5,\"std::io::error\",\"std::io::error\"]Bc[6,\"rustls::error\",\"rustls::error\"]Ba[8,\"clap_builder\",\"clap_builder\"]Bi[5,\"signature::error\",\"signature::error\"]Bg[6,\"postcard::error\",\"postcard::error\"]Af[2,\"iroh_relay::quic\"]Bc[2,\"iroh_relay::protos::handshake\"]Ao[2,\"iroh_relay::protos::relay\"]Ba[5,\"hyper::error\",\"hyper::error\"]Ee[6,\"iroh_quinn_proto::transport_parameters\",\"iroh_quinn_proto::transport_parameters\"]Be[5,\"reqwest::error\",\"reqwest::error\"]Cg[6,\"tokio_websockets::error\",\"tokio_websockets::error\"]Bi[6,\"iroh_relay::quic\",\"iroh_relay::quic\"]Dc[6,\"iroh_relay::protos::handshake\",\"iroh_relay::protos::handshake\"]Ck[6,\"iroh_relay::protos::relay\",\"iroh_relay::protos::relay\"]Ca[6,\"iroh::net_report\",\"iroh::net_report::probes\"]Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Bb[10,\"core::marker\",\"core::marker\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]1g[17,\"\"]f[1,\"\"]Ah[2,\"iroh_relay::protos\"]Af[2,\"iroh_quinn_proto\"]Ae[2,\"iroh::discovery\"]A`[2,\"iroh_bench\"]34Ae[2,\"iroh_dns_server\"]1Bb[2,\"iroh_quinn_proto::connection\"]166Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Ac[10,\"core::borrow\"]C`[10,\"bytes::buf::buf_mut\",\"bytes::buf::buf_mut\"]Bc[5,\"pkarr::client\",\"pkarr::client\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ba[5,\"async_compat\",\"async_compat\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Al[15,\"iroh::KeyParsingError\"]Ba[15,\"iroh_base::KeyParsingError\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Cb[10,\"core::future::future\",\"core::future::future\"]Ca[5,\"iroh_dns_server::dns\",\"iroh_dns_server::dns\"]An[10,\"core::hash\",\"core::hash\"]Cb[15,\"iroh_relay::protos::relay::RelayToClientMsg\"]Bm[6,\"core::net::ip_addr\",\"core::net::ip_addr\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]Bh[10,\"reloadable_core\",\"reloadable_core\"]Be[15,\"iroh_relay::server::CertConfig\"]Ad[5,\"iroh::endpoint\"]Ba[6,\"core::option\",\"core::option\"]g[17,\"\"]E`[10,\"tower_http::follow_redirect::policy\",\"tower_http::follow_redirect::policy\"]Ch[10,\"iroh::endpoint::presets\",\"iroh::endpoint::presets\"]Co[5,\"hickory_proto::rr::resource\",\"hickory_proto::rr::resource\"]Ca[5,\"iroh::net_report\",\"iroh::net_report::report\"]Ak[8,\"core::fmt\",\"core::fmt\"]Ba[6,\"core::result\",\"core::result\"]Be[8,\"std::io::error\",\"std::io::error\"]Ai[8,\"n0_error\",\"n0_error\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Cg[5,\"iroh_dns_server::server\",\"iroh_dns_server::server\"]?Ad[2,\"iroh::endpoint\"]Cd[6,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map\"]Ak[10,\"futures_core::stream\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Bc[5,\"alloc::string\",\"alloc::string\"]Bl[10,\"iroh_base::ticket\",\"iroh_base::ticket\"]Ak[5,\"core::any\",\"core::any\"]Ci[5,\"iroh_quinn_proto::varint\",\"iroh_quinn_proto::varint\"]Ad[5,\"iroh::endpoint\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bd[15,\"iroh_base::ticket::ParseError\"]A`[2,\"iroh_relay\"]Ah[2,\"iroh_relay::protos\"]Af[2,\"iroh_quinn_proto\"]Ae[2,\"iroh_dns_server\"]1Af[2,\"iroh::net_report\"]4041o[2,\"iroh_base\"]3Ae[10,\"iroh::endpoint\"]Bg[8,\"iroh_relay::dns\",\"iroh_relay::dns\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Co[5,\"iroh::discovery::pkarr::dht\",\"iroh::discovery::pkarr::dht\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]De[5,\"clap_builder::builder::command\",\"clap_builder::builder::command\"]Bc[15,\"iroh::endpoint::ConnectError\"]An[15,\"iroh_relay::quic::Error\"]Bi[5,\"core::task::wake\",\"core::task::wake\"]Cc[5,\"iroh_metrics::metrics\",\"iroh_metrics::metrics\"]Ad[10,\"core::default\"]A`[10,\"core::fmt\"]Bm[5,\"tokio::time::error\",\"tokio::time::error\"]Bl[15,\"iroh::discovery::mdns::DiscoveryEvent\"]Bc[10,\"axum_core::extract::from_ref\"]Ah[10,\"core::str::traits\"]Co[5,\"std::collections::hash::map\",\"std::collections::hash::map\"]Ak[5,\"std::time\",\"std::time\"]Cg[5,\"tonic::service::layered\",\"tonic::service::layered\"]Bj[15,\"iroh_relay::server::SupervisorError\"]Cb[5,\"iroh::net_report\",\"iroh::net_report::metrics\"]Ci[5,\"iroh_dns_server::metrics\",\"iroh_dns_server::metrics\"]Cf[5,\"iroh_relay::server\",\"iroh_relay::server::metrics\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Ad[5,\"iroh::endpoint\"]Cg[5,\"iroh::net_report\",\"iroh::net_report::options::imp\"]Ak[5,\"std::path\",\"std::path\"]Bk[5,\"dyn_clone::sealed\",\"dyn_clone::sealed\"]Bo[5,\"tokio::io::read_buf\",\"tokio::io::read_buf\"]Be[5,\"tonic::request\",\"tonic::request\"]Eg[5,\"hickory_server::server::request_handler\",\"hickory_server::server::request_handler\"]B`[15,\"iroh_relay::dns::DnsError\"]Al[10,\"reqwest::dns::resolve\"]Cg[5,\"tokio::runtime::runtime\",\"tokio::runtime::runtime\"]Cj[10,\"iroh_quinn_proto::crypto\",\"iroh_quinn_proto::crypto\"]Bd[15,\"iroh_relay::client::DialError\"]4Ad[10,\"alloc::borrow\"]Ad[10,\"core::convert\"]0Bg[15,\"iroh_relay::client::ConnectError\"]k[10,\"iroh\"]?j[2,\"iroh\"]Af[2,\"iroh::net_report\"]Ah[2,\"iroh_relay::server\"]Ae[2,\"iroh_dns_server\"]f[1,\"\"]Ad[2,\"iroh::endpoint\"]Ad[2,\"iroh::defaults\"]Bb[2,\"iroh_quinn_proto::connection\"]5Ad[5,\"iroh::endpoint\"]Bc[5,\"n0_error::any\",\"n0_error::any\"]Ce[5,\"iroh_dns_server::state\",\"iroh_dns_server::state\"]De[5,\"alloc::collections::btree::set\",\"alloc::collections::btree::set\"]Ch[6,\"iroh_dns_server::http\",\"iroh_dns_server::http::tls\"]Am[6,\"iroh_bench\",\"iroh_bench\"]Ag[10,\"core::ops::deref\"]Bm[15,\"iroh::endpoint::GetMappingAddressError\"]Ae[2,\"iroh_relay::dns\"]Bg[6,\"iroh_relay::dns\",\"iroh_relay::dns\"]Am[5,\"core::time\",\"core::time\"]A`[10,\"dyn_clone\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bd[15,\"iroh_base::ticket::ParseError\"]Ca[5,\"iroh_quinn::endpoint\",\"iroh_quinn::endpoint\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Bg[6,\"n0_error::error\",\"n0_error::error\"]4Ca[5,\"iroh_quinn::incoming\",\"iroh_quinn::incoming\"]2Bm[5,\"core::net::ip_addr\",\"core::net::ip_addr\"]0Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Am[10,\"iroh_metrics::iterable\"]Db[10,\"core::iter::traits::iterator\",\"core::iter::traits::iterator\"]An[10,\"tonic::service::layered\"]Am[15,\"iroh::endpoint::Source\"]An[10,\"n0_watcher\",\"n0_watcher\"]Ak[6,\"core::cmp\",\"core::cmp\"]Ad[5,\"iroh::endpoint\"]Bm[5,\"http::header::name\",\"http::header::name\"]Cc[5,\"iroh_dns_server::http\",\"iroh_dns_server::http\"]0B`[10,\"core::future::into_future\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Bd[15,\"iroh_relay::client::DialError\"]B`[15,\"iroh::endpoint::BindError\"]Bm[5,\"iroh_metrics::base\",\"iroh_metrics::base\"]B`[15,\"iroh_relay::dns::DnsError\"]Bm[8,\"core::num::nonzero\",\"core::num::nonzero\"]Bb[15,\"iroh::protocol::AcceptError\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Ae[2,\"iroh::discovery\"]Ag[2,\"iroh_base::ticket\"]Ao[6,\"url::parser\",\"url::parser\"]Bc[15,\"iroh_relay::dns::LookupError\"]Ao[2,\"iroh_relay::endpoint_info\"]Ae[6,\"iroh::discovery\"]Bk[6,\"iroh_base::ticket\",\"iroh_base::ticket\"]Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]A`[10,\"core::cmp\"]Al[2,\"iroh::discovery::pkarr\"]Ce[6,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Bi[5,\"iroh_relay::quic\",\"iroh_relay::quic\"]Cd[5,\"iroh::net_report\",\"iroh::net_report::reportgen\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]De[6,\"hickory_proto::rr::record_type\",\"hickory_proto::rr::record_type\"]Ad[5,\"iroh::endpoint\"]Ad[6,\"iroh::endpoint\"]Cb[15,\"iroh_relay::protos::relay::RelayToClientMsg\"]22Bh[10,\"serde_core::ser\",\"serde_core::ser\"]Ce[6,\"core::net::socket_addr\",\"core::net::socket_addr\"]Ah[2,\"iroh_relay::server\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Af[10,\"n0_error::error\"]Ba[5,\"http::status\",\"http::status\"]Ak[10,\"clap_builder::derive\"]Cj[10,\"iroh_quinn_proto::config\",\"iroh_quinn_proto::config\"]9Af[2,\"iroh_quinn_proto\"]0A`[2,\"iroh_quinn\"]f[3,\"\"]00j[2,\"iroh\"]0Ad[2,\"iroh::protocol\"]Be[6,\"iroh::protocol\",\"iroh::protocol\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Co[5,\"rustls::server::server_conn\",\"rustls::server::server_conn\"]Am[5,\"iroh_bench\",\"iroh_bench\"]Ad[5,\"iroh::endpoint\"]Bc[5,\"data_encoding\",\"data_encoding\"]Ae[10,\"serde_core::de\"]Bg[6,\"iroh_relay::dns\",\"iroh_relay::dns\"]o[5,\"iroh::dns\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Bd[15,\"iroh_relay::client::SendError\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Bo[5,\"http::header::value\",\"http::header::value\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]0Cc[5,\"iroh_dns_server::http\",\"iroh_dns_server::http\"]Do[5,\"iroh_quinn_proto::config::transport\",\"iroh_quinn_proto::config::transport\"]Ae[10,\"tonic::request\"]Be[15,\"iroh_relay::server::CertConfig\"]Ae[2,\"iroh_relay::dns\"];B`[15,\"iroh_relay::dns::DnsError\"]Bg[15,\"iroh_relay::client::ConnectError\"]Be[15,\"iroh_relay::server::SpawnError\"]Bk[5,\"iroh_relay\",\"iroh_relay::ping_tracker\"]j[5,\"iroh\"]Bh[5,\"iroh_relay\",\"iroh_relay::relay_map\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]6Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Bd[15,\"iroh_relay::client::RecvError\"]Bd[15,\"iroh_relay::client::SendError\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]B`[15,\"iroh::endpoint::AlpnError\"]Ci[5,\"ring::error::unspecified\",\"ring::error::unspecified\"]A`[2,\"iroh_quinn\"]0Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Ce[5,\"rustls::crypto::signer\",\"rustls::crypto::signer\"]Co[5,\"rustls::client::client_conn\",\"rustls::client::client_conn\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ad[5,\"iroh::endpoint\"]Ad[2,\"iroh::endpoint\"]Ah[2,\"iroh_relay::client\"]Cm[6,\"iroh_quinn_proto::endpoint\",\"iroh_quinn_proto::endpoint\"]Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]Bm[6,\"iroh_relay::client\",\"iroh_relay::client\"]Ci[5,\"iroh_quinn_proto::shared\",\"iroh_quinn_proto::shared\"]Bf[10,\"serde_core::de\",\"serde_core::de\"]Co[5,\"iroh::discovery::pkarr::dht\",\"iroh::discovery::pkarr::dht\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Ca[5,\"iroh::discovery::dns\",\"iroh::discovery::dns\"]Ci[5,\"iroh_base::endpoint_addr\",\"iroh_base::endpoint_addr\"]j[5,\"iroh\"]Bj[5,\"iroh_base\",\"iroh_base::endpoint_addr\"]Ae[5,\"iroh::discovery\"]Ck[5,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]10Bb[10,\"core::iter::traits::collect\"]Am[10,\"iroh_metrics::iterable\"]D`[10,\"core::iter::traits::collect\",\"core::iter::traits::collect\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Cg[5,\"iroh_quinn_proto::frame\",\"iroh_quinn_proto::frame\"]Bc[15,\"iroh_relay::dns::LookupError\"]Ai[10,\"iroh_metrics::base\"]Bd[15,\"iroh_relay::client::DialError\"]Ad[5,\"iroh::endpoint\"]Ac[5,\"iroh::metrics\"]Cf[5,\"iroh_relay::server\",\"iroh_relay::server::metrics\"]Cg[5,\"hickory_resolver::error\",\"hickory_resolver::error\"]Do[5,\"iroh_quinn_proto::connection::paths\",\"iroh_quinn_proto::connection::paths\"]Co[5,\"rustls::server::server_conn\",\"rustls::server::server_conn\"]5Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]Ca[5,\"pkarr::signed_packet\",\"pkarr::signed_packet\"]Ce[5,\"core::net::socket_addr\",\"core::net::socket_addr\"]0Ad[6,\"iroh::endpoint\"]Ae[2,\"iroh::magicsock\"]A`[2,\"iroh_relay\"]l[10,\"snafu\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ab[10,\"core::clone\"]Bb[15,\"iroh::discovery::ParseError\"]Ai[2,\"iroh::endpoint_info\"]Ao[2,\"iroh_relay::endpoint_info\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ai[6,\"iroh::endpoint_info\"]Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Bg[5,\"iroh::discovery\",\"iroh::discovery\"]5421Aj[10,\"iroh::endpoint_info\"]Cl[10,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Bh[10,\"iroh::discovery\",\"iroh::discovery\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Cc[5,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Bi[6,\"rustls_pki_types\",\"rustls_pki_types\"]Eo[6,\"iroh_quinn_proto::connection::streams::recv\",\"iroh_quinn_proto::connection::streams::recv\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Bj[15,\"iroh_relay::server::SupervisorError\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Ca[15,\"iroh_relay::protos::common::FrameTypeError\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Ci[5,\"iroh_quinn_proto::coding\",\"iroh_quinn_proto::coding\"]o[2,\"iroh_base\"]j[2,\"iroh\"]A`[2,\"iroh_relay\"]Ak[2,\"iroh_dns_server::http\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Bi[5,\"rustls_pki_types\",\"rustls_pki_types\"]Ak[10,\"clap_builder::derive\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Dd[6,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map::endpoint_state\"]Dd[5,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map::endpoint_state\"]Bf[6,\"iroh::endpoint\",\"iroh::magicsock\"]Ae[2,\"iroh::discovery\"]Bg[6,\"iroh::discovery\",\"iroh::discovery\"]Ak[2,\"iroh::discovery::mdns\"]Cc[6,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Bm[15,\"iroh::endpoint::GetMappingAddressError\"]D`[5,\"iroh::test_utils\",\"iroh::test_utils::dns_and_pkarr_servers\"]Co[5,\"iroh_base::ticket::endpoint\",\"iroh_base::ticket::endpoint\"]Ce[5,\"iroh_base::ticket\",\"iroh_base::ticket::endpoint\"]B`[2,\"iroh_relay::protos::common\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Cm[6,\"iroh_relay::protos::common\",\"iroh_relay::protos::common\"]Ak[10,\"clap_builder::derive\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Ac[5,\"iroh::metrics\"]Ao[6,\"pkarr::keys\",\"pkarr::keys\"]Ad[6,\"iroh::endpoint\"]0Ca[5,\"iroh::net_report\",\"iroh::net_report::report\"]Bn[10,\"hickory_server::server::request_handler\"]Cc[8,\"ed25519_dalek::errors\",\"ed25519_dalek::errors\"]j[5,\"iroh\"]B`[5,\"iroh_base\",\"iroh_base::key\"]Da[6,\"simple_dns::simple_dns_error\",\"simple_dns::simple_dns_error\"]Di[5,\"iroh::discovery::static_provider\",\"iroh::discovery::static_provider\"]Be[15,\"iroh_relay::server::SpawnError\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]Ad[5,\"iroh::endpoint\"]Bc[2,\"iroh::magicsock::endpoint_map\"]Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]44Cg[6,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]4B`[15,\"iroh::endpoint::AlpnError\"]Da[6,\"iroh_quinn_proto::connection\",\"iroh_quinn_proto::connection\"]Ad[6,\"iroh::endpoint\"]7Bc[5,\"iroh::metrics\",\"iroh::metrics\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bg[15,\"iroh_relay::client::ConnectError\"]B`[15,\"iroh_relay::dns::DnsError\"]Bi[15,\"iroh::endpoint_info::EncodingError\"]Bo[15,\"iroh_relay::endpoint_info::EncodingError\"]j[2,\"iroh\"]o[2,\"iroh_base\"]Be[6,\"iroh_base::key\",\"iroh_base::key\"]j[6,\"iroh\"]B`[6,\"iroh_base\",\"iroh_base::key\"]Eo[5,\"hickory_server::authority::message_response\",\"hickory_server::authority::message_response\"]Ai[10,\"iroh_metrics::base\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Bf[10,\"iroh::protocol\",\"iroh::protocol\"]Bd[15,\"iroh_relay::client::DialError\"]Db[6,\"iroh_dns_server::http\",\"iroh_dns_server::http::rate_limiting\"]Bh[5,\"iroh_relay\",\"iroh_relay::relay_map\"]Bo[10,\"hickory_server::server::response_handler\"]Ah[2,\"iroh_relay::server\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Do[5,\"iroh_quinn_proto::config::transport\",\"iroh_quinn_proto::config::transport\"]Ad[5,\"iroh::endpoint\"]Bm[5,\"alloc::collections\",\"alloc::collections\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]f[3,\"\"]Ae[2,\"iroh::discovery\"]5Bi[5,\"iroh::test_utils\",\"iroh::test_utils\"]Ao[2,\"iroh_relay::protos::relay\"]Ck[6,\"iroh_relay::protos::relay\",\"iroh_relay::protos::relay\"]Am[6,\"iroh_bench\",\"iroh_bench\"]77Ac[5,\"iroh::metrics\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]43Bk[15,\"iroh_relay::protos::handshake::Error\"]Ai[10,\"iri_string::format\"]o[10,\"num_enum\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ca[15,\"iroh_relay::protos::common::FrameTypeError\"]B`[15,\"iroh::endpoint::AlpnError\"]>Dg[5,\"tokio_util::task::abort_on_drop\",\"tokio_util::task::abort_on_drop\"]Ae[10,\"iroh::endpoint\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]1Bd[15,\"iroh_relay::client::DialError\"]Cg[5,\"iroh_relay::server\",\"iroh_relay::server::resolver\"]Ad[6,\"iroh::endpoint\"]Ad[5,\"iroh::endpoint\"]Am[6,\"iroh_bench\",\"iroh_bench\"]6Bf[10,\"iroh::protocol\",\"iroh::protocol\"]Ae[2,\"iroh::discovery\"]Bg[6,\"iroh::discovery\",\"iroh::discovery\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Bo[5,\"http::header::value\",\"http::header::value\"]7j[5,\"iroh\"]Bf[5,\"iroh_base\",\"iroh_base::relay_url\"]Bb[10,\"rustls::server::server_conn\"]::Bg[5,\"iroh::discovery\",\"iroh::discovery\"]Al[15,\"iroh::KeyParsingError\"]Ba[15,\"iroh_base::KeyParsingError\"]Ca[5,\"iroh::discovery::dns\",\"iroh::discovery::dns\"]Bg[15,\"iroh_relay::client::ConnectError\"]Bf[15,\"iroh::discovery::DiscoveryError\"]Ee[5,\"iroh_quinn_proto::transport_parameters\",\"iroh_quinn_proto::transport_parameters\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Ad[2,\"iroh::endpoint\"]Bf[6,\"iroh::endpoint\",\"iroh::magicsock\"]1Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]3Bd[15,\"iroh_relay::client::SendError\"]Bi[15,\"iroh::endpoint_info::EncodingError\"]Bo[15,\"iroh_relay::endpoint_info::EncodingError\"]9Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Cc[5,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Ci[5,\"iroh_quinn_proto::varint\",\"iroh_quinn_proto::varint\"]Ad[5,\"iroh::endpoint\"]2Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Ai[5,\"num_enum\",\"num_enum\"]Ci[5,\"iroh_quinn_proto::config\",\"iroh_quinn_proto::config\"]Af[2,\"iroh::test_utils\"]>Af[10,\"core::ops::drop\"]Ad[10,\"core::convert\"]Aa[10,\"core::hash\"]1g[17,\"\"]Ci[5,\"iroh_quinn_proto::crypto\",\"iroh_quinn_proto::crypto\"]Bd[15,\"iroh_base::ticket::ParseError\"]Be[5,\"n0_error::meta\",\"n0_error::meta\"]Cc[5,\"reqwest::dns::resolve\",\"reqwest::dns::resolve\"]Dg[5,\"hickory_proto::rr::domain::name\",\"hickory_proto::rr::domain::name\"]Ak[5,\"std::path\",\"std::path\"]Bi[6,\"core::task::poll\",\"core::task::poll\"]Bb[10,\"core::marker\",\"core::marker\"]Bi[6,\"iroh_quinn_proto\",\"iroh_quinn_proto\"]Ac[10,\"futures_sink\"]2Bf[15,\"iroh::discovery::DiscoveryError\"]Bj[15,\"iroh::discovery::IntoDiscoveryError\"]Bb[15,\"iroh::protocol::AcceptError\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ah[10,\"ppv_lite86::types\"]f[1,\"\"]f[3,\"\"]Ah[2,\"iroh_relay::client\"]A`[2,\"iroh_relay\"]Ae[2,\"iroh_dns_server\"]A`[2,\"iroh_bench\"]4Ae[2,\"iroh::discovery\"]Ad[2,\"iroh::defaults\"]4Bk[2,\"iroh_quinn_proto::connection::streams\"]88Ad[10,\"core::convert\"]Ca[8,\"futures_lite::future\",\"futures_lite::future\"]Ca[8,\"futures_lite::stream\",\"futures_lite::stream\"]Ba[5,\"bytes::bytes\",\"bytes::bytes\"]Ad[5,\"iroh::endpoint\"]Ab[10,\"core::clone\"]Cg[6,\"iroh_quinn_proto::frame\",\"iroh_quinn_proto::frame\"]Ao[10,\"iroh_quinn_proto::coding\"]A`[10,\"core::fmt\"]Ag[10,\"core::ops::deref\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Ak[5,\"core::fmt\",\"core::fmt\"]Ab[10,\"core::error\"]Be[5,\"std::io::error\",\"std::io::error\"]Bc[6,\"rustls::error\",\"rustls::error\"]Ba[8,\"clap_builder\",\"clap_builder\"]Bi[5,\"signature::error\",\"signature::error\"]Bg[6,\"postcard::error\",\"postcard::error\"]Af[2,\"iroh_relay::quic\"]Bc[2,\"iroh_relay::protos::handshake\"]Ao[2,\"iroh_relay::protos::relay\"]Ba[5,\"hyper::error\",\"hyper::error\"]Ee[6,\"iroh_quinn_proto::transport_parameters\",\"iroh_quinn_proto::transport_parameters\"]Be[5,\"reqwest::error\",\"reqwest::error\"]Cg[6,\"tokio_websockets::error\",\"tokio_websockets::error\"]Bi[6,\"iroh_relay::quic\",\"iroh_relay::quic\"]Dc[6,\"iroh_relay::protos::handshake\",\"iroh_relay::protos::handshake\"]Ck[6,\"iroh_relay::protos::relay\",\"iroh_relay::protos::relay\"]Ca[6,\"iroh::net_report\",\"iroh::net_report::probes\"]Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Bb[10,\"core::marker\",\"core::marker\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]1g[17,\"\"]f[1,\"\"]Ah[2,\"iroh_relay::protos\"]Af[2,\"iroh_quinn_proto\"]Ae[2,\"iroh::discovery\"]A`[2,\"iroh_bench\"]34Ae[2,\"iroh_dns_server\"]1Bb[2,\"iroh_quinn_proto::connection\"]166Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Ac[10,\"core::borrow\"]C`[10,\"bytes::buf::buf_mut\",\"bytes::buf::buf_mut\"]Bc[5,\"pkarr::client\",\"pkarr::client\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ba[5,\"async_compat\",\"async_compat\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Al[15,\"iroh::KeyParsingError\"]Ba[15,\"iroh_base::KeyParsingError\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Cb[10,\"core::future::future\",\"core::future::future\"]Ca[5,\"iroh_dns_server::dns\",\"iroh_dns_server::dns\"]An[10,\"core::hash\",\"core::hash\"]Cb[15,\"iroh_relay::protos::relay::RelayToClientMsg\"]Bm[6,\"core::net::ip_addr\",\"core::net::ip_addr\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]Bh[10,\"reloadable_core\",\"reloadable_core\"]Be[15,\"iroh_relay::server::CertConfig\"]Ad[5,\"iroh::endpoint\"]Ba[6,\"core::option\",\"core::option\"]g[17,\"\"]E`[10,\"tower_http::follow_redirect::policy\",\"tower_http::follow_redirect::policy\"]Ch[10,\"iroh::endpoint::presets\",\"iroh::endpoint::presets\"]Co[5,\"hickory_proto::rr::resource\",\"hickory_proto::rr::resource\"]Ca[5,\"iroh::net_report\",\"iroh::net_report::report\"]Ak[8,\"core::fmt\",\"core::fmt\"]Ba[6,\"core::result\",\"core::result\"]Be[8,\"std::io::error\",\"std::io::error\"]Bg[8,\"n0_snafu::error\",\"n0_snafu::error\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Cg[5,\"iroh_dns_server::server\",\"iroh_dns_server::server\"]?Ad[2,\"iroh::endpoint\"]Cd[6,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map\"]Ak[10,\"futures_core::stream\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Bc[5,\"alloc::string\",\"alloc::string\"]Bl[10,\"iroh_base::ticket\",\"iroh_base::ticket\"]Ak[5,\"core::any\",\"core::any\"]Ci[5,\"iroh_quinn_proto::varint\",\"iroh_quinn_proto::varint\"]Ad[5,\"iroh::endpoint\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bd[15,\"iroh_base::ticket::ParseError\"]A`[2,\"iroh_relay\"]Ah[2,\"iroh_relay::protos\"]Af[2,\"iroh_quinn_proto\"]Ae[2,\"iroh_dns_server\"]1Af[2,\"iroh::net_report\"]4041o[2,\"iroh_base\"]3Ae[10,\"iroh::endpoint\"]Bg[8,\"iroh_relay::dns\",\"iroh_relay::dns\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Co[5,\"iroh::discovery::pkarr::dht\",\"iroh::discovery::pkarr::dht\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]De[5,\"clap_builder::builder::command\",\"clap_builder::builder::command\"]Bc[15,\"iroh::endpoint::ConnectError\"]An[15,\"iroh_relay::quic::Error\"]Bi[5,\"core::task::wake\",\"core::task::wake\"]Cc[5,\"iroh_metrics::metrics\",\"iroh_metrics::metrics\"]Ad[10,\"core::default\"]A`[10,\"core::fmt\"]Bm[5,\"tokio::time::error\",\"tokio::time::error\"]Bl[15,\"iroh::discovery::mdns::DiscoveryEvent\"]Bc[10,\"axum_core::extract::from_ref\"]Ah[10,\"core::str::traits\"]Co[5,\"std::collections::hash::map\",\"std::collections::hash::map\"]Ak[5,\"std::time\",\"std::time\"]Cg[5,\"tonic::service::layered\",\"tonic::service::layered\"]Bj[15,\"iroh_relay::server::SupervisorError\"]Cb[5,\"iroh::net_report\",\"iroh::net_report::metrics\"]Ci[5,\"iroh_dns_server::metrics\",\"iroh_dns_server::metrics\"]Cf[5,\"iroh_relay::server\",\"iroh_relay::server::metrics\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Ad[5,\"iroh::endpoint\"]Cg[5,\"iroh::net_report\",\"iroh::net_report::options::imp\"]Ak[5,\"std::path\",\"std::path\"]Bk[5,\"dyn_clone::sealed\",\"dyn_clone::sealed\"]Bo[5,\"tokio::io::read_buf\",\"tokio::io::read_buf\"]Be[5,\"tonic::request\",\"tonic::request\"]Eg[5,\"hickory_server::server::request_handler\",\"hickory_server::server::request_handler\"]B`[15,\"iroh_relay::dns::DnsError\"]Al[10,\"reqwest::dns::resolve\"]Cg[5,\"tokio::runtime::runtime\",\"tokio::runtime::runtime\"]Cj[10,\"iroh_quinn_proto::crypto\",\"iroh_quinn_proto::crypto\"]Bd[15,\"iroh_relay::client::DialError\"]4Ad[10,\"alloc::borrow\"]Ad[10,\"core::convert\"]0Bg[15,\"iroh_relay::client::ConnectError\"]k[10,\"iroh\"]?j[2,\"iroh\"]Af[2,\"iroh::net_report\"]Ah[2,\"iroh_relay::server\"]Ae[2,\"iroh_dns_server\"]f[1,\"\"]Ad[2,\"iroh::endpoint\"]Ad[2,\"iroh::defaults\"]Bb[2,\"iroh_quinn_proto::connection\"]5Ad[5,\"iroh::endpoint\"]Bc[5,\"n0_error::any\",\"n0_error::any\"]Ce[5,\"iroh_dns_server::state\",\"iroh_dns_server::state\"]De[5,\"alloc::collections::btree::set\",\"alloc::collections::btree::set\"]Ch[6,\"iroh_dns_server::http\",\"iroh_dns_server::http::tls\"]Am[6,\"iroh_bench\",\"iroh_bench\"]Ag[10,\"core::ops::deref\"]Bm[15,\"iroh::endpoint::GetMappingAddressError\"]Ae[2,\"iroh_relay::dns\"]Bg[6,\"iroh_relay::dns\",\"iroh_relay::dns\"]Am[5,\"core::time\",\"core::time\"]A`[10,\"dyn_clone\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bd[15,\"iroh_base::ticket::ParseError\"]Ca[5,\"iroh_quinn::endpoint\",\"iroh_quinn::endpoint\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Bg[6,\"n0_error::error\",\"n0_error::error\"]4Ca[5,\"iroh_quinn::incoming\",\"iroh_quinn::incoming\"]2Bm[5,\"core::net::ip_addr\",\"core::net::ip_addr\"]0Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Am[10,\"iroh_metrics::iterable\"]Db[10,\"core::iter::traits::iterator\",\"core::iter::traits::iterator\"]An[10,\"tonic::service::layered\"]Am[15,\"iroh::endpoint::Source\"]An[10,\"n0_watcher\",\"n0_watcher\"]Ak[6,\"core::cmp\",\"core::cmp\"]Ad[5,\"iroh::endpoint\"]Bm[5,\"http::header::name\",\"http::header::name\"]Cc[5,\"iroh_dns_server::http\",\"iroh_dns_server::http\"]0B`[10,\"core::future::into_future\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Bd[15,\"iroh_relay::client::DialError\"]B`[15,\"iroh::endpoint::BindError\"]Bm[5,\"iroh_metrics::base\",\"iroh_metrics::base\"]B`[15,\"iroh_relay::dns::DnsError\"]Bm[8,\"core::num::nonzero\",\"core::num::nonzero\"]Bb[15,\"iroh::protocol::AcceptError\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Ae[2,\"iroh::discovery\"]Ag[2,\"iroh_base::ticket\"]Ao[6,\"url::parser\",\"url::parser\"]Bc[15,\"iroh_relay::dns::LookupError\"]Ao[2,\"iroh_relay::endpoint_info\"]Ae[6,\"iroh::discovery\"]Bk[6,\"iroh_base::ticket\",\"iroh_base::ticket\"]Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]A`[10,\"core::cmp\"]Al[2,\"iroh::discovery::pkarr\"]Ce[6,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Bi[5,\"iroh_relay::quic\",\"iroh_relay::quic\"]Cd[5,\"iroh::net_report\",\"iroh::net_report::reportgen\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]De[6,\"hickory_proto::rr::record_type\",\"hickory_proto::rr::record_type\"]Ad[5,\"iroh::endpoint\"]Ad[6,\"iroh::endpoint\"]Cb[15,\"iroh_relay::protos::relay::RelayToClientMsg\"]22Bh[10,\"serde_core::ser\",\"serde_core::ser\"]Ce[6,\"core::net::socket_addr\",\"core::net::socket_addr\"]Ah[2,\"iroh_relay::server\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Af[10,\"n0_error::error\"]Ba[5,\"http::status\",\"http::status\"]Ak[10,\"clap_builder::derive\"]Cj[10,\"iroh_quinn_proto::config\",\"iroh_quinn_proto::config\"]9Af[2,\"iroh_quinn_proto\"]0A`[2,\"iroh_quinn\"]f[3,\"\"]00j[2,\"iroh\"]0Ad[2,\"iroh::protocol\"]Be[6,\"iroh::protocol\",\"iroh::protocol\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Co[5,\"rustls::server::server_conn\",\"rustls::server::server_conn\"]Am[5,\"iroh_bench\",\"iroh_bench\"]Ad[5,\"iroh::endpoint\"]Bc[5,\"data_encoding\",\"data_encoding\"]Ae[10,\"serde_core::de\"]Bg[6,\"iroh_relay::dns\",\"iroh_relay::dns\"]o[5,\"iroh::dns\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Bd[15,\"iroh_relay::client::SendError\"]Bk[15,\"iroh::endpoint::AddEndpointAddrError\"]Bo[5,\"http::header::value\",\"http::header::value\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]0Cc[5,\"iroh_dns_server::http\",\"iroh_dns_server::http\"]Do[5,\"iroh_quinn_proto::config::transport\",\"iroh_quinn_proto::config::transport\"]Ae[10,\"tonic::request\"]Be[15,\"iroh_relay::server::CertConfig\"]Ae[2,\"iroh_relay::dns\"];B`[15,\"iroh_relay::dns::DnsError\"]Bg[15,\"iroh_relay::client::ConnectError\"]Be[15,\"iroh_relay::server::SpawnError\"]Bk[5,\"iroh_relay\",\"iroh_relay::ping_tracker\"]j[5,\"iroh\"]Bh[5,\"iroh_relay\",\"iroh_relay::relay_map\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]6Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Bd[15,\"iroh_relay::client::RecvError\"]Bd[15,\"iroh_relay::client::SendError\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]B`[15,\"iroh::endpoint::AlpnError\"]Ci[5,\"ring::error::unspecified\",\"ring::error::unspecified\"]A`[2,\"iroh_quinn\"]0Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Ce[5,\"rustls::crypto::signer\",\"rustls::crypto::signer\"]Co[5,\"rustls::client::client_conn\",\"rustls::client::client_conn\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ad[5,\"iroh::endpoint\"]Ad[2,\"iroh::endpoint\"]Ah[2,\"iroh_relay::client\"]Cm[6,\"iroh_quinn_proto::endpoint\",\"iroh_quinn_proto::endpoint\"]Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]Bm[6,\"iroh_relay::client\",\"iroh_relay::client\"]Ci[5,\"iroh_quinn_proto::shared\",\"iroh_quinn_proto::shared\"]Bf[10,\"serde_core::de\",\"serde_core::de\"]Co[5,\"iroh::discovery::pkarr::dht\",\"iroh::discovery::pkarr::dht\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Ca[5,\"iroh::discovery::dns\",\"iroh::discovery::dns\"]Ci[5,\"iroh_base::endpoint_addr\",\"iroh_base::endpoint_addr\"]j[5,\"iroh\"]Bj[5,\"iroh_base\",\"iroh_base::endpoint_addr\"]Ae[5,\"iroh::discovery\"]Ck[5,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]10Bb[10,\"core::iter::traits::collect\"]Am[10,\"iroh_metrics::iterable\"]D`[10,\"core::iter::traits::collect\",\"core::iter::traits::collect\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Cg[5,\"iroh_quinn_proto::frame\",\"iroh_quinn_proto::frame\"]Bc[15,\"iroh_relay::dns::LookupError\"]Ai[10,\"iroh_metrics::base\"]Bd[15,\"iroh_relay::client::DialError\"]Ad[5,\"iroh::endpoint\"]Ac[5,\"iroh::metrics\"]Cf[5,\"iroh_relay::server\",\"iroh_relay::server::metrics\"]Cg[5,\"hickory_resolver::error\",\"hickory_resolver::error\"]Do[5,\"iroh_quinn_proto::connection::paths\",\"iroh_quinn_proto::connection::paths\"]Co[5,\"rustls::server::server_conn\",\"rustls::server::server_conn\"]5Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]Ca[5,\"pkarr::signed_packet\",\"pkarr::signed_packet\"]Ce[5,\"core::net::socket_addr\",\"core::net::socket_addr\"]0Ad[6,\"iroh::endpoint\"]Ae[2,\"iroh::magicsock\"]A`[2,\"iroh_relay\"]l[10,\"snafu\"]Bm[5,\"iroh_relay::client\",\"iroh_relay::client\"]Ab[10,\"core::clone\"]Bb[15,\"iroh::discovery::ParseError\"]Ai[2,\"iroh::endpoint_info\"]Ao[2,\"iroh_relay::endpoint_info\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ai[6,\"iroh::endpoint_info\"]Ck[6,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Bg[5,\"iroh::discovery\",\"iroh::discovery\"]5421Aj[10,\"iroh::endpoint_info\"]Cl[10,\"iroh_relay::endpoint_info\",\"iroh_relay::endpoint_info\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Bh[10,\"iroh::discovery\",\"iroh::discovery\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Cc[5,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Bi[6,\"rustls_pki_types\",\"rustls_pki_types\"]Eo[6,\"iroh_quinn_proto::connection::streams::recv\",\"iroh_quinn_proto::connection::streams::recv\"]Be[5,\"iroh::protocol\",\"iroh::protocol\"]Bj[15,\"iroh_relay::server::SupervisorError\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Ca[15,\"iroh_relay::protos::common::FrameTypeError\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Ci[5,\"iroh_quinn_proto::coding\",\"iroh_quinn_proto::coding\"]o[2,\"iroh_base\"]j[2,\"iroh\"]A`[2,\"iroh_relay\"]Ak[2,\"iroh_dns_server::http\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Bi[5,\"rustls_pki_types\",\"rustls_pki_types\"]Ak[10,\"clap_builder::derive\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Dd[6,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map::endpoint_state\"]Dd[5,\"iroh::endpoint\",\"iroh::magicsock::endpoint_map::endpoint_state\"]Bf[6,\"iroh::endpoint\",\"iroh::magicsock\"]Ae[2,\"iroh::discovery\"]Bg[6,\"iroh::discovery\",\"iroh::discovery\"]Ak[2,\"iroh::discovery::mdns\"]Cc[6,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Bm[15,\"iroh::endpoint::GetMappingAddressError\"]D`[5,\"iroh::test_utils\",\"iroh::test_utils::dns_and_pkarr_servers\"]Co[5,\"iroh_base::ticket::endpoint\",\"iroh_base::ticket::endpoint\"]Ce[5,\"iroh_base::ticket\",\"iroh_base::ticket::endpoint\"]B`[2,\"iroh_relay::protos::common\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Cm[6,\"iroh_relay::protos::common\",\"iroh_relay::protos::common\"]Ak[10,\"clap_builder::derive\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Am[5,\"n0_watcher\",\"n0_watcher\"]Cg[5,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Ac[5,\"iroh::metrics\"]Ao[6,\"pkarr::keys\",\"pkarr::keys\"]Ad[6,\"iroh::endpoint\"]0Ca[5,\"iroh::net_report\",\"iroh::net_report::report\"]Bn[10,\"hickory_server::server::request_handler\"]Cc[8,\"ed25519_dalek::errors\",\"ed25519_dalek::errors\"]j[5,\"iroh\"]B`[5,\"iroh_base\",\"iroh_base::key\"]Da[6,\"simple_dns::simple_dns_error\",\"simple_dns::simple_dns_error\"]Di[5,\"iroh::discovery::static_provider\",\"iroh::discovery::static_provider\"]Be[15,\"iroh_relay::server::SpawnError\"]Bk[5,\"iroh_bench::stats\",\"iroh_bench::stats\"]Ad[5,\"iroh::endpoint\"]Bc[2,\"iroh::magicsock::endpoint_map\"]Bk[15,\"iroh::endpoint::ConnectWithOptsError\"]44Cg[6,\"iroh_dns_server::config\",\"iroh_dns_server::config\"]Bm[5,\"iroh_relay::server\",\"iroh_relay::server\"]4B`[15,\"iroh::endpoint::AlpnError\"]Da[6,\"iroh_quinn_proto::connection\",\"iroh_quinn_proto::connection\"]Ad[6,\"iroh::endpoint\"]7Bc[5,\"iroh::metrics\",\"iroh::metrics\"]Bi[15,\"iroh::discovery::pkarr::PkarrError\"]Bg[15,\"iroh_relay::client::ConnectError\"]B`[15,\"iroh_relay::dns::DnsError\"]Bi[15,\"iroh::endpoint_info::EncodingError\"]Bo[15,\"iroh_relay::endpoint_info::EncodingError\"]j[2,\"iroh\"]o[2,\"iroh_base\"]Be[6,\"iroh_base::key\",\"iroh_base::key\"]j[6,\"iroh\"]B`[6,\"iroh_base\",\"iroh_base::key\"]Eo[5,\"hickory_server::authority::message_response\",\"hickory_server::authority::message_response\"]Ai[10,\"iroh_metrics::base\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Bf[10,\"iroh::protocol\",\"iroh::protocol\"]Bd[15,\"iroh_relay::client::DialError\"]Db[6,\"iroh_dns_server::http\",\"iroh_dns_server::http::rate_limiting\"]Bh[5,\"iroh_relay\",\"iroh_relay::relay_map\"]Bo[10,\"hickory_server::server::response_handler\"]Ah[2,\"iroh_relay::server\"]Bm[6,\"iroh_relay::server\",\"iroh_relay::server\"]Do[5,\"iroh_quinn_proto::config::transport\",\"iroh_quinn_proto::config::transport\"]Ad[5,\"iroh::endpoint\"]Bm[5,\"alloc::collections\",\"alloc::collections\"]Bg[15,\"iroh_relay::protos::relay::Error\"]Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]f[3,\"\"]Ae[2,\"iroh::discovery\"]5Bi[5,\"iroh::test_utils\",\"iroh::test_utils\"]Ao[2,\"iroh_relay::protos::relay\"]Ck[6,\"iroh_relay::protos::relay\",\"iroh_relay::protos::relay\"]Am[6,\"iroh_bench\",\"iroh_bench\"]77Ac[5,\"iroh::metrics\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]43Bk[15,\"iroh_relay::protos::handshake::Error\"]Ai[10,\"iri_string::format\"]o[10,\"num_enum\"]Bb[15,\"iroh::discovery::ParseError\"]Bl[15,\"iroh_relay::endpoint_info::ParseError\"]Ca[15,\"iroh_relay::protos::common::FrameTypeError\"]B`[15,\"iroh::endpoint::AlpnError\"]>Dg[5,\"tokio_util::task::abort_on_drop\",\"tokio_util::task::abort_on_drop\"]Ae[10,\"iroh::endpoint\"]Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]1Bd[15,\"iroh_relay::client::DialError\"]Cg[5,\"iroh_relay::server\",\"iroh_relay::server::resolver\"]Ad[6,\"iroh::endpoint\"]Ad[5,\"iroh::endpoint\"]Am[6,\"iroh_bench\",\"iroh_bench\"]6Bf[10,\"iroh::protocol\",\"iroh::protocol\"]Ae[2,\"iroh::discovery\"]Bg[6,\"iroh::discovery\",\"iroh::discovery\"]Bi[15,\"iroh::endpoint_info::DecodingError\"]Bo[15,\"iroh_relay::endpoint_info::DecodingError\"]Bo[5,\"http::header::value\",\"http::header::value\"]7j[5,\"iroh\"]Bf[5,\"iroh_base\",\"iroh_base::relay_url\"]Bb[10,\"rustls::server::server_conn\"]::Bg[5,\"iroh::discovery\",\"iroh::discovery\"]Al[15,\"iroh::KeyParsingError\"]Ba[15,\"iroh_base::KeyParsingError\"]Ca[5,\"iroh::discovery::dns\",\"iroh::discovery::dns\"]Bg[15,\"iroh_relay::client::ConnectError\"]Bf[15,\"iroh::discovery::DiscoveryError\"]Ee[5,\"iroh_quinn_proto::transport_parameters\",\"iroh_quinn_proto::transport_parameters\"]Bk[15,\"iroh_relay::protos::handshake::Error\"]Ad[2,\"iroh::endpoint\"]Bf[6,\"iroh::endpoint\",\"iroh::magicsock\"]1Be[6,\"iroh::endpoint\",\"iroh::endpoint\"]3Bd[15,\"iroh_relay::client::SendError\"]Bi[15,\"iroh::endpoint_info::EncodingError\"]Bo[15,\"iroh_relay::endpoint_info::EncodingError\"]9Bg[5,\"iroh_relay::dns\",\"iroh_relay::dns\"]Cc[5,\"iroh::discovery::mdns\",\"iroh::discovery::mdns\"]Ce[5,\"iroh::discovery::pkarr\",\"iroh::discovery::pkarr\"]Ci[5,\"iroh_quinn_proto::varint\",\"iroh_quinn_proto::varint\"]Ad[5,\"iroh::endpoint\"]2Be[5,\"iroh::endpoint\",\"iroh::endpoint\"]Ai[5,\"num_enum\",\"num_enum\"]Ci[5,\"iroh_quinn_proto::config\",\"iroh_quinn_proto::config\"]Af[2,\"iroh::test_utils\"]>5use iroh_bench::quinn;
6use iroh_bench::{Commands, Opt, configure_tracing_subscriber, iroh, rt, s2n};
7use iroh_metrics::{MetricValue, MetricsGroup};
-8use n0_snafu::Result;
+8use n0_error::Result;
9
10fn main() {
11 let cmd = Commands::parse();
diff --git a/pr/3561/docs/src/iroh/discovery.rs.html b/pr/3561/docs/src/iroh/discovery.rs.html
index 8261964c2b..f14a765909 100644
--- a/pr/3561/docs/src/iroh/discovery.rs.html
+++ b/pr/3561/docs/src/iroh/discovery.rs.html
@@ -65,7 +65,7 @@
65//! endpoint::RelayMode,
66//! };
67//!
-68//! # async fn wrapper() -> n0_snafu::Result<()> {
+68//! # async fn wrapper() -> n0_error::Result<()> {
69//! let ep = Endpoint::empty_builder(RelayMode::Default)
70//! .discovery(PkarrPublisher::n0_dns())
71//! .discovery(DnsDiscovery::n0_dns())
@@ -86,7 +86,7 @@
86//! # Endpoint, SecretKey,
87//! # };
88//! #
-89//! # async fn wrapper() -> n0_snafu::Result<()> {
+89//! # async fn wrapper() -> n0_error::Result<()> {
90//! let ep = Endpoint::empty_builder(RelayMode::Default)
91//! .discovery(PkarrPublisher::n0_dns())
92//! .discovery(DnsDiscovery::n0_dns())
@@ -942,7 +942,7 @@
942 // we skip accept() errors, they can be caused by retransmits
943 while let Some(connecting) = ep.accept().await.and_then(|inc| inc.accept().ok()) {
944 // Just accept incoming connections, but don't do anything with them.
-945 let conn = connecting.await.context("connecting")?;
+945 let conn = connecting.await.std_context("connecting")?;
946 connections.push(conn);
947 }
948
@@ -995,7 +995,7 @@
995 let state = State::new(origin.clone());
996 let (nameserver, _dns_drop_guard) = run_dns_server(state.clone())
997 .await
-998 .context("Running DNS server")?;
+998 .std_context("Running DNS server")?;
999
1000 let secret_key = SecretKey::generate(&mut rng);
1001 let endpoint_info = EndpointInfo::new(secret_key.public())
@@ -1003,7 +1003,7 @@
1003 let signed_packet = endpoint_info.to_pkarr_signed_packet(&secret_key, 30)?;
1004 state
1005 .upsert(signed_packet)
-1006 .context("update and insert signed packet")?;
+1006 .std_context("update and insert signed packet")?;
1007
1008 let resolver = DnsResolver::with_nameserver(nameserver);
1009 let resolved = resolver
@@ -1023,7 +1023,7 @@
1023
1024 let dns_pkarr_server = DnsPkarrServer::run_with_origin(origin.clone())
1025 .await
-1026 .context("DnsPkarrServer")?;
+1026 .std_context("DnsPkarrServer")?;
1027
1028 let secret_key = SecretKey::generate(&mut rng);
1029 let endpoint_id = secret_key.public();
@@ -1042,7 +1042,7 @@
1042 dns_pkarr_server
1043 .on_endpoint(&endpoint_id, PUBLISH_TIMEOUT)
1044 .await
-1045 .context("wait for on endpoint update")?;
+1045 .std_context("wait for on endpoint update")?;
1046 let resolved = resolver
1047 .lookup_endpoint_by_id(&endpoint_id, &origin)
1048 .await?;
@@ -1066,7 +1066,7 @@
1066 async fn pkarr_publish_dns_discover() -> Result<()> {
1067 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0u64);
1068
-1069 let dns_pkarr_server = DnsPkarrServer::run().await.context("DnsPkarrServer run")?;
+1069 let dns_pkarr_server = DnsPkarrServer::run().await.std_context("DnsPkarrServer run")?;
1070 let (relay_map, _relay_url, _relay_guard) = run_relay_server().await?;
1071
1072 let (ep1, _guard1) = ep_with_discovery(&mut rng, &relay_map, &dns_pkarr_server).await?;
@@ -1076,7 +1076,7 @@
1076 dns_pkarr_server
1077 .on_endpoint(&ep1.id(), PUBLISH_TIMEOUT)
1078 .await
-1079 .context("wait for on endpoint update")?;
+1079 .std_context("wait for on endpoint update")?;
1080
1081 // we connect only by endpoint id!
1082 let _conn = ep2.connect(ep1.id(), TEST_ALPN).await?;
@@ -1103,7 +1103,7 @@
1103 async move {
1104 // we skip accept() errors, they can be caused by retransmits
1105 while let Some(connecting) = ep.accept().await.and_then(|inc| inc.accept().ok()) {
-1106 let _conn = connecting.await.context("connecting")?;
+1106 let _conn = connecting.await.std_context("connecting")?;
1107 // Just accept incoming connections, but don't do anything with them.
1108 }
1109
diff --git a/pr/3561/docs/src/iroh/discovery/mdns.rs.html b/pr/3561/docs/src/iroh/discovery/mdns.rs.html
index 99f3ca552b..1031c01241 100644
--- a/pr/3561/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3561/docs/src/iroh/discovery/mdns.rs.html
@@ -591,7 +591,7 @@
591 ..
592 } = tokio::time::timeout(Duration::from_secs(5), s1.next())
593 .await
-594 .context("timeout")?
+594 .std_context("timeout")?
595 .unwrap()
596 else {
597 panic!("Received unexpected discovery event");
@@ -601,7 +601,7 @@
601 ..
602 } = tokio::time::timeout(Duration::from_secs(5), s2.next())
603 .await
-604 .context("timeout")?
+604 .std_context("timeout")?
605 .unwrap()
606 else {
607 panic!("Received unexpected discovery event");
@@ -632,7 +632,7 @@
632 loop {
633 let event = tokio::time::timeout(Duration::from_secs(5), s1.next())
634 .await
-635 .context("timeout")?
+635 .std_context("timeout")?
636 .expect("Stream should not be closed");
637
638 match event {
@@ -653,7 +653,7 @@
653 loop {
654 let event = tokio::time::timeout(Duration::from_secs(10), s1.next())
655 .await
-656 .context("timeout waiting for expiration event")?
+656 .std_context("timeout waiting for expiration event")?
657 .expect("Stream should not be closed");
658
659 match event {
@@ -717,7 +717,7 @@
717 };
718 tokio::time::timeout(Duration::from_secs(5), test)
719 .await
-720 .context("timeout")?
+720 .std_context("timeout")?
721 }
722
723 #[tokio::test]
diff --git a/pr/3561/docs/src/iroh/discovery/static_provider.rs.html b/pr/3561/docs/src/iroh/discovery/static_provider.rs.html
index 1c02b51a05..f453cf1bea 100644
--- a/pr/3561/docs/src/iroh/discovery/static_provider.rs.html
+++ b/pr/3561/docs/src/iroh/discovery/static_provider.rs.html
@@ -41,7 +41,7 @@
41/// use iroh_base::SecretKey;
42///
43/// # #[tokio::main]
-44/// # async fn main() -> n0_snafu::Result<()> {
+44/// # async fn main() -> n0_error::Result<()> {
45/// // Create the discovery service and endpoint.
46/// let discovery = StaticProvider::new();
47///
@@ -125,8 +125,8 @@
125 /// # fn get_addrs() -> Vec<EndpointAddr> {
126 /// # Vec::new()
127 /// # }
-128 /// # #[tokio::main]
-129 /// # async fn main() -> n0_snafu::Result<()> {
+128/// # #[tokio::main]
+129/// # async fn main() -> n0_error::Result<()> {
130 /// // get addrs from somewhere
131 /// let addrs = get_addrs();
132 ///
diff --git a/pr/3561/docs/src/iroh/endpoint.rs.html b/pr/3561/docs/src/iroh/endpoint.rs.html
index 094496c6dd..17db4528bd 100644
--- a/pr/3561/docs/src/iroh/endpoint.rs.html
+++ b/pr/3561/docs/src/iroh/endpoint.rs.html
@@ -827,7 +827,7 @@
827 /// The observed [`EndpointAddr`] will have the current [`RelayUrl`] and direct addresses.
828 ///
829 /// ```no_run
-830 /// # async fn wrapper() -> n0_snafu::Result {
+830 /// # async fn wrapper() -> n0_error::Result<()> {
831 /// use iroh::{Endpoint, Watcher};
832 ///
833 /// let endpoint = Endpoint::builder()
@@ -1022,7 +1022,7 @@
1022 /// ```rust
1023 /// # use std::collections::BTreeMap;
1024 /// # use iroh::endpoint::Endpoint;
-1025 /// # async fn wrapper() -> n0_snafu::Result {
+1025 /// # async fn wrapper() -> n0_error::Result<()> {
1026 /// let endpoint = Endpoint::bind().await?;
1027 /// assert_eq!(endpoint.metrics().magicsock.recv_datagrams.get(), 0);
1028 /// # Ok(())
@@ -1040,7 +1040,7 @@
1040 /// # use std::collections::BTreeMap;
1041 /// # use iroh_metrics::{Metric, MetricsGroup, MetricValue, MetricsGroupSet};
1042 /// # use iroh::endpoint::Endpoint;
-1043 /// # async fn wrapper() -> n0_snafu::Result {
+1043 /// # async fn wrapper() -> n0_error::Result<()> {
1044 /// let endpoint = Endpoint::bind().await?;
1045 /// let metrics: BTreeMap<String, MetricValue> = endpoint
1046 /// .metrics()
@@ -1063,7 +1063,7 @@
1063 /// ```rust
1064 /// # use iroh_metrics::{Registry, MetricsSource};
1065 /// # use iroh::endpoint::Endpoint;
-1066 /// # async fn wrapper() -> n0_snafu::Result {
+1066 /// # async fn wrapper() -> n0_error::Result<()> {
1067 /// let endpoint = Endpoint::bind().await?;
1068 /// let mut registry = Registry::default();
1069 /// registry.register_all(endpoint.metrics());
@@ -1086,8 +1086,8 @@
1086 /// # use std::{sync::{Arc, RwLock}, time::Duration};
1087 /// # use iroh_metrics::{Registry, MetricsSource};
1088 /// # use iroh::endpoint::Endpoint;
-1089 /// # use n0_snafu::ResultExt;
-1090 /// # async fn wrapper() -> n0_snafu::Result {
+1089 /// # use n0_error::StackResultExt;
+1090 /// # async fn wrapper() -> n0_error::Result<()> {
1091 /// // Create a registry, wrapped in a read-write lock so that we can register and serve
1092 /// // the metrics independently.
1093 /// let registry = Arc::new(RwLock::new(Registry::default()));
@@ -3019,7 +3019,7 @@
3019 let mut registry = Registry::default();
3020 register_endpoint(&mut registry, &client);
3021 register_endpoint(&mut registry, &server);
-3022 let s = registry.encode_openmetrics_to_string()?;
+3022 let s = registry.encode_openmetrics_to_string().e()?;
3023 assert!(s.contains(r#"magicsock_endpoints_contacted_directly_total{id="3b6a27bcce"} 1"#));
3024 assert!(s.contains(r#"magicsock_endpoints_contacted_directly_total{id="8a88e3dd74"} 1"#));
3025 Ok(())
@@ -3125,7 +3125,7 @@
3125 let endpoint = Endpoint::empty_builder(RelayMode::Staging).bind().await?;
3126
3127 // can get a first report
-3128 endpoint.net_report().updated().await?;
+3128 endpoint.net_report().updated().await.e()?;
3129
3130 Ok(())
3131 }
diff --git a/pr/3561/docs/src/iroh/endpoint/presets.rs.html b/pr/3561/docs/src/iroh/endpoint/presets.rs.html
index 68da930d9a..309e888873 100644
--- a/pr/3561/docs/src/iroh/endpoint/presets.rs.html
+++ b/pr/3561/docs/src/iroh/endpoint/presets.rs.html
@@ -3,7 +3,7 @@
3//! # Example
4//!
5//! ```no_run
-6//! # async fn wrapper() -> n0_snafu::Result {
+6//! # async fn wrapper() -> n0_error::Result<()> {
7//! use iroh::{Endpoint, RelayMode, Watcher, endpoint::presets};
8//!
9//! let endpoint = Endpoint::empty_builder(RelayMode::Disabled)
diff --git a/pr/3561/docs/src/iroh/lib.rs.html b/pr/3561/docs/src/iroh/lib.rs.html
index e3ba119664..9024d3b01e 100644
--- a/pr/3561/docs/src/iroh/lib.rs.html
+++ b/pr/3561/docs/src/iroh/lib.rs.html
@@ -9,8 +9,8 @@
9//!
10//! ```no_run
11//! # use iroh::{Endpoint, EndpointAddr};
-12//! # use n0_snafu::ResultExt;
-13//! # async fn wrapper() -> n0_snafu::Result {
+12//! # use n0_error::StackResultExt;
+13//! # async fn wrapper() -> n0_error::Result<()> {
14//! let addr: EndpointAddr = todo!();
15//! let ep = Endpoint::bind().await?;
16//! let conn = ep.connect(addr, b"my-alpn").await?;
@@ -27,8 +27,8 @@
27//!
28//! ```no_run
29//! # use iroh::{Endpoint, EndpointAddr};
-30//! # use n0_snafu::ResultExt;
-31//! # async fn wrapper() -> n0_snafu::Result {
+30//! # use n0_error::StackResultExt;
+31//! # async fn wrapper() -> n0_error::Result<()> {
32//! let ep = Endpoint::builder()
33//! .alpns(vec![b"my-alpn".to_vec()])
34//! .bind()
@@ -171,7 +171,7 @@
171//!
172//! ```no_run
173//! use iroh::{Endpoint, EndpointAddr};
-174//! use n0_snafu::{Result, ResultExt};
+174//! use n0_error::{Result, StackResultExt};
175//!
176//! async fn connect(addr: EndpointAddr) -> Result<()> {
177//! // The Endpoint is the central object that manages an iroh node.
@@ -197,7 +197,7 @@
197//! ```no_run
198//! use iroh::{Endpoint, EndpointAddr};
199//! use n0_future::StreamExt;
-200//! use n0_snafu::{Result, ResultExt};
+200//! use n0_error::{Result, StackResultExt};
201//!
202//! async fn accept() -> Result<()> {
203//! // To accept connections at least one ALPN must be configured.
diff --git a/pr/3561/docs/src/iroh/magicsock.rs.html b/pr/3561/docs/src/iroh/magicsock.rs.html
index 71524c2b45..07dc05e396 100644
--- a/pr/3561/docs/src/iroh/magicsock.rs.html
+++ b/pr/3561/docs/src/iroh/magicsock.rs.html
@@ -2697,7 +2697,7 @@
2697 }
2698 })
2699 .await
-2700 .context("timeout")?;
+2700 .std_context("timeout")?;
2701 info!("all endpoints meshed");
2702 Ok(tasks)
2703 }
@@ -2708,24 +2708,24 @@
2708 let conn = ep.endpoint.accept().await.expect("no conn");
2709
2710 info!("connecting");
-2711 let conn = conn.await.context("connecting")?;
+2711 let conn = conn.await.std_context("connecting")?;
2712 info!("accepting bi");
-2713 let (mut send_bi, mut recv_bi) = conn.accept_bi().await.context("accept bi")?;
+2713 let (mut send_bi, mut recv_bi) = conn.accept_bi().await.std_context("accept bi")?;
2714
2715 info!("reading");
2716 let val = recv_bi
2717 .read_to_end(usize::MAX)
2718 .await
-2719 .context("read to end")?;
+2719 .std_context("read to end")?;
2720
2721 info!("replying");
2722 for chunk in val.chunks(12) {
-2723 send_bi.write_all(chunk).await.context("write all")?;
+2723 send_bi.write_all(chunk).await.std_context("write all")?;
2724 }
2725
2726 info!("finishing");
-2727 send_bi.finish().context("finish")?;
-2728 send_bi.stopped().await.context("stopped")?;
+2727 send_bi.finish().std_context("finish")?;
+2728 send_bi.stopped().await.std_context("stopped")?;
2729
2730 let stats = conn.stats();
2731 info!("stats: {:#?}", stats);
@@ -2757,20 +2757,20 @@
2757 let conn = ep.endpoint.connect(dest, ALPN).await?;
2758
2759 info!("opening bi");
-2760 let (mut send_bi, mut recv_bi) = conn.open_bi().await.context("open bi")?;
+2760 let (mut send_bi, mut recv_bi) = conn.open_bi().await.std_context("open bi")?;
2761
2762 info!("writing message");
-2763 send_bi.write_all(msg).await.context("write all")?;
+2763 send_bi.write_all(msg).await.std_context("write all")?;
2764
2765 info!("finishing");
-2766 send_bi.finish().context("finish")?;
-2767 send_bi.stopped().await.context("stopped")?;
+2766 send_bi.finish().std_context("finish")?;
+2767 send_bi.stopped().await.std_context("stopped")?;
2768
2769 info!("reading_to_end");
2770 let val = recv_bi
2771 .read_to_end(usize::MAX)
2772 .await
-2773 .context("read to end")?;
+2773 .std_context("read to end")?;
2774 assert_eq!(
2775 val,
2776 msg,
@@ -2921,7 +2921,7 @@
2921 test_two_devices_roundtrip_network_change_impl(),
2922 )
2923 .await
-2924 .context("timeout")?
+2924 .std_context("timeout")?
2925 }
2926
2927 /// Same structure as `test_two_devices_roundtrip_quinn_magic`, but interrupts regularly
@@ -3147,7 +3147,7 @@
3147 mapped_addr.private_socket_addr(),
3148 &tls::name::encode(endpoint_id),
3149 )
-3150 .context("connect")?;
+3150 .std_context("connect")?;
3151 let connection = connect.await.e()?;
3152 Ok(connection)
3153 }
@@ -3191,12 +3191,12 @@
3191 // This needs an accept task
3192 let accept_task = tokio::spawn({
3193 async fn accept(ep: quinn::Endpoint) -> Result<()> {
-3194 let incoming = ep.accept().await.context("no incoming")?;
+3194 let incoming = ep.accept().await.std_context("no incoming")?;
3195 let _conn = incoming
3196 .accept()
-3197 .context("accept")?
+3197 .std_context("accept")?
3198 .await
-3199 .context("connecting")?;
+3199 .std_context("connecting")?;
3200
3201 // Keep this connection alive for a while
3202 tokio::time::sleep(Duration::from_secs(10)).await;
@@ -3268,14 +3268,14 @@
3268 // We need a task to accept the connection.
3269 let accept_task = tokio::spawn({
3270 async fn accept(ep: quinn::Endpoint) -> Result<()> {
-3271 let incoming = ep.accept().await.context("no incoming")?;
+3271 let incoming = ep.accept().await.std_context("no incoming")?;
3272 let conn = incoming
3273 .accept()
-3274 .context("accept")?
+3274 .std_context("accept")?
3275 .await
-3276 .context("connecting")?;
-3277 let mut stream = conn.accept_uni().await.context("accept uni")?;
-3278 stream.read_to_end(1 << 16).await.context("read to end")?;
+3276 .std_context("connecting")?;
+3277 let mut stream = conn.accept_uni().await.std_context("accept uni")?;
+3278 stream.read_to_end(1 << 16).await.std_context("read to end")?;
3279 info!("accept finished");
3280 Ok(())
3281 }
diff --git a/pr/3561/docs/src/iroh_bench/iroh.rs.html b/pr/3561/docs/src/iroh_bench/iroh.rs.html
index c5bb6cce42..61edb24770 100644
--- a/pr/3561/docs/src/iroh_bench/iroh.rs.html
+++ b/pr/3561/docs/src/iroh_bench/iroh.rs.html
@@ -8,7 +8,7 @@
8 Endpoint, EndpointAddr, RelayMode, RelayUrl,
9 endpoint::{Connection, ConnectionError, RecvStream, SendStream, TransportConfig},
10};
-11use n0_snafu::{Result, ResultExt};
+11use n0_error::{Result, StackResultExt, StdResultExt};
12use tracing::{trace, warn};
13
14use crate::{
@@ -120,7 +120,7 @@
120 let connection = endpoint
121 .connect(server_addr, ALPN)
122 .await
-123 .context("unable to connect")?;
+123 .std_context("unable to connect")?;
124 trace!("connected");
125
126 Ok((endpoint, connection))
@@ -200,21 +200,21 @@
200 stream
201 .write_chunk(bytes_data.clone())
202 .await
-203 .context("failed sending data")?;
+203 .std_context("failed sending data")?;
204 }
205
206 if remaining != 0 {
207 stream
208 .write_chunk(bytes_data.slice(0..remaining))
209 .await
-210 .context("failed sending data")?;
+210 .std_context("failed sending data")?;
211 }
212
-213 stream.finish().context("failed finishing stream")?;
+213 stream.finish().std_context("failed finishing stream")?;
214 stream
215 .stopped()
216 .await
-217 .context("failed to wait for stream to be stopped")?;
+217 .std_context("failed to wait for stream to be stopped")?;
218
219 Ok(())
220}
@@ -229,7 +229,7 @@
229 let (mut send_stream, mut recv_stream) = connection
230 .open_bi()
231 .await
-232 .context("failed to open stream")?;
+232 .std_context("failed to open stream")?;
233
234 send_data_on_stream(&mut send_stream, upload_size).await?;
235
@@ -258,7 +258,7 @@
258 continue;
259 }
260 };
-261 let connection = connecting.await.context("handshake failed")?;
+261 let connection = connecting.await.std_context("handshake failed")?;
262
263 server_tasks.push(tokio::spawn(async move {
264 loop {
@@ -275,7 +275,7 @@
275 tokio::spawn(async move {
276 drain_stream(&mut recv_stream, opt.read_unordered).await?;
277 send_data_on_stream(&mut send_stream, opt.download_size).await?;
-278 Ok::<_, n0_snafu::Error>(())
+278 Ok::<_, n0_error::AnyError>(())
279 });
280 }
281
diff --git a/pr/3561/docs/src/iroh_bench/lib.rs.html b/pr/3561/docs/src/iroh_bench/lib.rs.html
index 8b5af0f273..628570e4cb 100644
--- a/pr/3561/docs/src/iroh_bench/lib.rs.html
+++ b/pr/3561/docs/src/iroh_bench/lib.rs.html
@@ -6,7 +6,7 @@
6};
7
8use clap::Parser;
-9use n0_snafu::Result;
+9use n0_error::Result;
10use stats::Stats;
11use tokio::{
12 runtime::{Builder, Runtime},
diff --git a/pr/3561/docs/src/iroh_bench/quinn.rs.html b/pr/3561/docs/src/iroh_bench/quinn.rs.html
index ea393e9b8b..94a7d64cd6 100644
--- a/pr/3561/docs/src/iroh_bench/quinn.rs.html
+++ b/pr/3561/docs/src/iroh_bench/quinn.rs.html
@@ -5,7 +5,7 @@
5};
6
7use bytes::Bytes;
-8use n0_snafu::{Result, ResultExt};
+8use n0_error::{Result, StdResultExt};
9use quinn::{
10 Connection, Endpoint, RecvStream, SendStream, TransportConfig, crypto::rustls::QuicClientConfig,
11};
@@ -91,7 +91,7 @@
91 .connect_with(client_config, server_addr, "localhost")
92 .unwrap()
93 .await
-94 .context("unable to connect")?;
+94 .std_context("unable to connect")?;
95 trace!("connected");
96
97 Ok((endpoint, connection))
@@ -171,21 +171,21 @@
171 stream
172 .write_chunk(bytes_data.clone())
173 .await
-174 .context("failed sending data")?;
+174 .std_context("failed sending data")?;
175 }
176
177 if remaining != 0 {
178 stream
179 .write_chunk(bytes_data.slice(0..remaining))
180 .await
-181 .context("failed sending data")?;
+181 .std_context("failed sending data")?;
182 }
183
-184 stream.finish().context("failed finishing stream")?;
+184 stream.finish().std_context("failed finishing stream")?;
185 stream
186 .stopped()
187 .await
-188 .context("failed to wait for stream to be stopped")?;
+188 .std_context("failed to wait for stream to be stopped")?;
189
190 Ok(())
191}
@@ -200,7 +200,7 @@
200 let (mut send_stream, mut recv_stream) = connection
201 .open_bi()
202 .await
-203 .context("failed to open stream")?;
+203 .std_context("failed to open stream")?;
204
205 send_data_on_stream(&mut send_stream, upload_size).await?;
206
@@ -229,7 +229,7 @@
229 continue;
230 }
231 };
-232 let connection = connecting.await.context("handshake failed")?;
+232 let connection = connecting.await.std_context("handshake failed")?;
233
234 server_tasks.push(tokio::spawn(async move {
235 loop {
@@ -246,7 +246,7 @@
246 tokio::spawn(async move {
247 drain_stream(&mut recv_stream, opt.read_unordered).await?;
248 send_data_on_stream(&mut send_stream, opt.download_size).await?;
-249 Ok::<_, n0_snafu::Error>(())
+249 Ok::<_, n0_error::AnyError>(())
250 });
251 }
252
diff --git a/pr/3561/docs/src/iroh_dns_server/config.rs.html b/pr/3561/docs/src/iroh_dns_server/config.rs.html
index 2aef1cb158..a6d4c54bcd 100644
--- a/pr/3561/docs/src/iroh_dns_server/config.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/config.rs.html
@@ -7,7 +7,7 @@
7 time::Duration,
8};
9
-10use n0_snafu::{Result, ResultExt};
+10use n0_error::{Result, StackResultExt, StdResultExt};
11use serde::{Deserialize, Serialize};
12use tracing::info;
13
@@ -162,87 +162,91 @@
162 );
163 let s = tokio::fs::read_to_string(path.as_ref())
164 .await
-165 .with_context(|| format!("failed to read {}", path.as_ref().to_string_lossy()))?;
-166 let config: Config = toml::from_str(&s).e()?;
-167 Ok(config)
-168 }
-169
-170 /// Get the data directory.
-171 pub fn data_dir() -> Result<PathBuf> {
-172 let dir = if let Some(val) = env::var_os("IROH_DNS_DATA_DIR") {
-173 PathBuf::from(val)
-174 } else {
-175 let path = dirs_next::data_dir()
-176 .context("operating environment provides no directory for application data")?;
-177
-178 path.join("iroh-dns")
-179 };
-180 Ok(dir)
-181 }
-182
-183 /// Get the path to the store database file.
-184 pub fn signed_packet_store_path() -> Result<PathBuf> {
-185 Ok(Self::data_dir()?.join("signed-packets-1.db"))
-186 }
-187
-188 /// Get the address where the metrics server should be bound, if set.
-189 pub(crate) fn metrics_addr(&self) -> Option<SocketAddr> {
-190 match &self.metrics {
-191 None => Some(DEFAULT_METRICS_ADDR),
-192 Some(conf) => match conf.disabled {
-193 true => None,
-194 false => Some(conf.bind_addr.unwrap_or(DEFAULT_METRICS_ADDR)),
-195 },
-196 }
-197 }
-198
-199 pub(crate) fn mainline_enabled(&self) -> Option<BootstrapOption> {
-200 match self.mainline.as_ref() {
-201 None => None,
-202 Some(MainlineConfig { enabled: false, .. }) => None,
-203 Some(MainlineConfig {
-204 bootstrap: Some(bootstrap),
-205 ..
-206 }) => Some(BootstrapOption::Custom(bootstrap.clone())),
+165 .std_context(format!(
+166 "failed to read {}",
+167 path.as_ref().to_string_lossy()
+168 ))?;
+169 let config: Config = toml::from_str(&s).e()?;
+170 Ok(config)
+171 }
+172
+173 /// Get the data directory.
+174 pub fn data_dir() -> Result<PathBuf> {
+175 let dir = if let Some(val) = env::var_os("IROH_DNS_DATA_DIR") {
+176 PathBuf::from(val)
+177 } else {
+178 let path = dirs_next::data_dir().std_context(
+179 "operating environment provides no directory for application data",
+180 )?;
+181
+182 path.join("iroh-dns")
+183 };
+184 Ok(dir)
+185 }
+186
+187 /// Get the path to the store database file.
+188 pub fn signed_packet_store_path() -> Result<PathBuf> {
+189 Ok(Self::data_dir()?.join("signed-packets-1.db"))
+190 }
+191
+192 /// Get the address where the metrics server should be bound, if set.
+193 pub(crate) fn metrics_addr(&self) -> Option<SocketAddr> {
+194 match &self.metrics {
+195 None => Some(DEFAULT_METRICS_ADDR),
+196 Some(conf) => match conf.disabled {
+197 true => None,
+198 false => Some(conf.bind_addr.unwrap_or(DEFAULT_METRICS_ADDR)),
+199 },
+200 }
+201 }
+202
+203 pub(crate) fn mainline_enabled(&self) -> Option<BootstrapOption> {
+204 match self.mainline.as_ref() {
+205 None => None,
+206 Some(MainlineConfig { enabled: false, .. }) => None,
207 Some(MainlineConfig {
-208 bootstrap: None, ..
-209 }) => Some(BootstrapOption::Default),
-210 }
-211 }
-212}
-213
-214impl Default for Config {
-215 fn default() -> Self {
-216 Self {
-217 http: Some(HttpConfig {
-218 port: 8080,
-219 bind_addr: None,
-220 }),
-221 https: Some(HttpsConfig {
-222 port: 8443,
+208 bootstrap: Some(bootstrap),
+209 ..
+210 }) => Some(BootstrapOption::Custom(bootstrap.clone())),
+211 Some(MainlineConfig {
+212 bootstrap: None, ..
+213 }) => Some(BootstrapOption::Default),
+214 }
+215 }
+216}
+217
+218impl Default for Config {
+219 fn default() -> Self {
+220 Self {
+221 http: Some(HttpConfig {
+222 port: 8080,
223 bind_addr: None,
-224 domains: vec!["localhost".to_string()],
-225 cert_mode: CertMode::SelfSigned,
-226 letsencrypt_contact: None,
-227 letsencrypt_prod: None,
-228 }),
-229 dns: DnsConfig {
-230 port: 5300,
-231 bind_addr: None,
-232 origins: vec!["irohdns.example.".to_string(), ".".to_string()],
-233
-234 default_soa: "irohdns.example hostmaster.irohdns.example 0 10800 3600 604800 3600"
-235 .to_string(),
-236 default_ttl: 900,
+224 }),
+225 https: Some(HttpsConfig {
+226 port: 8443,
+227 bind_addr: None,
+228 domains: vec!["localhost".to_string()],
+229 cert_mode: CertMode::SelfSigned,
+230 letsencrypt_contact: None,
+231 letsencrypt_prod: None,
+232 }),
+233 dns: DnsConfig {
+234 port: 5300,
+235 bind_addr: None,
+236 origins: vec!["irohdns.example.".to_string(), ".".to_string()],
237
-238 rr_a: Some(Ipv4Addr::LOCALHOST),
-239 rr_aaaa: None,
-240 rr_ns: Some("ns1.irohdns.example.".to_string()),
-241 },
-242 zone_store: None,
-243 metrics: None,
-244 mainline: None,
-245 pkarr_put_rate_limit: RateLimitConfig::default(),
-246 }
-247 }
-248}
\ No newline at end of file
+238 default_soa: "irohdns.example hostmaster.irohdns.example 0 10800 3600 604800 3600"
+239 .to_string(),
+240 default_ttl: 900,
+241
+242 rr_a: Some(Ipv4Addr::LOCALHOST),
+243 rr_aaaa: None,
+244 rr_ns: Some("ns1.irohdns.example.".to_string()),
+245 },
+246 zone_store: None,
+247 metrics: None,
+248 mainline: None,
+249 pkarr_put_rate_limit: RateLimitConfig::default(),
+250 }
+251 }
+252}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/dns.rs.html b/pr/3561/docs/src/iroh_dns_server/dns.rs.html
index e8824ac927..2db42df66d 100644
--- a/pr/3561/docs/src/iroh_dns_server/dns.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/dns.rs.html
@@ -25,7 +25,7 @@
25 server::{Request, RequestHandler, ResponseHandler, ResponseInfo},
26 store::in_memory::InMemoryAuthority,
27};
-28use n0_snafu::{Result, ResultExt, format_err};
+28use n0_error::{Result, StdResultExt, format_err};
29use serde::{Deserialize, Serialize};
30use tokio::{
31 net::{TcpListener, UdpSocket},
diff --git a/pr/3561/docs/src/iroh_dns_server/dns/node_authority.rs.html b/pr/3561/docs/src/iroh_dns_server/dns/node_authority.rs.html
index 11485c6189..4606591544 100644
--- a/pr/3561/docs/src/iroh_dns_server/dns/node_authority.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/dns/node_authority.rs.html
@@ -13,197 +13,196 @@
13 server::RequestInfo,
14 store::in_memory::InMemoryAuthority,
15};
-16use n0_snafu::{Result, ResultExt};
-17use snafu::whatever;
-18use tracing::{debug, trace};
-19
-20use crate::{
-21 store::ZoneStore,
-22 util::{PublicKeyBytes, record_set_append_origin},
-23};
-24
-25#[derive(derive_more::Debug)]
-26pub struct NodeAuthority {
-27 serial: u32,
-28 origins: Vec<Name>,
-29 #[debug("InMemoryAuthority")]
-30 static_authority: InMemoryAuthority,
-31 zones: ZoneStore,
-32 // TODO: This is used by Authority::origin
-33 // Find out what exactly this is used for - we don't have a primary origin.
-34 first_origin: LowerName,
-35}
-36
-37impl NodeAuthority {
-38 pub fn new(
-39 zones: ZoneStore,
-40 static_authority: InMemoryAuthority,
-41 origins: Vec<Name>,
-42 serial: u32,
-43 ) -> Result<Self> {
-44 if origins.is_empty() {
-45 whatever!("at least one origin is required");
-46 }
-47 let first_origin = LowerName::from(&origins[0]);
-48 Ok(Self {
-49 static_authority,
-50 origins,
-51 serial,
-52 zones,
-53 first_origin,
-54 })
-55 }
-56
-57 pub fn origins(&self) -> impl Iterator<Item = &Name> {
-58 self.origins.iter()
-59 }
-60
-61 pub fn serial(&self) -> u32 {
-62 self.serial
-63 }
-64
-65 async fn resolve_pkarr(
-66 &self,
-67 name: Name,
-68 pubkey: PublicKeyBytes,
-69 origin: Name,
-70 record_type: RecordType,
-71 lookup_options: LookupOptions,
-72 ) -> Result<AuthLookup, LookupError> {
-73 debug!(%origin, %pubkey, %name, "resolve in pkarr zones");
-74 match self
-75 .zones
-76 .resolve(&pubkey, &name, record_type)
-77 .await
-78 .map_err(err_refused)?
-79 {
-80 Some(pkarr_set) => {
-81 debug!(%origin, %pubkey, %name, "found {} records in pkarr zone", pkarr_set.records_without_rrsigs().count());
-82 let new_origin =
-83 Name::parse(&pubkey.to_z32(), Some(&origin)).map_err(err_refused)?;
-84 let record_set = record_set_append_origin(&pkarr_set, &new_origin, self.serial())
-85 .map_err(err_refused)?;
-86 let records = LookupRecords::new(lookup_options, Arc::new(record_set));
-87 let answers = AuthLookup::answers(records, None);
-88 Ok(answers)
-89 }
-90 None => Err(err_nx_domain("not found")),
-91 }
-92 }
-93}
-94
-95#[async_trait]
-96impl Authority for NodeAuthority {
-97 type Lookup = AuthLookup;
-98
-99 fn zone_type(&self) -> ZoneType {
-100 ZoneType::Primary
-101 }
-102
-103 fn is_axfr_allowed(&self) -> bool {
-104 false
-105 }
-106
-107 async fn update(&self, _update: &MessageRequest) -> UpdateResult<bool> {
-108 Err(ResponseCode::NotImp)
-109 }
-110
-111 fn origin(&self) -> &LowerName {
-112 &self.first_origin
-113 }
-114
-115 async fn lookup(
-116 &self,
-117 name: &LowerName,
-118 record_type: RecordType,
-119 lookup_options: LookupOptions,
-120 ) -> LookupControlFlow<Self::Lookup> {
-121 debug!(name=%name, "lookup in node authority");
-122 match record_type {
-123 RecordType::SOA | RecordType::NS => {
-124 self.static_authority
-125 .lookup(name, record_type, lookup_options)
-126 .await
-127 }
-128 _ => match parse_name_as_pkarr_with_origin(name, &self.origins) {
-129 Ok((name, pubkey, origin)) => {
-130 let res = self
-131 .resolve_pkarr(name, pubkey, origin, record_type, lookup_options)
-132 .await;
-133 LookupControlFlow::Continue(res)
-134 }
-135 Err(err) => {
-136 debug!(%name, failed_with=%err, "not a pkarr name, resolve in static authority");
-137 self.static_authority
-138 .lookup(name, record_type, lookup_options)
-139 .await
-140 }
-141 },
-142 }
-143 }
-144
-145 async fn search(
-146 &self,
-147 request_info: RequestInfo<'_>,
-148 lookup_options: LookupOptions,
-149 ) -> LookupControlFlow<Self::Lookup> {
-150 debug!("search in node authority for {}", request_info.query);
-151 let lookup_name = request_info.query.name();
-152 let record_type: RecordType = request_info.query.query_type();
-153 match record_type {
-154 RecordType::SOA => {
-155 self.static_authority
-156 .lookup(self.origin(), record_type, lookup_options)
-157 .await
-158 }
-159 RecordType::AXFR => {
-160 LookupControlFlow::Continue(Err(LookupError::from(ResponseCode::Refused)))
-161 }
-162 _ => self.lookup(lookup_name, record_type, lookup_options).await,
-163 }
-164 }
-165
-166 async fn get_nsec_records(
-167 &self,
-168 _name: &LowerName,
-169 _lookup_options: LookupOptions,
-170 ) -> LookupControlFlow<Self::Lookup> {
-171 LookupControlFlow::Skip
-172 }
-173}
-174
-175fn parse_name_as_pkarr_with_origin(
-176 name: impl Into<Name>,
-177 allowed_origins: &[Name],
-178) -> Result<(Name, PublicKeyBytes, Name)> {
-179 let name = name.into();
-180 trace!("resolve {name}");
-181 for origin in allowed_origins.iter() {
-182 trace!("try {origin}");
-183 if !origin.zone_of(&name) {
-184 continue;
-185 }
-186 if name.num_labels() < origin.num_labels() + 1 {
-187 whatever!("not a valid pkarr name: missing pubkey");
-188 }
-189 trace!("parse {origin}");
-190 let labels = name.iter().rev();
-191 let mut labels_without_origin = labels.skip(origin.num_labels() as usize);
-192 let pkey_label = labels_without_origin.next().expect("length checked above");
-193 let pkey_str = std::str::from_utf8(pkey_label).e()?;
-194 let pkey =
-195 PublicKeyBytes::from_z32(pkey_str).context("not a valid pkarr name: invalid pubkey")?;
-196 let remaining_name = Name::from_labels(labels_without_origin.rev()).e()?;
-197 return Ok((remaining_name, pkey, origin.clone()));
-198 }
-199 whatever!("name does not match any allowed origin");
-200}
-201
-202fn err_refused(e: impl fmt::Debug) -> LookupError {
-203 trace!("lookup failed (refused): {e:?}");
-204 LookupError::from(ResponseCode::Refused)
-205}
-206fn err_nx_domain(e: impl fmt::Debug) -> LookupError {
-207 trace!("lookup failed (nxdomain): {e:?}");
-208 LookupError::from(ResponseCode::NXDomain)
-209}
\ No newline at end of file
+16use n0_error::{Result, StackResultExt, StdResultExt, whatever};
+17use tracing::{debug, trace};
+18
+19use crate::{
+20 store::ZoneStore,
+21 util::{PublicKeyBytes, record_set_append_origin},
+22};
+23
+24#[derive(derive_more::Debug)]
+25pub struct NodeAuthority {
+26 serial: u32,
+27 origins: Vec<Name>,
+28 #[debug("InMemoryAuthority")]
+29 static_authority: InMemoryAuthority,
+30 zones: ZoneStore,
+31 // TODO: This is used by Authority::origin
+32 // Find out what exactly this is used for - we don't have a primary origin.
+33 first_origin: LowerName,
+34}
+35
+36impl NodeAuthority {
+37 pub fn new(
+38 zones: ZoneStore,
+39 static_authority: InMemoryAuthority,
+40 origins: Vec<Name>,
+41 serial: u32,
+42 ) -> Result<Self> {
+43 if origins.is_empty() {
+44 whatever!("at least one origin is required");
+45 }
+46 let first_origin = LowerName::from(&origins[0]);
+47 Ok(Self {
+48 static_authority,
+49 origins,
+50 serial,
+51 zones,
+52 first_origin,
+53 })
+54 }
+55
+56 pub fn origins(&self) -> impl Iterator<Item = &Name> {
+57 self.origins.iter()
+58 }
+59
+60 pub fn serial(&self) -> u32 {
+61 self.serial
+62 }
+63
+64 async fn resolve_pkarr(
+65 &self,
+66 name: Name,
+67 pubkey: PublicKeyBytes,
+68 origin: Name,
+69 record_type: RecordType,
+70 lookup_options: LookupOptions,
+71 ) -> Result<AuthLookup, LookupError> {
+72 debug!(%origin, %pubkey, %name, "resolve in pkarr zones");
+73 match self
+74 .zones
+75 .resolve(&pubkey, &name, record_type)
+76 .await
+77 .map_err(err_refused)?
+78 {
+79 Some(pkarr_set) => {
+80 debug!(%origin, %pubkey, %name, "found {} records in pkarr zone", pkarr_set.records_without_rrsigs().count());
+81 let new_origin =
+82 Name::parse(&pubkey.to_z32(), Some(&origin)).map_err(err_refused)?;
+83 let record_set = record_set_append_origin(&pkarr_set, &new_origin, self.serial())
+84 .map_err(err_refused)?;
+85 let records = LookupRecords::new(lookup_options, Arc::new(record_set));
+86 let answers = AuthLookup::answers(records, None);
+87 Ok(answers)
+88 }
+89 None => Err(err_nx_domain("not found")),
+90 }
+91 }
+92}
+93
+94#[async_trait]
+95impl Authority for NodeAuthority {
+96 type Lookup = AuthLookup;
+97
+98 fn zone_type(&self) -> ZoneType {
+99 ZoneType::Primary
+100 }
+101
+102 fn is_axfr_allowed(&self) -> bool {
+103 false
+104 }
+105
+106 async fn update(&self, _update: &MessageRequest) -> UpdateResult<bool> {
+107 Err(ResponseCode::NotImp)
+108 }
+109
+110 fn origin(&self) -> &LowerName {
+111 &self.first_origin
+112 }
+113
+114 async fn lookup(
+115 &self,
+116 name: &LowerName,
+117 record_type: RecordType,
+118 lookup_options: LookupOptions,
+119 ) -> LookupControlFlow<Self::Lookup> {
+120 debug!(name=%name, "lookup in node authority");
+121 match record_type {
+122 RecordType::SOA | RecordType::NS => {
+123 self.static_authority
+124 .lookup(name, record_type, lookup_options)
+125 .await
+126 }
+127 _ => match parse_name_as_pkarr_with_origin(name, &self.origins) {
+128 Ok((name, pubkey, origin)) => {
+129 let res = self
+130 .resolve_pkarr(name, pubkey, origin, record_type, lookup_options)
+131 .await;
+132 LookupControlFlow::Continue(res)
+133 }
+134 Err(err) => {
+135 debug!(%name, failed_with=%err, "not a pkarr name, resolve in static authority");
+136 self.static_authority
+137 .lookup(name, record_type, lookup_options)
+138 .await
+139 }
+140 },
+141 }
+142 }
+143
+144 async fn search(
+145 &self,
+146 request_info: RequestInfo<'_>,
+147 lookup_options: LookupOptions,
+148 ) -> LookupControlFlow<Self::Lookup> {
+149 debug!("search in node authority for {}", request_info.query);
+150 let lookup_name = request_info.query.name();
+151 let record_type: RecordType = request_info.query.query_type();
+152 match record_type {
+153 RecordType::SOA => {
+154 self.static_authority
+155 .lookup(self.origin(), record_type, lookup_options)
+156 .await
+157 }
+158 RecordType::AXFR => {
+159 LookupControlFlow::Continue(Err(LookupError::from(ResponseCode::Refused)))
+160 }
+161 _ => self.lookup(lookup_name, record_type, lookup_options).await,
+162 }
+163 }
+164
+165 async fn get_nsec_records(
+166 &self,
+167 _name: &LowerName,
+168 _lookup_options: LookupOptions,
+169 ) -> LookupControlFlow<Self::Lookup> {
+170 LookupControlFlow::Skip
+171 }
+172}
+173
+174fn parse_name_as_pkarr_with_origin(
+175 name: impl Into<Name>,
+176 allowed_origins: &[Name],
+177) -> Result<(Name, PublicKeyBytes, Name)> {
+178 let name = name.into();
+179 trace!("resolve {name}");
+180 for origin in allowed_origins.iter() {
+181 trace!("try {origin}");
+182 if !origin.zone_of(&name) {
+183 continue;
+184 }
+185 if name.num_labels() < origin.num_labels() + 1 {
+186 whatever!("not a valid pkarr name: missing pubkey");
+187 }
+188 trace!("parse {origin}");
+189 let labels = name.iter().rev();
+190 let mut labels_without_origin = labels.skip(origin.num_labels() as usize);
+191 let pkey_label = labels_without_origin.next().expect("length checked above");
+192 let pkey_str = std::str::from_utf8(pkey_label).e()?;
+193 let pkey = PublicKeyBytes::from_z32(pkey_str)
+194 .std_context("not a valid pkarr name: invalid pubkey")?;
+195 let remaining_name = Name::from_labels(labels_without_origin.rev()).e()?;
+196 return Ok((remaining_name, pkey, origin.clone()));
+197 }
+198 whatever!("name does not match any allowed origin");
+199}
+200
+201fn err_refused(e: impl fmt::Debug) -> LookupError {
+202 trace!("lookup failed (refused): {e:?}");
+203 LookupError::from(ResponseCode::Refused)
+204}
+205fn err_nx_domain(e: impl fmt::Debug) -> LookupError {
+206 trace!("lookup failed (nxdomain): {e:?}");
+207 LookupError::from(ResponseCode::NXDomain)
+208}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/http.rs.html b/pr/3561/docs/src/iroh_dns_server/http.rs.html
index aa380d8b0c..24964d15d2 100644
--- a/pr/3561/docs/src/iroh_dns_server/http.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/http.rs.html
@@ -14,254 +14,253 @@
14 response::IntoResponse,
15 routing::get,
16};
-17use n0_snafu::{Result, ResultExt};
+17use n0_error::{Result, StackResultExt, StdResultExt, whatever};
18use serde::{Deserialize, Serialize};
-19use snafu::whatever;
-20use tokio::{net::TcpListener, task::JoinSet};
-21use tower_http::{
-22 cors::{self, CorsLayer},
-23 trace::TraceLayer,
-24};
-25use tracing::{Level, info, span, warn};
-26
-27mod doh;
-28mod error;
-29mod pkarr;
-30mod rate_limiting;
-31mod tls;
-32
-33pub use self::{rate_limiting::RateLimitConfig, tls::CertMode};
-34use crate::{config::Config, state::AppState};
-35
-36/// Config for the HTTP server
-37#[derive(Debug, Serialize, Deserialize, Clone)]
-38pub struct HttpConfig {
-39 /// Port to bind to
-40 pub port: u16,
-41 /// Optionally set a custom bind address (will use 0.0.0.0 if unset)
-42 pub bind_addr: Option<IpAddr>,
-43}
-44
-45/// Config for the HTTPS server
-46#[derive(Debug, Serialize, Deserialize, Clone)]
-47pub struct HttpsConfig {
-48 /// Port to bind to
-49 pub port: u16,
-50 /// Optionally set a custom bind address (will use 0.0.0.0 if unset)
-51 pub bind_addr: Option<IpAddr>,
-52 /// The list of domains for which SSL certificates should be created.
-53 pub domains: Vec<String>,
-54 /// The mode of SSL certificate creation
-55 pub cert_mode: CertMode,
-56 /// Letsencrypt contact email address (required if using [`CertMode::LetsEncrypt`])
-57 pub letsencrypt_contact: Option<String>,
-58 /// Whether to use the letsenrypt production servers (only applies to [`CertMode::LetsEncrypt`])
-59 pub letsencrypt_prod: Option<bool>,
-60}
-61
-62/// The HTTP(S) server part of iroh-dns-server
-63pub struct HttpServer {
-64 tasks: JoinSet<std::io::Result<()>>,
-65 http_addr: Option<SocketAddr>,
-66 https_addr: Option<SocketAddr>,
-67}
-68
-69impl HttpServer {
-70 /// Spawn the server
-71 pub async fn spawn(
-72 http_config: Option<HttpConfig>,
-73 https_config: Option<HttpsConfig>,
-74 rate_limit_config: RateLimitConfig,
-75 state: AppState,
-76 ) -> Result<HttpServer> {
-77 if http_config.is_none() && https_config.is_none() {
-78 whatever!("Either http or https config is required");
-79 }
-80
-81 let app = create_app(state, &rate_limit_config);
-82
-83 let mut tasks = JoinSet::new();
-84
-85 // launch http
-86 let http_addr = if let Some(config) = http_config {
-87 let bind_addr = SocketAddr::new(
-88 config.bind_addr.unwrap_or(Ipv4Addr::UNSPECIFIED.into()),
-89 config.port,
-90 );
-91 let app = app.clone();
-92 let listener = TcpListener::bind(bind_addr).await.e()?.into_std().e()?;
-93 let bound_addr = listener.local_addr().e()?;
-94 let fut = axum_server::from_tcp(listener)
-95 .serve(app.into_make_service_with_connect_info::<SocketAddr>());
-96 info!("HTTP server listening on {bind_addr}");
-97 tasks.spawn(fut);
-98 Some(bound_addr)
-99 } else {
-100 None
-101 };
-102
-103 // launch https
-104 let https_addr = if let Some(config) = https_config {
-105 let bind_addr = SocketAddr::new(
-106 config.bind_addr.unwrap_or(Ipv4Addr::UNSPECIFIED.into()),
-107 config.port,
-108 );
-109 let acceptor = {
-110 let cache_path = Config::data_dir()?
-111 .join("cert_cache")
-112 .join(config.cert_mode.to_string());
-113 tokio::fs::create_dir_all(&cache_path)
-114 .await
-115 .with_context(|| {
-116 format!("failed to create cert cache dir at {cache_path:?}")
-117 })?;
-118 config
-119 .cert_mode
-120 .build(
-121 config.domains,
-122 cache_path,
-123 config.letsencrypt_contact,
-124 config.letsencrypt_prod.unwrap_or(false),
-125 )
-126 .await?
-127 };
-128 let listener = TcpListener::bind(bind_addr).await.e()?.into_std().e()?;
-129 let bound_addr = listener.local_addr().e()?;
-130 let fut = axum_server::from_tcp(listener)
-131 .acceptor(acceptor)
-132 .serve(app.into_make_service_with_connect_info::<SocketAddr>());
-133 info!("HTTPS server listening on {bind_addr}");
-134 tasks.spawn(fut);
-135 Some(bound_addr)
-136 } else {
-137 None
-138 };
-139
-140 Ok(HttpServer {
-141 tasks,
-142 http_addr,
-143 https_addr,
-144 })
-145 }
-146
-147 /// Get the bound address of the HTTP socket.
-148 pub fn http_addr(&self) -> Option<SocketAddr> {
-149 self.http_addr
-150 }
-151
-152 /// Get the bound address of the HTTPS socket.
-153 pub fn https_addr(&self) -> Option<SocketAddr> {
-154 self.https_addr
-155 }
-156
-157 /// Shutdown the server and wait for all tasks to complete.
-158 pub async fn shutdown(mut self) -> Result<()> {
-159 // TODO: Graceful cancellation.
-160 self.tasks.abort_all();
-161 self.run_until_done().await?;
-162 Ok(())
-163 }
-164
-165 /// Wait for all tasks to complete.
-166 ///
-167 /// Runs forever unless tasks fail.
-168 pub async fn run_until_done(mut self) -> Result<()> {
-169 let mut final_res: Result<()> = Ok(());
-170 while let Some(res) = self.tasks.join_next().await {
-171 match res {
-172 Ok(Ok(())) => {}
-173 Err(err) if err.is_cancelled() => {}
-174 Ok(Err(err)) => {
-175 warn!(?err, "task failed");
-176 final_res = Err(err).context("task");
-177 }
-178 Err(err) => {
-179 warn!(?err, "task panicked");
-180 final_res = Err(err).context("join");
-181 }
-182 }
-183 }
-184 final_res
-185 }
-186}
-187
-188pub(crate) fn create_app(state: AppState, rate_limit_config: &RateLimitConfig) -> Router {
-189 // configure cors middleware
-190 let cors = CorsLayer::new()
-191 // allow `GET` and `POST` when accessing the resource
-192 .allow_methods([Method::GET, Method::POST, Method::PUT])
-193 // allow requests from any origin
-194 .allow_origin(cors::Any);
-195
-196 // configure tracing middleware
-197 let trace = TraceLayer::new_for_http().make_span_with(|request: &http::Request<_>| {
-198 let conn_info = request
-199 .extensions()
-200 .get::<ConnectInfo<SocketAddr>>()
-201 .expect("connectinfo extension to be present");
-202 let span = span!(
-203 Level::DEBUG,
-204 "http_request",
-205 method = ?request.method(),
-206 uri = ?request.uri(),
-207 src = %conn_info.0,
-208 );
-209 span
-210 });
-211
-212 // configure rate limiting middleware
-213 let rate_limit = rate_limiting::create(rate_limit_config);
-214
-215 // configure routes
-216 //
-217 // only the pkarr::put route gets a rate limit
-218 let router = Router::new()
-219 .route("/dns-query", get(doh::get).post(doh::post))
-220 .route(
-221 "/pkarr/{key}",
-222 if let Some(rate_limit) = rate_limit {
-223 get(pkarr::get).put(pkarr::put.layer(rate_limit))
-224 } else {
-225 get(pkarr::get).put(pkarr::put)
-226 },
-227 )
-228 .route("/healthcheck", get(|| async { "OK" }))
-229 .route("/", get(|| async { "Hi!" }))
-230 .with_state(state.clone());
-231
-232 // configure app
-233 router
-234 .layer(cors)
-235 .layer(trace)
-236 .route_layer(middleware::from_fn_with_state(state, metrics_middleware))
-237}
-238
-239/// Record request metrics.
-240// TODO:
-241// * Request duration would be much better tracked as a histogram.
-242// * It would be great to attach labels to the metrics, so that the recorded metrics
-243// can filter by method etc.
-244//
-245// See also
-246// https://github.com/tokio-rs/axum/blob/main/examples/prometheus-metrics/src/main.rs#L114
-247async fn metrics_middleware(
-248 State(state): State<AppState>,
-249 req: Request,
-250 next: Next,
-251) -> impl IntoResponse {
-252 let start = Instant::now();
-253 let response = next.run(req).await;
-254 let latency = start.elapsed().as_millis();
-255 let status = response.status();
-256 state
-257 .metrics
-258 .http_requests_duration_ms
-259 .inc_by(latency as u64);
-260 state.metrics.http_requests.inc();
-261 if status.is_success() {
-262 state.metrics.http_requests_success.inc();
-263 } else {
-264 state.metrics.http_requests_error.inc();
-265 }
-266 response
-267}
\ No newline at end of file
+19use tokio::{net::TcpListener, task::JoinSet};
+20use tower_http::{
+21 cors::{self, CorsLayer},
+22 trace::TraceLayer,
+23};
+24use tracing::{Level, info, span, warn};
+25
+26mod doh;
+27mod error;
+28mod pkarr;
+29mod rate_limiting;
+30mod tls;
+31
+32pub use self::{rate_limiting::RateLimitConfig, tls::CertMode};
+33use crate::{config::Config, state::AppState};
+34
+35/// Config for the HTTP server
+36#[derive(Debug, Serialize, Deserialize, Clone)]
+37pub struct HttpConfig {
+38 /// Port to bind to
+39 pub port: u16,
+40 /// Optionally set a custom bind address (will use 0.0.0.0 if unset)
+41 pub bind_addr: Option<IpAddr>,
+42}
+43
+44/// Config for the HTTPS server
+45#[derive(Debug, Serialize, Deserialize, Clone)]
+46pub struct HttpsConfig {
+47 /// Port to bind to
+48 pub port: u16,
+49 /// Optionally set a custom bind address (will use 0.0.0.0 if unset)
+50 pub bind_addr: Option<IpAddr>,
+51 /// The list of domains for which SSL certificates should be created.
+52 pub domains: Vec<String>,
+53 /// The mode of SSL certificate creation
+54 pub cert_mode: CertMode,
+55 /// Letsencrypt contact email address (required if using [`CertMode::LetsEncrypt`])
+56 pub letsencrypt_contact: Option<String>,
+57 /// Whether to use the letsenrypt production servers (only applies to [`CertMode::LetsEncrypt`])
+58 pub letsencrypt_prod: Option<bool>,
+59}
+60
+61/// The HTTP(S) server part of iroh-dns-server
+62pub struct HttpServer {
+63 tasks: JoinSet<std::io::Result<()>>,
+64 http_addr: Option<SocketAddr>,
+65 https_addr: Option<SocketAddr>,
+66}
+67
+68impl HttpServer {
+69 /// Spawn the server
+70 pub async fn spawn(
+71 http_config: Option<HttpConfig>,
+72 https_config: Option<HttpsConfig>,
+73 rate_limit_config: RateLimitConfig,
+74 state: AppState,
+75 ) -> Result<HttpServer> {
+76 if http_config.is_none() && https_config.is_none() {
+77 whatever!("Either http or https config is required");
+78 }
+79
+80 let app = create_app(state, &rate_limit_config);
+81
+82 let mut tasks = JoinSet::new();
+83
+84 // launch http
+85 let http_addr = if let Some(config) = http_config {
+86 let bind_addr = SocketAddr::new(
+87 config.bind_addr.unwrap_or(Ipv4Addr::UNSPECIFIED.into()),
+88 config.port,
+89 );
+90 let app = app.clone();
+91 let listener = TcpListener::bind(bind_addr).await.e()?.into_std().e()?;
+92 let bound_addr = listener.local_addr().e()?;
+93 let fut = axum_server::from_tcp(listener)
+94 .serve(app.into_make_service_with_connect_info::<SocketAddr>());
+95 info!("HTTP server listening on {bind_addr}");
+96 tasks.spawn(fut);
+97 Some(bound_addr)
+98 } else {
+99 None
+100 };
+101
+102 // launch https
+103 let https_addr = if let Some(config) = https_config {
+104 let bind_addr = SocketAddr::new(
+105 config.bind_addr.unwrap_or(Ipv4Addr::UNSPECIFIED.into()),
+106 config.port,
+107 );
+108 let acceptor = {
+109 let cache_path = Config::data_dir()?
+110 .join("cert_cache")
+111 .join(config.cert_mode.to_string());
+112 tokio::fs::create_dir_all(&cache_path)
+113 .await
+114 .std_context(format!(
+115 "failed to create cert cache dir at {cache_path:?}"
+116 ))?;
+117 config
+118 .cert_mode
+119 .build(
+120 config.domains,
+121 cache_path,
+122 config.letsencrypt_contact,
+123 config.letsencrypt_prod.unwrap_or(false),
+124 )
+125 .await?
+126 };
+127 let listener = TcpListener::bind(bind_addr).await.e()?.into_std().e()?;
+128 let bound_addr = listener.local_addr().e()?;
+129 let fut = axum_server::from_tcp(listener)
+130 .acceptor(acceptor)
+131 .serve(app.into_make_service_with_connect_info::<SocketAddr>());
+132 info!("HTTPS server listening on {bind_addr}");
+133 tasks.spawn(fut);
+134 Some(bound_addr)
+135 } else {
+136 None
+137 };
+138
+139 Ok(HttpServer {
+140 tasks,
+141 http_addr,
+142 https_addr,
+143 })
+144 }
+145
+146 /// Get the bound address of the HTTP socket.
+147 pub fn http_addr(&self) -> Option<SocketAddr> {
+148 self.http_addr
+149 }
+150
+151 /// Get the bound address of the HTTPS socket.
+152 pub fn https_addr(&self) -> Option<SocketAddr> {
+153 self.https_addr
+154 }
+155
+156 /// Shutdown the server and wait for all tasks to complete.
+157 pub async fn shutdown(mut self) -> Result<()> {
+158 // TODO: Graceful cancellation.
+159 self.tasks.abort_all();
+160 self.run_until_done().await?;
+161 Ok(())
+162 }
+163
+164 /// Wait for all tasks to complete.
+165 ///
+166 /// Runs forever unless tasks fail.
+167 pub async fn run_until_done(mut self) -> Result<()> {
+168 let mut final_res: Result<()> = Ok(());
+169 while let Some(res) = self.tasks.join_next().await {
+170 match res {
+171 Ok(Ok(())) => {}
+172 Err(err) if err.is_cancelled() => {}
+173 Ok(Err(err)) => {
+174 warn!(?err, "task failed");
+175 final_res = Err(err).std_context("task");
+176 }
+177 Err(err) => {
+178 warn!(?err, "task panicked");
+179 final_res = Err(err).std_context("join");
+180 }
+181 }
+182 }
+183 final_res
+184 }
+185}
+186
+187pub(crate) fn create_app(state: AppState, rate_limit_config: &RateLimitConfig) -> Router {
+188 // configure cors middleware
+189 let cors = CorsLayer::new()
+190 // allow `GET` and `POST` when accessing the resource
+191 .allow_methods([Method::GET, Method::POST, Method::PUT])
+192 // allow requests from any origin
+193 .allow_origin(cors::Any);
+194
+195 // configure tracing middleware
+196 let trace = TraceLayer::new_for_http().make_span_with(|request: &http::Request<_>| {
+197 let conn_info = request
+198 .extensions()
+199 .get::<ConnectInfo<SocketAddr>>()
+200 .expect("connectinfo extension to be present");
+201 let span = span!(
+202 Level::DEBUG,
+203 "http_request",
+204 method = ?request.method(),
+205 uri = ?request.uri(),
+206 src = %conn_info.0,
+207 );
+208 span
+209 });
+210
+211 // configure rate limiting middleware
+212 let rate_limit = rate_limiting::create(rate_limit_config);
+213
+214 // configure routes
+215 //
+216 // only the pkarr::put route gets a rate limit
+217 let router = Router::new()
+218 .route("/dns-query", get(doh::get).post(doh::post))
+219 .route(
+220 "/pkarr/{key}",
+221 if let Some(rate_limit) = rate_limit {
+222 get(pkarr::get).put(pkarr::put.layer(rate_limit))
+223 } else {
+224 get(pkarr::get).put(pkarr::put)
+225 },
+226 )
+227 .route("/healthcheck", get(|| async { "OK" }))
+228 .route("/", get(|| async { "Hi!" }))
+229 .with_state(state.clone());
+230
+231 // configure app
+232 router
+233 .layer(cors)
+234 .layer(trace)
+235 .route_layer(middleware::from_fn_with_state(state, metrics_middleware))
+236}
+237
+238/// Record request metrics.
+239// TODO:
+240// * Request duration would be much better tracked as a histogram.
+241// * It would be great to attach labels to the metrics, so that the recorded metrics
+242// can filter by method etc.
+243//
+244// See also
+245// https://github.com/tokio-rs/axum/blob/main/examples/prometheus-metrics/src/main.rs#L114
+246async fn metrics_middleware(
+247 State(state): State<AppState>,
+248 req: Request,
+249 next: Next,
+250) -> impl IntoResponse {
+251 let start = Instant::now();
+252 let response = next.run(req).await;
+253 let latency = start.elapsed().as_millis();
+254 let status = response.status();
+255 state
+256 .metrics
+257 .http_requests_duration_ms
+258 .inc_by(latency as u64);
+259 state.metrics.http_requests.inc();
+260 if status.is_success() {
+261 state.metrics.http_requests_success.inc();
+262 } else {
+263 state.metrics.http_requests_error.inc();
+264 }
+265 response
+266}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/http/doh.rs.html b/pr/3561/docs/src/iroh_dns_server/http/doh.rs.html
index de326b34b2..4a9e187b03 100644
--- a/pr/3561/docs/src/iroh_dns_server/http/doh.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/http/doh.rs.html
@@ -16,7 +16,7 @@
16 HeaderValue, StatusCode,
17 header::{CACHE_CONTROL, CONTENT_TYPE},
18};
-19use n0_snafu::ResultExt;
+19use n0_error::StdResultExt;
20
21use super::error::AppResult;
22use crate::state::AppState;
diff --git a/pr/3561/docs/src/iroh_dns_server/http/doh/response.rs.html b/pr/3561/docs/src/iroh_dns_server/http/doh/response.rs.html
index bbfaadd8fc..0c2c9edd9d 100644
--- a/pr/3561/docs/src/iroh_dns_server/http/doh/response.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/http/doh/response.rs.html
@@ -4,138 +4,134 @@
4// https://github.com/fission-codes/fission-server/blob/394de877fad021260c69fdb1edd7bb4b2f98108c/fission-core/src/dns.rs
5
6use hickory_server::proto;
-7use n0_snafu::Result;
+7use n0_error::{Result, whatever};
8use serde::{Deserialize, Serialize};
-9use snafu::ensure_whatever;
-10
-11#[derive(Debug, Serialize, Deserialize)]
-12/// JSON representation of a DNS response
-13/// See: <https://developers.google.com/speed/public-dns/docs/doh/json>
-14pub struct DnsResponse {
-15 /// Standard DNS response code
-16 #[serde(rename = "Status")]
-17 pub status: u32,
-18 /// Whether the response was truncated
-19 #[serde(rename = "TC")]
-20 pub tc: bool,
-21 /// Whether recursion was desired
-22 #[serde(rename = "RD")]
-23 pub rd: bool,
-24 /// Whether recursion was available
-25 #[serde(rename = "RA")]
-26 pub ra: bool,
-27 /// Whether the response was validated with DNSSEC
-28 #[serde(rename = "AD")]
-29 pub ad: bool,
-30 /// Whether the client asked to disable DNSSEC validation
-31 #[serde(rename = "CD")]
-32 pub cd: bool,
-33 /// The questions that this request answers
-34 #[serde(rename = "Question")]
-35 pub question: Vec<DohQuestionJson>,
-36 /// The answers to the request
-37 #[serde(rename = "Answer")]
-38 #[serde(skip_serializing_if = "Vec::is_empty")]
-39 pub answer: Vec<DohRecordJson>,
-40 /// An optional comment
-41 #[serde(rename = "Comment")]
-42 pub comment: Option<String>,
-43 /// IP Address / scope prefix-length of the client
-44 /// See: <https://tools.ietf.org/html/rfc7871>
-45 pub edns_client_subnet: Option<String>,
-46}
-47
-48impl DnsResponse {
-49 /// Create a new JSON response from a DNS message
-50 pub fn from_message(message: proto::op::Message) -> Result<Self> {
-51 ensure_whatever!(
-52 message.message_type() == proto::op::MessageType::Response,
-53 "Expected message type to be response"
-54 );
-55
-56 ensure_whatever!(
-57 message.query_count() == message.queries().len() as u16,
-58 "Query count mismatch"
-59 );
-60
-61 ensure_whatever!(
-62 message.answer_count() == message.answers().len() as u16,
-63 "Answer count mismatch"
-64 );
-65
-66 let status: u32 =
-67 <u16 as From<proto::op::ResponseCode>>::from(message.response_code()) as u32;
-68
-69 let question: Vec<_> = message
-70 .queries()
-71 .iter()
-72 .map(DohQuestionJson::from_query)
-73 .collect();
-74
-75 let answer: Vec<_> = message
-76 .answers()
-77 .iter()
-78 .map(DohRecordJson::from_record)
-79 .collect::<Result<_>>()?;
-80
-81 Ok(DnsResponse {
-82 status,
-83 tc: message.truncated(),
-84 rd: message.recursion_desired(),
-85 ra: message.recursion_available(),
-86 ad: message.authentic_data(),
-87 cd: message.checking_disabled(),
-88 question,
-89 answer,
-90 comment: None,
-91 edns_client_subnet: None,
-92 })
-93 }
-94}
-95
-96#[derive(Debug, Serialize, Deserialize)]
-97/// JSON representation of a DNS question
-98pub struct DohQuestionJson {
-99 /// FQDN with trailing dot
-100 pub name: String,
-101 /// Standard DNS RR type
-102 #[serde(rename = "type")]
-103 pub question_type: u16,
-104}
-105
-106impl DohQuestionJson {
-107 /// Create a new JSON question from a DNS query
-108 pub fn from_query(query: &proto::op::Query) -> Self {
-109 Self {
-110 name: query.name().to_string(),
-111 question_type: query.query_type().into(),
-112 }
-113 }
-114}
-115
-116#[derive(Debug, Serialize, Deserialize)]
-117/// JSON representation of a DNS record
-118pub struct DohRecordJson {
-119 /// FQDN with trailing dot
-120 pub name: String,
-121 /// Standard DNS RR type
-122 #[serde(rename = "type")]
-123 pub record_type: u16,
-124 /// Time-to-live, in seconds
-125 #[serde(rename = "TTL")]
-126 pub ttl: u32,
-127 /// Record data
-128 pub data: String,
-129}
-130
-131impl DohRecordJson {
-132 /// Create a new JSON record from a DNS record
-133 pub fn from_record(record: &proto::rr::Record) -> Result<Self> {
-134 Ok(Self {
-135 name: record.name().to_string(),
-136 record_type: record.record_type().into(),
-137 ttl: record.ttl(),
-138 data: record.data().to_string(),
-139 })
-140 }
-141}
\ No newline at end of file
+9
+10#[derive(Debug, Serialize, Deserialize)]
+11/// JSON representation of a DNS response
+12/// See: <https://developers.google.com/speed/public-dns/docs/doh/json>
+13pub struct DnsResponse {
+14 /// Standard DNS response code
+15 #[serde(rename = "Status")]
+16 pub status: u32,
+17 /// Whether the response was truncated
+18 #[serde(rename = "TC")]
+19 pub tc: bool,
+20 /// Whether recursion was desired
+21 #[serde(rename = "RD")]
+22 pub rd: bool,
+23 /// Whether recursion was available
+24 #[serde(rename = "RA")]
+25 pub ra: bool,
+26 /// Whether the response was validated with DNSSEC
+27 #[serde(rename = "AD")]
+28 pub ad: bool,
+29 /// Whether the client asked to disable DNSSEC validation
+30 #[serde(rename = "CD")]
+31 pub cd: bool,
+32 /// The questions that this request answers
+33 #[serde(rename = "Question")]
+34 pub question: Vec<DohQuestionJson>,
+35 /// The answers to the request
+36 #[serde(rename = "Answer")]
+37 #[serde(skip_serializing_if = "Vec::is_empty")]
+38 pub answer: Vec<DohRecordJson>,
+39 /// An optional comment
+40 #[serde(rename = "Comment")]
+41 pub comment: Option<String>,
+42 /// IP Address / scope prefix-length of the client
+43 /// See: <https://tools.ietf.org/html/rfc7871>
+44 pub edns_client_subnet: Option<String>,
+45}
+46
+47impl DnsResponse {
+48 /// Create a new JSON response from a DNS message
+49 pub fn from_message(message: proto::op::Message) -> Result<Self> {
+50 if message.message_type() != proto::op::MessageType::Response {
+51 whatever!("Expected message type to be response");
+52 }
+53
+54 if message.query_count() != message.queries().len() as u16 {
+55 whatever!("Query count mismatch");
+56 }
+57
+58 if message.answer_count() != message.answers().len() as u16 {
+59 whatever!("Answer count mismatch");
+60 }
+61
+62 let status: u32 =
+63 <u16 as From<proto::op::ResponseCode>>::from(message.response_code()) as u32;
+64
+65 let question: Vec<_> = message
+66 .queries()
+67 .iter()
+68 .map(DohQuestionJson::from_query)
+69 .collect();
+70
+71 let answer: Vec<_> = message
+72 .answers()
+73 .iter()
+74 .map(DohRecordJson::from_record)
+75 .collect::<Result<_>>()?;
+76
+77 Ok(DnsResponse {
+78 status,
+79 tc: message.truncated(),
+80 rd: message.recursion_desired(),
+81 ra: message.recursion_available(),
+82 ad: message.authentic_data(),
+83 cd: message.checking_disabled(),
+84 question,
+85 answer,
+86 comment: None,
+87 edns_client_subnet: None,
+88 })
+89 }
+90}
+91
+92#[derive(Debug, Serialize, Deserialize)]
+93/// JSON representation of a DNS question
+94pub struct DohQuestionJson {
+95 /// FQDN with trailing dot
+96 pub name: String,
+97 /// Standard DNS RR type
+98 #[serde(rename = "type")]
+99 pub question_type: u16,
+100}
+101
+102impl DohQuestionJson {
+103 /// Create a new JSON question from a DNS query
+104 pub fn from_query(query: &proto::op::Query) -> Self {
+105 Self {
+106 name: query.name().to_string(),
+107 question_type: query.query_type().into(),
+108 }
+109 }
+110}
+111
+112#[derive(Debug, Serialize, Deserialize)]
+113/// JSON representation of a DNS record
+114pub struct DohRecordJson {
+115 /// FQDN with trailing dot
+116 pub name: String,
+117 /// Standard DNS RR type
+118 #[serde(rename = "type")]
+119 pub record_type: u16,
+120 /// Time-to-live, in seconds
+121 #[serde(rename = "TTL")]
+122 pub ttl: u32,
+123 /// Record data
+124 pub data: String,
+125}
+126
+127impl DohRecordJson {
+128 /// Create a new JSON record from a DNS record
+129 pub fn from_record(record: &proto::rr::Record) -> Result<Self> {
+130 Ok(Self {
+131 name: record.name().to_string(),
+132 record_type: record.record_type().into(),
+133 ttl: record.ttl(),
+134 data: record.data().to_string(),
+135 })
+136 }
+137}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/http/error.rs.html b/pr/3561/docs/src/iroh_dns_server/http/error.rs.html
index d659fd42ef..8cef37af80 100644
--- a/pr/3561/docs/src/iroh_dns_server/http/error.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/http/error.rs.html
@@ -49,8 +49,8 @@
49 }
50}
51
-52impl From<n0_snafu::Error> for AppError {
-53 fn from(value: n0_snafu::Error) -> Self {
+52impl From<n0_error::AnyError> for AppError {
+53 fn from(value: n0_error::AnyError) -> Self {
54 Self {
55 status: StatusCode::INTERNAL_SERVER_ERROR,
56 detail: Some(value.to_string()),
diff --git a/pr/3561/docs/src/iroh_dns_server/http/tls.rs.html b/pr/3561/docs/src/iroh_dns_server/http/tls.rs.html
index 37478ca5c4..5b91fdcb76 100644
--- a/pr/3561/docs/src/iroh_dns_server/http/tls.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/http/tls.rs.html
@@ -10,179 +10,178 @@
10 tls_rustls::{RustlsAcceptor, RustlsConfig},
11};
12use n0_future::{FutureExt, future::Boxed as BoxFuture};
-13use n0_snafu::{Result, ResultExt};
+13use n0_error::{Result, StdResultExt, whatever};
14use serde::{Deserialize, Serialize};
-15use snafu::whatever;
-16use tokio::io::{AsyncRead, AsyncWrite};
-17use tokio_rustls_acme::{AcmeConfig, axum::AxumAcceptor, caches::DirCache};
-18use tokio_stream::StreamExt;
-19use tracing::{Instrument, debug, error, info_span};
-20
-21/// The mode how SSL certificates should be created.
-22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, strum::Display)]
-23#[serde(rename_all = "snake_case")]
-24pub enum CertMode {
-25 /// Certs are loaded from a the `cert_cache` path
-26 Manual,
-27 /// ACME with LetsEncrypt servers
-28 LetsEncrypt,
-29 /// Create self-signed certificates and store them in the `cert_cache` path
-30 SelfSigned,
-31}
-32
-33impl CertMode {
-34 /// Build the [`TlsAcceptor`] for this mode.
-35 pub(crate) async fn build(
-36 &self,
-37 domains: Vec<String>,
-38 cert_cache: PathBuf,
-39 letsencrypt_contact: Option<String>,
-40 letsencrypt_prod: bool,
-41 ) -> Result<TlsAcceptor> {
-42 Ok(match self {
-43 CertMode::Manual => TlsAcceptor::manual(domains, cert_cache).await?,
-44 CertMode::SelfSigned => TlsAcceptor::self_signed(domains).await?,
-45 CertMode::LetsEncrypt => {
-46 let contact =
-47 letsencrypt_contact.context("contact is required for letsencrypt cert mode")?;
-48 TlsAcceptor::letsencrypt(domains, &contact, letsencrypt_prod, cert_cache)?
-49 }
-50 })
-51 }
-52}
-53
-54/// TLS Certificate Authority acceptor.
-55#[derive(Clone)]
-56pub enum TlsAcceptor {
-57 LetsEncrypt(AxumAcceptor),
-58 Manual(RustlsAcceptor),
-59}
-60
-61impl<I: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: Send + 'static> Accept<I, S>
-62 for TlsAcceptor
-63{
-64 type Stream = tokio_rustls::server::TlsStream<I>;
-65 type Service = S;
-66 type Future = BoxFuture<io::Result<(Self::Stream, Self::Service)>>;
-67
-68 fn accept(&self, stream: I, service: S) -> Self::Future {
-69 match self {
-70 Self::LetsEncrypt(a) => a.accept(stream, service).boxed(),
-71 Self::Manual(a) => a.accept(stream, service).boxed(),
-72 }
-73 }
-74}
-75
-76impl TlsAcceptor {
-77 async fn self_signed(domains: Vec<String>) -> Result<Self> {
-78 let rcgen::CertifiedKey { cert, signing_key } =
-79 rcgen::generate_simple_self_signed(domains).e()?;
-80 let config = RustlsConfig::from_der(vec![cert.der().to_vec()], signing_key.serialize_der())
-81 .await
-82 .e()?;
-83 let acceptor = RustlsAcceptor::new(config);
-84 Ok(Self::Manual(acceptor))
-85 }
-86
-87 async fn manual(domains: Vec<String>, dir: PathBuf) -> Result<Self> {
-88 let config = rustls::ServerConfig::builder().with_no_client_auth();
-89 if domains.len() != 1 {
-90 whatever!("Multiple domains in manual mode are not supported");
-91 }
-92
-93 let keyname = escape_hostname(&domains[0]);
-94 let cert_path = dir.join(format!("{keyname}.crt"));
-95 let key_path = dir.join(format!("{keyname}.key"));
-96
-97 let certs = load_certs(cert_path).await?;
-98 let secret_key = load_secret_key(key_path).await?;
-99
-100 let config = config.with_single_cert(certs, secret_key).e()?;
-101 let config = RustlsConfig::from_config(Arc::new(config));
-102 let acceptor = RustlsAcceptor::new(config);
-103 Ok(Self::Manual(acceptor))
-104 }
-105
-106 fn letsencrypt(
-107 domains: Vec<String>,
-108 contact: &str,
-109 is_production: bool,
-110 dir: PathBuf,
-111 ) -> Result<Self> {
-112 let config = rustls::ServerConfig::builder().with_no_client_auth();
-113 let mut state = AcmeConfig::new(domains)
-114 .contact([format!("mailto:{contact}")])
-115 .cache_option(Some(DirCache::new(dir)))
-116 .directory_lets_encrypt(is_production)
-117 .state();
-118
-119 let config = config.with_cert_resolver(state.resolver());
-120 let acceptor = state.acceptor();
-121
-122 tokio::spawn(
-123 async move {
-124 loop {
-125 match state.next().await.unwrap() {
-126 Ok(ok) => debug!("acme event: {:?}", ok),
-127 Err(err) => error!("error: {:?}", err),
-128 }
-129 }
-130 }
-131 .instrument(info_span!("acme")),
-132 );
-133 let config = Arc::new(config);
-134 let acceptor = AxumAcceptor::new(acceptor, config);
-135 Ok(Self::LetsEncrypt(acceptor))
-136 }
-137}
-138
-139async fn load_certs(
-140 filename: impl AsRef<Path>,
-141) -> Result<Vec<rustls::pki_types::CertificateDer<'static>>> {
-142 let certfile = tokio::fs::read(filename)
-143 .await
-144 .context("cannot open certificate file")?;
-145 let mut reader = std::io::Cursor::new(certfile);
-146 let certs: Result<Vec<_>, std::io::Error> = rustls_pemfile::certs(&mut reader).collect();
-147 let certs = certs.e()?;
-148
-149 Ok(certs)
-150}
-151
-152async fn load_secret_key(
-153 filename: impl AsRef<Path>,
-154) -> Result<rustls::pki_types::PrivateKeyDer<'static>> {
-155 let keyfile = tokio::fs::read(filename.as_ref())
-156 .await
-157 .context("cannot open secret key file")?;
-158 let mut reader = std::io::Cursor::new(keyfile);
-159
-160 loop {
-161 match rustls_pemfile::read_one(&mut reader).context("cannot parse secret key .pem file")? {
-162 Some(rustls_pemfile::Item::Pkcs1Key(key)) => {
-163 return Ok(rustls::pki_types::PrivateKeyDer::Pkcs1(key));
-164 }
-165 Some(rustls_pemfile::Item::Pkcs8Key(key)) => {
-166 return Ok(rustls::pki_types::PrivateKeyDer::Pkcs8(key));
-167 }
-168 Some(rustls_pemfile::Item::Sec1Key(key)) => {
-169 return Ok(rustls::pki_types::PrivateKeyDer::Sec1(key));
-170 }
-171 None => break,
-172 _ => {}
-173 }
-174 }
-175
-176 whatever!(
-177 "no keys found in {} (encrypted keys not supported)",
-178 filename.as_ref().display()
-179 );
-180}
-181
-182static UNSAFE_HOSTNAME_CHARACTERS: OnceLock<regex::Regex> = OnceLock::new();
-183
-184fn escape_hostname(hostname: &str) -> Cow<'_, str> {
-185 let regex = UNSAFE_HOSTNAME_CHARACTERS
-186 .get_or_init(|| regex::Regex::new(r"[^a-zA-Z0-9-\.]").expect("valid regex"));
-187 regex.replace_all(hostname, "")
-188}
\ No newline at end of file
+15use tokio::io::{AsyncRead, AsyncWrite};
+16use tokio_rustls_acme::{AcmeConfig, axum::AxumAcceptor, caches::DirCache};
+17use tokio_stream::StreamExt;
+18use tracing::{Instrument, debug, error, info_span};
+19
+20/// The mode how SSL certificates should be created.
+21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, strum::Display)]
+22#[serde(rename_all = "snake_case")]
+23pub enum CertMode {
+24 /// Certs are loaded from a the `cert_cache` path
+25 Manual,
+26 /// ACME with LetsEncrypt servers
+27 LetsEncrypt,
+28 /// Create self-signed certificates and store them in the `cert_cache` path
+29 SelfSigned,
+30}
+31
+32impl CertMode {
+33 /// Build the [`TlsAcceptor`] for this mode.
+34 pub(crate) async fn build(
+35 &self,
+36 domains: Vec<String>,
+37 cert_cache: PathBuf,
+38 letsencrypt_contact: Option<String>,
+39 letsencrypt_prod: bool,
+40 ) -> Result<TlsAcceptor> {
+41 Ok(match self {
+42 CertMode::Manual => TlsAcceptor::manual(domains, cert_cache).await?,
+43 CertMode::SelfSigned => TlsAcceptor::self_signed(domains).await?,
+44 CertMode::LetsEncrypt => {
+45 let contact = letsencrypt_contact
+46 .std_context("contact is required for letsencrypt cert mode")?;
+47 TlsAcceptor::letsencrypt(domains, &contact, letsencrypt_prod, cert_cache)?
+48 }
+49 })
+50 }
+51}
+52
+53/// TLS Certificate Authority acceptor.
+54#[derive(Clone)]
+55pub enum TlsAcceptor {
+56 LetsEncrypt(AxumAcceptor),
+57 Manual(RustlsAcceptor),
+58}
+59
+60impl<I: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: Send + 'static> Accept<I, S>
+61 for TlsAcceptor
+62{
+63 type Stream = tokio_rustls::server::TlsStream<I>;
+64 type Service = S;
+65 type Future = BoxFuture<io::Result<(Self::Stream, Self::Service)>>;
+66
+67 fn accept(&self, stream: I, service: S) -> Self::Future {
+68 match self {
+69 Self::LetsEncrypt(a) => a.accept(stream, service).boxed(),
+70 Self::Manual(a) => a.accept(stream, service).boxed(),
+71 }
+72 }
+73}
+74
+75impl TlsAcceptor {
+76 async fn self_signed(domains: Vec<String>) -> Result<Self> {
+77 let rcgen::CertifiedKey { cert, signing_key } =
+78 rcgen::generate_simple_self_signed(domains).e()?;
+79 let config = RustlsConfig::from_der(vec![cert.der().to_vec()], signing_key.serialize_der())
+80 .await
+81 .e()?;
+82 let acceptor = RustlsAcceptor::new(config);
+83 Ok(Self::Manual(acceptor))
+84 }
+85
+86 async fn manual(domains: Vec<String>, dir: PathBuf) -> Result<Self> {
+87 let config = rustls::ServerConfig::builder().with_no_client_auth();
+88 if domains.len() != 1 {
+89 whatever!("Multiple domains in manual mode are not supported");
+90 }
+91
+92 let keyname = escape_hostname(&domains[0]);
+93 let cert_path = dir.join(format!("{keyname}.crt"));
+94 let key_path = dir.join(format!("{keyname}.key"));
+95
+96 let certs = load_certs(cert_path).await?;
+97 let secret_key = load_secret_key(key_path).await?;
+98
+99 let config = config.with_single_cert(certs, secret_key).e()?;
+100 let config = RustlsConfig::from_config(Arc::new(config));
+101 let acceptor = RustlsAcceptor::new(config);
+102 Ok(Self::Manual(acceptor))
+103 }
+104
+105 fn letsencrypt(
+106 domains: Vec<String>,
+107 contact: &str,
+108 is_production: bool,
+109 dir: PathBuf,
+110 ) -> Result<Self> {
+111 let config = rustls::ServerConfig::builder().with_no_client_auth();
+112 let mut state = AcmeConfig::new(domains)
+113 .contact([format!("mailto:{contact}")])
+114 .cache_option(Some(DirCache::new(dir)))
+115 .directory_lets_encrypt(is_production)
+116 .state();
+117
+118 let config = config.with_cert_resolver(state.resolver());
+119 let acceptor = state.acceptor();
+120
+121 tokio::spawn(
+122 async move {
+123 loop {
+124 match state.next().await.unwrap() {
+125 Ok(ok) => debug!("acme event: {:?}", ok),
+126 Err(err) => error!("error: {:?}", err),
+127 }
+128 }
+129 }
+130 .instrument(info_span!("acme")),
+131 );
+132 let config = Arc::new(config);
+133 let acceptor = AxumAcceptor::new(acceptor, config);
+134 Ok(Self::LetsEncrypt(acceptor))
+135 }
+136}
+137
+138async fn load_certs(
+139 filename: impl AsRef<Path>,
+140) -> Result<Vec<rustls::pki_types::CertificateDer<'static>>> {
+141 let certfile = tokio::fs::read(filename)
+142 .await
+143 .std_context("cannot open certificate file")?;
+144 let mut reader = std::io::Cursor::new(certfile);
+145 let certs: Result<Vec<_>, std::io::Error> = rustls_pemfile::certs(&mut reader).collect();
+146 let certs = certs.e()?;
+147
+148 Ok(certs)
+149}
+150
+151async fn load_secret_key(
+152 filename: impl AsRef<Path>,
+153) -> Result<rustls::pki_types::PrivateKeyDer<'static>> {
+154 let keyfile = tokio::fs::read(filename.as_ref())
+155 .await
+156 .std_context("cannot open secret key file")?;
+157 let mut reader = std::io::Cursor::new(keyfile);
+158
+159 loop {
+160 match rustls_pemfile::read_one(&mut reader).std_context("cannot parse secret key .pem file")? {
+161 Some(rustls_pemfile::Item::Pkcs1Key(key)) => {
+162 return Ok(rustls::pki_types::PrivateKeyDer::Pkcs1(key));
+163 }
+164 Some(rustls_pemfile::Item::Pkcs8Key(key)) => {
+165 return Ok(rustls::pki_types::PrivateKeyDer::Pkcs8(key));
+166 }
+167 Some(rustls_pemfile::Item::Sec1Key(key)) => {
+168 return Ok(rustls::pki_types::PrivateKeyDer::Sec1(key));
+169 }
+170 None => break,
+171 _ => {}
+172 }
+173 }
+174
+175 whatever!(
+176 "no keys found in {} (encrypted keys not supported)",
+177 filename.as_ref().display()
+178 );
+179}
+180
+181static UNSAFE_HOSTNAME_CHARACTERS: OnceLock<regex::Regex> = OnceLock::new();
+182
+183fn escape_hostname(hostname: &str) -> Cow<'_, str> {
+184 let regex = UNSAFE_HOSTNAME_CHARACTERS
+185 .get_or_init(|| regex::Regex::new(r"[^a-zA-Z0-9-\.]").expect("valid regex"));
+186 regex.replace_all(hostname, "")
+187}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/lib.rs.html b/pr/3561/docs/src/iroh_dns_server/lib.rs.html
index c3b70f9da7..d2acbdb84d 100644
--- a/pr/3561/docs/src/iroh_dns_server/lib.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/lib.rs.html
@@ -25,7 +25,7 @@
25 RelayUrl, SecretKey, discovery::pkarr::PkarrRelayClient, dns::DnsResolver,
26 endpoint_info::EndpointInfo,
27 };
-28 use n0_snafu::{Result, ResultExt};
+28 use n0_error::{Result, StdResultExt};
29 use pkarr::{SignedPacket, Timestamp};
30 use rand::{CryptoRng, SeedableRng};
31 use tracing_test::traced_test;
@@ -43,7 +43,7 @@
43 #[tokio::test]
44 #[traced_test]
45 async fn pkarr_publish_dns_resolve() -> Result {
-46 let (server, nameserver, http_url) = Server::spawn_for_tests().await?;
+46 let (server, nameserver, http_url) = Server::spawn_for_tests().await.e()?;
47 let pkarr_relay_url = {
48 let mut url = http_url.clone();
49 url.set_path("/pkarr");
@@ -158,7 +158,7 @@
158 #[tokio::test]
159 #[traced_test]
160 async fn integration_smoke() -> Result {
-161 let (server, nameserver, http_url) = Server::spawn_for_tests().await?;
+161 let (server, nameserver, http_url) = Server::spawn_for_tests().await.e()?;
162
163 let pkarr_relay = {
164 let mut url = http_url.clone();
@@ -200,7 +200,7 @@
200 max_batch_time: Duration::from_millis(100),
201 ..Default::default()
202 };
-203 let store = ZoneStore::in_memory(options, Default::default())?;
+203 let store = ZoneStore::in_memory(options, Default::default()).e()?;
204
205 // create a signed packet
206 let signed_packet = random_signed_packet(&mut rng)?;
@@ -208,71 +208,76 @@
208
209 store
210 .insert(signed_packet, PacketSource::PkarrPublish)
-211 .await?;
-212
-213 tokio::time::sleep(Duration::from_secs(1)).await;
-214 for _ in 0..10 {
-215 let entry = store.get_signed_packet(&key).await?;
-216 if entry.is_none() {
-217 return Ok(());
-218 }
-219 tokio::time::sleep(Duration::from_secs(1)).await;
-220 }
-221 panic!("store did not evict packet");
-222 }
-223
-224 #[tokio::test]
-225 #[traced_test]
-226 async fn integration_mainline() -> Result {
-227 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0u64);
-228
-229 // run a mainline testnet
-230 let testnet = pkarr::mainline::Testnet::new_async(5).await.e()?;
-231 let bootstrap = testnet.bootstrap.clone();
-232
-233 // spawn our server with mainline support
-234 let (server, nameserver, _http_url) =
-235 Server::spawn_for_tests_with_options(Some(BootstrapOption::Custom(bootstrap)), None)
-236 .await?;
-237
-238 let origin = "irohdns.example.";
+211 .await
+212 .e()?;
+213
+214 tokio::time::sleep(Duration::from_secs(1)).await;
+215 for _ in 0..10 {
+216 let entry = store.get_signed_packet(&key).await.e()?;
+217 if entry.is_none() {
+218 return Ok(());
+219 }
+220 tokio::time::sleep(Duration::from_secs(1)).await;
+221 }
+222 panic!("store did not evict packet");
+223 }
+224
+225 #[tokio::test]
+226 #[traced_test]
+227 async fn integration_mainline() -> Result {
+228 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0u64);
+229
+230 // run a mainline testnet
+231 let testnet = pkarr::mainline::Testnet::new_async(5).await.e()?;
+232 let bootstrap = testnet.bootstrap.clone();
+233
+234 // spawn our server with mainline support
+235 let (server, nameserver, _http_url) =
+236 Server::spawn_for_tests_with_options(Some(BootstrapOption::Custom(bootstrap)), None)
+237 .await
+238 .e()?;
239
-240 // create a signed packet
-241 let secret_key = SecretKey::generate(&mut rng);
-242 let endpoint_id = secret_key.public();
-243 let relay_url: RelayUrl = "https://relay.example.".parse()?;
-244 let endpoint_info = EndpointInfo::new(endpoint_id).with_relay_url(Some(relay_url.clone()));
-245 let signed_packet = endpoint_info.to_pkarr_signed_packet(&secret_key, 30)?;
-246
-247 // publish the signed packet to our DHT
-248 let pkarr = pkarr::Client::builder()
-249 .no_default_network()
-250 .dht(|builder| builder.bootstrap(&testnet.bootstrap))
-251 .build()
-252 .e()?;
-253 pkarr.publish(&signed_packet, None).await.e()?;
-254
-255 // resolve via DNS from our server, which will lookup from our DHT
-256 let resolver = test_resolver(nameserver);
-257 let res = resolver.lookup_endpoint_by_id(&endpoint_id, origin).await?;
-258
-259 assert_eq!(res.endpoint_id, endpoint_id);
-260 assert_eq!(res.relay_url(), Some(&relay_url));
-261
-262 server.shutdown().await?;
-263 Ok(())
-264 }
-265
-266 fn test_resolver(nameserver: SocketAddr) -> DnsResolver {
-267 DnsResolver::with_nameserver(nameserver)
-268 }
-269
-270 fn random_signed_packet<R: CryptoRng + ?Sized>(rng: &mut R) -> Result<SignedPacket> {
-271 let secret_key = SecretKey::generate(rng);
-272 let endpoint_id = secret_key.public();
-273 let relay_url: RelayUrl = "https://relay.example.".parse()?;
-274 let endpoint_info = EndpointInfo::new(endpoint_id).with_relay_url(Some(relay_url.clone()));
-275 let packet = endpoint_info.to_pkarr_signed_packet(&secret_key, 30)?;
-276 Ok(packet)
-277 }
-278}
\ No newline at end of file
+240 let origin = "irohdns.example.";
+241
+242 // create a signed packet
+243 let secret_key = SecretKey::generate(&mut rng);
+244 let endpoint_id = secret_key.public();
+245 let relay_url: RelayUrl = "https://relay.example.".parse()?;
+246 let endpoint_info = EndpointInfo::new(endpoint_id).with_relay_url(Some(relay_url.clone()));
+247 let signed_packet = endpoint_info.to_pkarr_signed_packet(&secret_key, 30)?;
+248
+249 // publish the signed packet to our DHT
+250 let pkarr = pkarr::Client::builder()
+251 .no_default_network()
+252 .dht(|builder| builder.bootstrap(&testnet.bootstrap))
+253 .build()
+254 .e()?;
+255 pkarr.publish(&signed_packet, None).await.e()?;
+256
+257 // resolve via DNS from our server, which will lookup from our DHT
+258 let resolver = test_resolver(nameserver);
+259 let res = resolver
+260 .lookup_endpoint_by_id(&endpoint_id, origin)
+261 .await
+262 .e()?;
+263
+264 assert_eq!(res.endpoint_id, endpoint_id);
+265 assert_eq!(res.relay_url(), Some(&relay_url));
+266
+267 server.shutdown().await.e()?;
+268 Ok(())
+269 }
+270
+271 fn test_resolver(nameserver: SocketAddr) -> DnsResolver {
+272 DnsResolver::with_nameserver(nameserver)
+273 }
+274
+275 fn random_signed_packet<R: CryptoRng + ?Sized>(rng: &mut R) -> Result<SignedPacket> {
+276 let secret_key = SecretKey::generate(rng);
+277 let endpoint_id = secret_key.public();
+278 let relay_url: RelayUrl = "https://relay.example.".parse()?;
+279 let endpoint_info = EndpointInfo::new(endpoint_id).with_relay_url(Some(relay_url.clone()));
+280 let packet = endpoint_info.to_pkarr_signed_packet(&secret_key, 30)?;
+281 Ok(packet)
+282 }
+283}
\ No newline at end of file
diff --git a/pr/3561/docs/src/iroh_dns_server/server.rs.html b/pr/3561/docs/src/iroh_dns_server/server.rs.html
index bbda7c9450..5f492621aa 100644
--- a/pr/3561/docs/src/iroh_dns_server/server.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/server.rs.html
@@ -2,7 +2,7 @@
2use std::sync::Arc;
3
4use iroh_metrics::service::start_metrics_server;
-5use n0_snafu::{Result, ResultExt};
+5use n0_error::{Result, StdResultExt, StackResultExt};
6use tracing::info;
7
8use crate::{
diff --git a/pr/3561/docs/src/iroh_dns_server/store.rs.html b/pr/3561/docs/src/iroh_dns_server/store.rs.html
index 33aa8bb1bd..7f298f95fe 100644
--- a/pr/3561/docs/src/iroh_dns_server/store.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/store.rs.html
@@ -4,7 +4,7 @@
4
5use hickory_server::proto::rr::{Name, RecordSet, RecordType, RrKey};
6use lru::LruCache;
-7use n0_snafu::Result;
+7use n0_error::Result;
8use pkarr::{Client as PkarrClient, SignedPacket};
9use tokio::sync::Mutex;
10use tracing::{debug, trace, warn};
diff --git a/pr/3561/docs/src/iroh_dns_server/store/signed_packets.rs.html b/pr/3561/docs/src/iroh_dns_server/store/signed_packets.rs.html
index 6648adbf0d..0f26b3fd84 100644
--- a/pr/3561/docs/src/iroh_dns_server/store/signed_packets.rs.html
+++ b/pr/3561/docs/src/iroh_dns_server/store/signed_packets.rs.html
@@ -6,7 +6,7 @@
6 time::{Duration, SystemTime},
7};
8
-9use n0_snafu::{Result, ResultExt, format_err};
+9use n0_error::{Result, StdResultExt, StackResultExt, format_err};
10use pkarr::{SignedPacket, Timestamp};
11use redb::{
12 Database, MultimapTableDefinition, ReadableTable, TableDefinition, backends::InMemoryBackend,
@@ -144,10 +144,10 @@
144 },
145 Err(err) => {
146 warn!("get {key} failed: {err:#}");
-147 return Err(err).with_context(|| format!("get packet for {key} failed"))
-148 }
-149 }
-150 }
+147 return Err(err).std_context(format!("get packet for {key} failed"))
+148 }
+149 }
+150 }
151 Message::Upsert { packet, res } => {
152 let key = PublicKeyBytes::from_signed_packet(&packet);
153 trace!("upsert {}", key);
@@ -265,250 +265,251 @@
265 let path = path.as_ref();
266 info!("loading packet database from {}", path.to_string_lossy());
267 if let Some(parent) = path.parent() {
-268 std::fs::create_dir_all(parent).with_context(|| {
-269 format!(
-270 "failed to create database directory at {}",
-271 path.to_string_lossy()
-272 )
-273 })?;
-274 }
-275 let mut db = Database::builder()
-276 .create(path)
-277 .context("failed to open packet database")?;
-278 match db.upgrade() {
-279 Ok(true) => info!("Database was upgraded to redb v3 compatible format"),
-280 Ok(false) => {}
-281 Err(err) => warn!("Database upgrade to redb v3 compatible format failed: {err:#}"),
-282 }
-283 Self::open(db, options, metrics)
-284 }
-285
-286 pub fn in_memory(options: Options, metrics: Arc<Metrics>) -> Result<Self> {
-287 info!("using in-memory packet database");
-288 let db = Database::builder()
-289 .create_with_backend(InMemoryBackend::new())
-290 .e()?;
-291 Self::open(db, options, metrics)
-292 }
-293
-294 pub fn open(db: Database, options: Options, metrics: Arc<Metrics>) -> Result<Self> {
-295 // create tables
-296 let write_tx = db.begin_write().e()?;
-297 let _ = Tables::new(&write_tx).e()?;
-298 write_tx.commit().e()?;
-299 let (send, recv) = mpsc::channel(1024);
-300 let send2 = send.clone();
-301 let cancel = CancellationToken::new();
-302 let cancel2 = cancel.clone();
-303 let cancel3 = cancel.clone();
-304 let actor = Actor {
-305 db,
-306 recv: PeekableReceiver::new(recv),
-307 cancel: cancel2,
-308 options,
-309 metrics,
-310 };
-311 // start an io thread and donate it to the tokio runtime so we can do blocking IO
-312 // inside the thread despite being in a tokio runtime
-313 let _write_thread = IoThread::new("packet-store-actor", move || actor.run())?;
-314 let _evict_thread = IoThread::new("packet-store-evict", move || {
-315 evict_task(send2, options, cancel3)
-316 })?;
-317 Ok(Self {
-318 send,
-319 cancel,
-320 _write_thread,
-321 _evict_thread,
-322 })
-323 }
-324
-325 pub async fn upsert(&self, packet: SignedPacket) -> Result<bool> {
-326 let (tx, rx) = oneshot::channel();
-327 self.send
-328 .send(Message::Upsert { packet, res: tx })
-329 .await
-330 .e()?;
-331 rx.await.e()
-332 }
-333
-334 pub async fn get(&self, key: &PublicKeyBytes) -> Result<Option<SignedPacket>> {
-335 let (tx, rx) = oneshot::channel();
-336 self.send
-337 .send(Message::Get { key: *key, res: tx })
-338 .await
-339 .e()?;
-340 rx.await.e()
-341 }
-342
-343 pub async fn remove(&self, key: &PublicKeyBytes) -> Result<bool> {
-344 let (tx, rx) = oneshot::channel();
-345 self.send
-346 .send(Message::Remove { key: *key, res: tx })
-347 .await
-348 .e()?;
-349 rx.await.e()
-350 }
-351}
-352
-353fn get_packet(
-354 table: &impl ReadableTable<&'static SignedPacketsKey, &'static [u8]>,
-355 key: &PublicKeyBytes,
-356) -> Result<Option<SignedPacket>> {
-357 let Some(row) = table.get(key.as_ref()).context("database fetch failed")? else {
-358 return Ok(None);
-359 };
-360 match SignedPacket::deserialize(row.value()) {
-361 Ok(packet) => Ok(Some(packet)),
-362 Err(err) => {
-363 // Prior to iroh-dns-server v0.35, we stored packets in the default `SignedPacket::as_bytes` serialization from pkarr v2,
-364 // which did not include the `last_seen` timestamp added as a prefix in `SignedPacket::serialize` from pkarr v3.
-365 // If decoding the packet as a serialized pkarr v3 packet fails, we assume it was stored with iroh-dns-server before v0.35,
-366 // and prepend an empty timestamp.
-367 let data = row.value();
-368 let mut buf = Vec::with_capacity(data.len() + 8);
-369 buf.extend(&[0u8; 8]);
-370 buf.extend(data);
-371 match SignedPacket::deserialize(&buf) {
-372 Ok(packet) => Ok(Some(packet)),
-373 Err(err2) => Err(format_err!(
-374 "Failed to decode as pkarr v3: {err:#}. Also failed to decode as pkarr v2: {err2:#}"
-375 )),
-376 }
-377 }
-378 }
-379}
-380
-381async fn evict_task(send: mpsc::Sender<Message>, options: Options, cancel: CancellationToken) {
-382 let cancel2 = cancel.clone();
-383 let _ = cancel2
-384 .run_until_cancelled(async move {
-385 info!("starting evict task");
-386 if let Err(cause) = evict_task_inner(send, options).await {
-387 error!("evict task failed: {:?}", cause);
-388 }
-389 // when we are done for whatever reason we want to shut down the actor
-390 cancel.cancel();
-391 })
-392 .await;
-393}
-394
-395/// Periodically check for expired packets and remove them.
-396async fn evict_task_inner(send: mpsc::Sender<Message>, options: Options) -> Result<()> {
-397 let expiry_us = options.eviction.as_micros() as u64;
-398 loop {
-399 let (tx, rx) = oneshot::channel();
-400 let _ = send.send(Message::Snapshot { res: tx }).await.ok();
-401 // if we can't get the snapshot we exit the loop, main actor dead
-402 let snapshot = rx.await.context("failed to get snapshot")?;
-403
-404 let expired = Timestamp::now() - expiry_us;
-405 trace!("evicting packets older than {}", fmt_time(expired));
-406 // if getting the range fails we exit the loop and shut down
-407 // if individual reads fail we log the error and limp on
-408 for item in snapshot.update_time.range(..expired.to_bytes()).e()? {
-409 let (time, keys) = match item {
-410 Ok(v) => v,
-411 Err(e) => {
-412 error!("failed to read update_time row {:?}", e);
-413 continue;
-414 }
-415 };
-416 let time = Timestamp::from(time.value());
-417 trace!("evicting expired packets at {}", fmt_time(time));
-418 for item in keys {
-419 let key = match item {
-420 Ok(v) => v,
-421 Err(e) => {
-422 error!(
-423 "failed to read update_time item at {}: {:?}",
-424 fmt_time(time),
-425 e
-426 );
-427 continue;
-428 }
-429 };
-430 let key = PublicKeyBytes::new(key.value());
-431
-432 debug!("evicting expired packet {} {}", fmt_time(time), key);
-433 send.send(Message::CheckExpired { time, key }).await.e()?;
-434 }
-435 }
-436 // sleep for the eviction interval so we don't constantly check
-437 tokio::time::sleep(options.eviction_interval).await;
-438 }
-439}
-440
-441/// An io thread that drives a future to completion on the current tokio runtime
-442///
-443/// Inside the future, blocking IO can be done without blocking one of the tokio
-444/// pool threads.
-445#[derive(Debug)]
-446struct IoThread {
-447 handle: Option<std::thread::JoinHandle<()>>,
-448}
-449
-450impl IoThread {
-451 /// Spawn a new io thread.
-452 ///
-453 /// Calling this function requires that the current thread is running in a
-454 /// tokio runtime. It is up to the caller to make sure the future exits,
-455 /// e.g. by using a cancellation token. Otherwise, drop will block.
-456 fn new<F, Fut>(name: &str, f: F) -> Result<Self>
-457 where
-458 F: FnOnce() -> Fut + Send + 'static,
-459 Fut: Future<Output = ()>,
-460 {
-461 let rt = tokio::runtime::Handle::try_current().context("get tokio handle")?;
-462 let handle = std::thread::Builder::new()
-463 .name(name.into())
-464 .spawn(move || rt.block_on(f()))
-465 .context("failed to spawn thread")?;
-466 Ok(Self {
-467 handle: Some(handle),
-468 })
-469 }
-470}
-471
-472impl Drop for IoThread {
-473 fn drop(&mut self) {
-474 if let Some(handle) = self.handle.take() {
-475 let _ = handle.join();
-476 }
-477 }
-478}
-479
-480/// A wrapper for a tokio mpsc receiver that allows peeking at the next message.
-481#[derive(Debug)]
-482pub(super) struct PeekableReceiver<T> {
-483 msg: Option<T>,
-484 recv: tokio::sync::mpsc::Receiver<T>,
-485}
-486
-487#[allow(dead_code)]
-488impl<T> PeekableReceiver<T> {
-489 pub fn new(recv: tokio::sync::mpsc::Receiver<T>) -> Self {
-490 Self { msg: None, recv }
-491 }
-492
-493 /// Receive the next message.
-494 ///
-495 /// Will block if there are no messages.
-496 /// Returns None only if there are no more messages (sender is dropped).
-497 pub async fn recv(&mut self) -> Option<T> {
-498 if let Some(msg) = self.msg.take() {
-499 return Some(msg);
-500 }
-501 self.recv.recv().await
-502 }
-503
-504 /// Push back a message. This will only work if there is room for it.
-505 /// Otherwise, it will fail and return the message.
-506 pub fn push_back(&mut self, msg: T) -> std::result::Result<(), T> {
-507 if self.msg.is_none() {
-508 self.msg = Some(msg);
-509 Ok(())
-510 } else {
-511 Err(msg)
-512 }
-513 }
-514}
\ No newline at end of file
+268 std::fs::create_dir_all(parent).std_context(format!(
+269 "failed to create database directory at {}",
+270 path.to_string_lossy()
+271 ))?;
+272 }
+273 let mut db = Database::builder()
+274 .create(path)
+275 .std_context("failed to open packet database")?;
+276 match db.upgrade() {
+277 Ok(true) => info!("Database was upgraded to redb v3 compatible format"),
+278 Ok(false) => {}
+279 Err(err) => warn!("Database upgrade to redb v3 compatible format failed: {err:#}"),
+280 }
+281 Self::open(db, options, metrics)
+282 }
+283
+284 pub fn in_memory(options: Options, metrics: Arc<Metrics>) -> Result<Self> {
+285 info!("using in-memory packet database");
+286 let db = Database::builder()
+287 .create_with_backend(InMemoryBackend::new())
+288 .e()?;
+289 Self::open(db, options, metrics)
+290 }
+291
+292 pub fn open(db: Database, options: Options, metrics: Arc<Metrics>) -> Result<Self> {
+293 // create tables
+294 let write_tx = db.begin_write().e()?;
+295 let _ = Tables::new(&write_tx).e()?;
+296 write_tx.commit().e()?;
+297 let (send, recv) = mpsc::channel(1024);
+298 let send2 = send.clone();
+299 let cancel = CancellationToken::new();
+300 let cancel2 = cancel.clone();
+301 let cancel3 = cancel.clone();
+302 let actor = Actor {
+303 db,
+304 recv: PeekableReceiver::new(recv),
+305 cancel: cancel2,
+306 options,
+307 metrics,
+308 };
+309 // start an io thread and donate it to the tokio runtime so we can do blocking IO
+310 // inside the thread despite being in a tokio runtime
+311 let _write_thread = IoThread::new("packet-store-actor", move || actor.run())?;
+312 let _evict_thread = IoThread::new("packet-store-evict", move || {
+313 evict_task(send2, options, cancel3)
+314 })?;
+315 Ok(Self {
+316 send,
+317 cancel,
+318 _write_thread,
+319 _evict_thread,
+320 })
+321 }
+322
+323 pub async fn upsert(&self, packet: SignedPacket) -> Result<bool> {
+324 let (tx, rx) = oneshot::channel();
+325 self.send
+326 .send(Message::Upsert { packet, res: tx })
+327 .await
+328 .e()?;
+329 rx.await.e()
+330 }
+331
+332 pub async fn get(&self, key: &PublicKeyBytes) -> Result<Option<SignedPacket>> {
+333 let (tx, rx) = oneshot::channel();
+334 self.send
+335 .send(Message::Get { key: *key, res: tx })
+336 .await
+337 .e()?;
+338 rx.await.e()
+339 }
+340
+341 pub async fn remove(&self, key: &PublicKeyBytes) -> Result<bool> {
+342 let (tx, rx) = oneshot::channel();
+343 self.send
+344 .send(Message::Remove { key: *key, res: tx })
+345 .await
+346 .e()?;
+347 rx.await.e()
+348 }
+349}
+350
+351fn get_packet(
+352 table: &impl ReadableTable<&'static SignedPacketsKey, &'static [u8]>,
+353 key: &PublicKeyBytes,
+354) -> Result<Option<SignedPacket>> {
+355 let Some(row) = table
+356 .get(key.as_ref())
+357 .std_context("database fetch failed")?
+358 else {
+359 return Ok(None);
+360 };
+361 match SignedPacket::deserialize(row.value()) {
+362 Ok(packet) => Ok(Some(packet)),
+363 Err(err) => {
+364 // Prior to iroh-dns-server v0.35, we stored packets in the default `SignedPacket::as_bytes` serialization from pkarr v2,
+365 // which did not include the `last_seen` timestamp added as a prefix in `SignedPacket::serialize` from pkarr v3.
+366 // If decoding the packet as a serialized pkarr v3 packet fails, we assume it was stored with iroh-dns-server before v0.35,
+367 // and prepend an empty timestamp.
+368 let data = row.value();
+369 let mut buf = Vec::with_capacity(data.len() + 8);
+370 buf.extend(&[0u8; 8]);
+371 buf.extend(data);
+372 match SignedPacket::deserialize(&buf) {
+373 Ok(packet) => Ok(Some(packet)),
+374 Err(err2) => Err(format_err!(
+375 "Failed to decode as pkarr v3: {err:#}. Also failed to decode as pkarr v2: {err2:#}"
+376 )),
+377 }
+378 }
+379 }
+380}
+381
+382async fn evict_task(send: mpsc::Sender<Message>, options: Options, cancel: CancellationToken) {
+383 let cancel2 = cancel.clone();
+384 let _ = cancel2
+385 .run_until_cancelled(async move {
+386 info!("starting evict task");
+387 if let Err(cause) = evict_task_inner(send, options).await {
+388 error!("evict task failed: {:?}", cause);
+389 }
+390 // when we are done for whatever reason we want to shut down the actor
+391 cancel.cancel();
+392 })
+393 .await;
+394}
+395
+396/// Periodically check for expired packets and remove them.
+397async fn evict_task_inner(send: mpsc::Sender<Message>, options: Options) -> Result<()> {
+398 let expiry_us = options.eviction.as_micros() as u64;
+399 loop {
+400 let (tx, rx) = oneshot::channel();
+401 let _ = send.send(Message::Snapshot { res: tx }).await.ok();
+402 // if we can't get the snapshot we exit the loop, main actor dead
+403 let snapshot = rx.await.std_context("failed to get snapshot")?;
+404
+405 let expired = Timestamp::now() - expiry_us;
+406 trace!("evicting packets older than {}", fmt_time(expired));
+407 // if getting the range fails we exit the loop and shut down
+408 // if individual reads fail we log the error and limp on
+409 for item in snapshot.update_time.range(..expired.to_bytes()).e()? {
+410 let (time, keys) = match item {
+411 Ok(v) => v,
+412 Err(e) => {
+413 error!("failed to read update_time row {:?}", e);
+414 continue;
+415 }
+416 };
+417 let time = Timestamp::from(time.value());
+418 trace!("evicting expired packets at {}", fmt_time(time));
+419 for item in keys {
+420 let key = match item {
+421 Ok(v) => v,
+422 Err(e) => {
+423 error!(
+424 "failed to read update_time item at {}: {:?}",
+425 fmt_time(time),
+426 e
+427 );
+428 continue;
+429 }
+430 };
+431 let key = PublicKeyBytes::new(key.value());
+432
+433 debug!("evicting expired packet {} {}", fmt_time(time), key);
+434 send.send(Message::CheckExpired { time, key }).await.e()?;
+435 }
+436 }
+437 // sleep for the eviction interval so we don't constantly check
+438 tokio::time::sleep(options.eviction_interval).await;
+439 }
+440}
+441
+442/// An io thread that drives a future to completion on the current tokio runtime
+443///
+444/// Inside the future, blocking IO can be done without blocking one of the tokio
+445/// pool threads.
+446#[derive(Debug)]
+447struct IoThread {
+448 handle: Option<std::thread::JoinHandle<()>>,
+449}
+450
+451impl IoThread {
+452 /// Spawn a new io thread.
+453 ///
+454 /// Calling this function requires that the current thread is running in a
+455 /// tokio runtime. It is up to the caller to make sure the future exits,
+456 /// e.g. by using a cancellation token. Otherwise, drop will block.
+457 fn new<F, Fut>(name: &str, f: F) -> Result<Self>
+458 where
+459 F: FnOnce() -> Fut + Send + 'static,
+460 Fut: Future<Output = ()>,
+461 {
+462 let rt = tokio::runtime::Handle::try_current().std_context("get tokio handle")?;
+463 let handle = std::thread::Builder::new()
+464 .name(name.into())
+465 .spawn(move || rt.block_on(f()))
+466 .std_context("failed to spawn thread")?;
+467 Ok(Self {
+468 handle: Some(handle),
+469 })
+470 }
+471}
+472
+473impl Drop for IoThread {
+474 fn drop(&mut self) {
+475 if let Some(handle) = self.handle.take() {
+476 let _ = handle.join();
+477 }
+478 }
+479}
+480
+481/// A wrapper for a tokio mpsc receiver that allows peeking at the next message.
+482#[derive(Debug)]
+483pub(super) struct PeekableReceiver<T> {
+484 msg: Option<T>,
+485 recv: tokio::sync::mpsc::Receiver<T>,
+486}
+487
+488#[allow(dead_code)]
+489impl<T> PeekableReceiver<T> {
+490 pub fn new(recv: tokio::sync::mpsc::Receiver<T>) -> Self {
+491 Self { msg: None, recv }
+492 }
+493
+494 /// Receive the next message.
+495 ///
+496 /// Will block if there are no messages.
+497 /// Returns None only if there are no more messages (sender is dropped).
+498 pub async fn recv(&mut self) -> Option<T> {
+499 if let Some(msg) = self.msg.take() {
+500 return Some(msg);
+501 }
+502 self.recv.recv().await
+503 }
+504
+505 /// Push back a message. This will only work if there is room for it.
+506 /// Otherwise, it will fail and return the message.
+507 pub fn push_back(&mut self, msg: T) -> std::result::Result<(), T> {
+508 if self.msg.is_none() {
+509 self.msg = Some(msg);
+510 Ok(())
+511 } else {
+512 Err(msg)
+513 }
+514 }
+515}