Skip to content

Commit 894ff10

Browse files
committed
codex did it
1 parent 4e830d1 commit 894ff10

37 files changed

+126
-182
lines changed

Cargo.lock

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-dns-server/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ humantime-serde = "1.1.1"
3131
iroh-metrics = { version = "0.36", features = ["service"] }
3232
lru = "0.16"
3333
n0-future = "0.3.0"
34-
n0-snafu = "0.2.2"
3534
pkarr = { version = "5", features = ["relays", "dht"], default-features = false }
3635
rcgen = "0.14"
3736
redb = "2.6.3"
@@ -40,7 +39,7 @@ rustls = { version = "0.23.33", default-features = false, features = ["ring"] }
4039
rustls-pemfile = { version = "2.1" }
4140
serde = { version = "1", features = ["derive"] }
4241
struct_iterable = "0.1.1"
43-
snafu = { version = "0.8.5", features = ["rust_1_81"] }
42+
n0-error = { git = "https://github.com/n0-computer/n0-error" }
4443
strum = { version = "0.27", features = ["derive"] }
4544
tokio = { version = "1", features = ["full"] }
4645
tokio-rustls = { version = "0.26", default-features = false, features = [
@@ -64,7 +63,6 @@ criterion = "0.7.0"
6463
data-encoding = "2.3.3"
6564
hickory-resolver = "0.25.0"
6665
iroh = { path = "../iroh" }
67-
n0-error = { git = "https://github.com/n0-computer/n0-error" }
6866
rand = "0.9.2"
6967
rand_chacha = "0.9"
7068
tracing-test = "0.2.5"

iroh-dns-server/benches/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
44
use iroh::{SecretKey, discovery::pkarr::PkarrRelayClient, endpoint_info::EndpointInfo};
55
use iroh_dns_server::{ZoneStore, config::Config, metrics::Metrics, server::Server};
6-
use n0_snafu::Result;
6+
use n0_error::Result;
77
use rand_chacha::rand_core::SeedableRng;
88
use tokio::runtime::Runtime;
99

iroh-dns-server/examples/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::str::FromStr;
22

33
use clap::Parser;
44
use iroh::EndpointId;
5-
use n0_snafu::{Result, ResultExt};
5+
use n0_error::{Result, StdResultExt};
66

77
#[derive(Debug, Parser)]
88
struct Cli {
@@ -26,7 +26,7 @@ fn main() -> Result<()> {
2626
}
2727
Command::PkarrToEndpoint { z32_pubkey } => {
2828
let public_key = pkarr::PublicKey::try_from(z32_pubkey.as_str()).e()?;
29-
let endpoint_id = EndpointId::from_bytes(public_key.as_bytes()).e()?;
29+
let endpoint_id = EndpointId::from_bytes(public_key.as_bytes())?;
3030
println!("{endpoint_id}")
3131
}
3232
}

iroh-dns-server/examples/publish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use iroh::{
1010
},
1111
endpoint_info::{EndpointIdExt, EndpointInfo, IROH_TXT_NAME},
1212
};
13-
use n0_snafu::{Result, ResultExt};
13+
use n0_error::{Result, StdResultExt};
1414
use url::Url;
1515

1616
const DEV_PKARR_RELAY_URL: &str = "http://localhost:8080/pkarr";
@@ -61,7 +61,7 @@ async fn main() -> Result<()> {
6161

6262
let secret_key = match std::env::var("IROH_SECRET") {
6363
Ok(s) => SecretKey::from_str(&s)
64-
.context("failed to parse IROH_SECRET environment variable as iroh secret key")?,
64+
.std_context("failed to parse IROH_SECRET environment variable as iroh secret key")?,
6565
Err(_) => {
6666
let s = SecretKey::generate(&mut rand::rng());
6767
println!("Generated a new endpoint secret. To reuse, set");

iroh-dns-server/examples/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use iroh::{
44
discovery::dns::{N0_DNS_ENDPOINT_ORIGIN_PROD, N0_DNS_ENDPOINT_ORIGIN_STAGING},
55
dns::DnsResolver,
66
};
7-
use n0_snafu::{Result, ResultExt};
7+
use n0_error::{Result, StdResultExt, format_err};
88

99
const DEV_DNS_SERVER: &str = "127.0.0.1:5300";
1010
const DEV_DNS_ORIGIN_DOMAIN: &str = "irohdns.example";
@@ -51,7 +51,7 @@ async fn main() -> Result<()> {
5151
.await
5252
.e()?
5353
.next()
54-
.context("failed to resolve DNS server address")?;
54+
.ok_or_else(|| format_err!("failed to resolve DNS server address"))?;
5555
DnsResolver::with_nameserver(addr)
5656
} else {
5757
match args.env {

iroh-dns-server/src/config.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
time::Duration,
88
};
99

10-
use n0_snafu::{Result, ResultExt};
10+
use n0_error::{Result, StackResultExt, StdResultExt};
1111
use serde::{Deserialize, Serialize};
1212
use tracing::info;
1313

@@ -162,7 +162,10 @@ impl Config {
162162
);
163163
let s = tokio::fs::read_to_string(path.as_ref())
164164
.await
165-
.with_context(|| format!("failed to read {}", path.as_ref().to_string_lossy()))?;
165+
.std_context(format!(
166+
"failed to read {}",
167+
path.as_ref().to_string_lossy()
168+
))?;
166169
let config: Config = toml::from_str(&s).e()?;
167170
Ok(config)
168171
}
@@ -172,8 +175,9 @@ impl Config {
172175
let dir = if let Some(val) = env::var_os("IROH_DNS_DATA_DIR") {
173176
PathBuf::from(val)
174177
} else {
175-
let path = dirs_next::data_dir()
176-
.context("operating environment provides no directory for application data")?;
178+
let path = dirs_next::data_dir().std_context(
179+
"operating environment provides no directory for application data",
180+
)?;
177181

178182
path.join("iroh-dns")
179183
};

iroh-dns-server/src/dns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use hickory_server::{
2525
server::{Request, RequestHandler, ResponseHandler, ResponseInfo},
2626
store::in_memory::InMemoryAuthority,
2727
};
28-
use n0_snafu::{Result, ResultExt, format_err};
28+
use n0_error::{Result, StdResultExt, format_err};
2929
use serde::{Deserialize, Serialize};
3030
use tokio::{
3131
net::{TcpListener, UdpSocket},

iroh-dns-server/src/dns/node_authority.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use hickory_server::{
1313
server::RequestInfo,
1414
store::in_memory::InMemoryAuthority,
1515
};
16-
use n0_snafu::{Result, ResultExt};
17-
use snafu::whatever;
16+
use n0_error::{Result, StackResultExt, StdResultExt, whatever};
1817
use tracing::{debug, trace};
1918

2019
use crate::{
@@ -191,8 +190,8 @@ fn parse_name_as_pkarr_with_origin(
191190
let mut labels_without_origin = labels.skip(origin.num_labels() as usize);
192191
let pkey_label = labels_without_origin.next().expect("length checked above");
193192
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")?;
193+
let pkey = PublicKeyBytes::from_z32(pkey_str)
194+
.std_context("not a valid pkarr name: invalid pubkey")?;
196195
let remaining_name = Name::from_labels(labels_without_origin.rev()).e()?;
197196
return Ok((remaining_name, pkey, origin.clone()));
198197
}

iroh-dns-server/src/http.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ use axum::{
1414
response::IntoResponse,
1515
routing::get,
1616
};
17-
use n0_snafu::{Result, ResultExt};
17+
use n0_error::{Result, StackResultExt, StdResultExt, whatever};
1818
use serde::{Deserialize, Serialize};
19-
use snafu::whatever;
2019
use tokio::{net::TcpListener, task::JoinSet};
2120
use tower_http::{
2221
cors::{self, CorsLayer},
@@ -112,9 +111,9 @@ impl HttpServer {
112111
.join(config.cert_mode.to_string());
113112
tokio::fs::create_dir_all(&cache_path)
114113
.await
115-
.with_context(|| {
116-
format!("failed to create cert cache dir at {cache_path:?}")
117-
})?;
114+
.std_context(format!(
115+
"failed to create cert cache dir at {cache_path:?}"
116+
))?;
118117
config
119118
.cert_mode
120119
.build(
@@ -173,11 +172,11 @@ impl HttpServer {
173172
Err(err) if err.is_cancelled() => {}
174173
Ok(Err(err)) => {
175174
warn!(?err, "task failed");
176-
final_res = Err(err).context("task");
175+
final_res = Err(err).std_context("task");
177176
}
178177
Err(err) => {
179178
warn!(?err, "task panicked");
180-
final_res = Err(err).context("join");
179+
final_res = Err(err).std_context("join");
181180
}
182181
}
183182
}

0 commit comments

Comments
 (0)