Skip to content

Commit 1d79f92

Browse files
feat: update to [email protected] (#3274)
## Description Depends on n0-computer/tokio-rustls-acme#25 Closes #3273
1 parent 7e13aa3 commit 1d79f92

File tree

8 files changed

+75
-93
lines changed

8 files changed

+75
-93
lines changed

Cargo.lock

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

deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ allow = [
2222
ignore = [
2323
"RUSTSEC-2024-0384", # unmaintained, no upgrade available
2424
"RUSTSEC-2024-0436", # paste
25+
"RUSTSEC-2023-0089", # unmainatined: postcard -> heapless -> atomic-polyfill
2526
]

iroh-dns-server/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readme = "README.md"
1212
[dependencies]
1313
anyhow = "1.0.80"
1414
async-trait = "0.1.77"
15-
axum = { version = "0.7", features = ["macros"] }
15+
axum = { version = "0.8", features = ["macros"] }
1616
axum-server = { version = "0.7", features = ["tls-rustls-no-provider"] }
1717
base64-url = "3.0"
1818
bytes = "1.7"
@@ -24,7 +24,7 @@ derive_more = { version = "1.0.0", features = [
2424
"from",
2525
] }
2626
dirs-next = "2.0.0"
27-
governor = "0.6.3" #needs new release of tower_governor for 0.7.0
27+
governor = "0.8"
2828
hickory-server = { version = "0.25.1", features = ["https-ring"] }
2929
http = "1.0.0"
3030
humantime-serde = "1.1.1"
@@ -45,12 +45,12 @@ tokio-rustls = { version = "0.26", default-features = false, features = [
4545
"logging",
4646
"ring",
4747
] }
48-
tokio-rustls-acme = { version = "0.6", features = ["axum"] }
48+
tokio-rustls-acme = { version = "0.7.1", features = ["axum"] }
4949
tokio-stream = "0.1.14"
5050
tokio-util = "0.7"
5151
toml = "0.8.10"
5252
tower-http = { version = "0.6.1", features = ["cors", "trace"] }
53-
tower_governor = "0.4"
53+
tower_governor = "0.7"
5454
tracing = "0.1"
5555
tracing-subscriber = "0.3.18"
5656
ttl_cache = "0.5.1"

iroh-dns-server/src/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub(crate) fn create_app(state: AppState, rate_limit_config: &RateLimitConfig) -
218218
let router = Router::new()
219219
.route("/dns-query", get(doh::get).post(doh::post))
220220
.route(
221-
"/pkarr/:key",
221+
"/pkarr/{key}",
222222
if let Some(rate_limit) = rate_limit {
223223
get(pkarr::get).put(pkarr::put.layer(rate_limit))
224224
} else {

iroh-dns-server/src/http/doh/extract.rs

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
use std::{
77
fmt::{self, Display, Formatter},
8+
future::Future,
89
net::SocketAddr,
910
str::FromStr,
1011
};
1112

12-
use async_trait::async_trait;
1313
use axum::{
14+
body::Body,
1415
extract::{ConnectInfo, FromRequest, FromRequestParts, Query},
1516
http::Request,
1617
};
@@ -98,53 +99,63 @@ pub struct DnsRequestQuery(pub(crate) DNSRequest, pub(crate) DnsMimeType);
9899
#[derive(Debug)]
99100
pub struct DnsRequestBody(pub(crate) DNSRequest);
100101

101-
#[async_trait]
102102
impl<S> FromRequestParts<S> for DnsRequestQuery
103103
where
104104
S: Send + Sync,
105105
{
106106
type Rejection = AppError;
107107

108-
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
109-
let ConnectInfo(src_addr) = ConnectInfo::from_request_parts(parts, state).await?;
110-
111-
match parts.headers.get(header::ACCEPT) {
112-
Some(content_type) if content_type == "application/dns-message" => {
113-
handle_dns_message_query(parts, state, src_addr).await
114-
}
115-
Some(content_type) if content_type == "application/dns-json" => {
116-
handle_dns_json_query(parts, state, src_addr).await
108+
#[allow(clippy::manual_async_fn)]
109+
fn from_request_parts(
110+
parts: &mut Parts,
111+
state: &S,
112+
) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
113+
async move {
114+
let ConnectInfo(src_addr) = ConnectInfo::from_request_parts(parts, state).await?;
115+
116+
match parts.headers.get(header::ACCEPT) {
117+
Some(content_type) if content_type == "application/dns-message" => {
118+
handle_dns_message_query(parts, state, src_addr).await
119+
}
120+
Some(content_type) if content_type == "application/dns-json" => {
121+
handle_dns_json_query(parts, state, src_addr).await
122+
}
123+
Some(content_type) if content_type == "application/x-javascript" => {
124+
handle_dns_json_query(parts, state, src_addr).await
125+
}
126+
None => handle_dns_message_query(parts, state, src_addr).await,
127+
_ => Err(AppError::with_status(StatusCode::NOT_ACCEPTABLE)),
117128
}
118-
Some(content_type) if content_type == "application/x-javascript" => {
119-
handle_dns_json_query(parts, state, src_addr).await
120-
}
121-
None => handle_dns_message_query(parts, state, src_addr).await,
122-
_ => Err(AppError::with_status(StatusCode::NOT_ACCEPTABLE)),
123129
}
124130
}
125131
}
126132

127-
#[async_trait]
128133
impl<S> FromRequest<S> for DnsRequestBody
129134
where
130135
S: Send + Sync,
131136
{
132137
type Rejection = AppError;
133138

134-
async fn from_request(req: axum::extract::Request, state: &S) -> Result<Self, Self::Rejection> {
135-
let (mut parts, body) = req.into_parts();
139+
#[allow(clippy::manual_async_fn)]
140+
fn from_request(
141+
req: Request<Body>,
142+
state: &S,
143+
) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
144+
async move {
145+
let (mut parts, body) = req.into_parts();
136146

137-
let ConnectInfo(src_addr) = ConnectInfo::from_request_parts(&mut parts, state).await?;
147+
let ConnectInfo(src_addr) = ConnectInfo::from_request_parts(&mut parts, state).await?;
138148

139-
let req = Request::from_parts(parts, body);
149+
let req = Request::from_parts(parts, body);
140150

141-
let body = Bytes::from_request(req, state)
142-
.await
143-
.map_err(|_| AppError::with_status(StatusCode::INTERNAL_SERVER_ERROR))?;
151+
let body = Bytes::from_request(req, state)
152+
.await
153+
.map_err(|_| AppError::with_status(StatusCode::INTERNAL_SERVER_ERROR))?;
144154

145-
let request = decode_request(&body, src_addr)?;
155+
let request = decode_request(&body, src_addr)?;
146156

147-
Ok(DnsRequestBody(request))
157+
Ok(DnsRequestBody(request))
158+
}
148159
}
149160
}
150161

iroh-relay/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ z32 = "1.0.3"
7777
# server feature
7878
clap = { version = "4", features = ["derive"], optional = true }
7979
dashmap = { version = "6.1.0", optional = true }
80-
governor = { version = "0.7.0", optional = true }
80+
governor = { version = "0.8.0", optional = true }
8181
hickory-proto = { version = "0.25.1", default-features = false, optional = true }
8282
rcgen = { version = "0.13", optional = true }
8383
regex = { version = "1.7.1", optional = true }
@@ -86,7 +86,7 @@ rustls-cert-reloadable-resolver = { version = "0.7.1", optional = true }
8686
rustls-cert-file-reader = { version = "0.4.1", optional = true }
8787
rustls-pemfile = { version = "2.1", optional = true }
8888
time = { version = "0.3.37", optional = true }
89-
tokio-rustls-acme = { version = "0.6", optional = true }
89+
tokio-rustls-acme = { version = "0.7.1", optional = true }
9090
tokio-websockets = { version = "0.11.3", features = ["rustls-bring-your-own-connector", "ring", "getrandom", "rand", "server"], optional = true } # server-side websocket implementation
9191
toml = { version = "0.8", optional = true }
9292
tracing-subscriber = { version = "0.3", features = [

iroh/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ swarm-discovery = { version = "0.3.1", optional = true }
8888
futures-util = "0.3"
8989

9090
# test_utils
91-
axum = { version = "0.7", optional = true }
91+
axum = { version = "0.8", optional = true }
9292

9393
# Examples
9494
clap = { version = "4", features = ["derive"], optional = true }
@@ -132,7 +132,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
132132

133133
# *non*-wasm-in-browser test/dev dependencies
134134
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dev-dependencies]
135-
axum = { version = "0.7" }
135+
axum = { version = "0.8" }
136136
clap = { version = "4", features = ["derive"] }
137137
futures-lite = "2.6"
138138
pretty_assertions = "1.4"

iroh/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub(crate) mod pkarr_relay {
310310
pub async fn run_pkarr_relay(state: AppState) -> Result<(Url, CleanupDropGuard)> {
311311
let bind_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
312312
let app = Router::new()
313-
.route("/pkarr/:key", put(pkarr_put))
313+
.route("/pkarr/{key}", put(pkarr_put))
314314
.with_state(state);
315315
let listener = tokio::net::TcpListener::bind(bind_addr).await?;
316316
let bound_addr = listener.local_addr()?;

0 commit comments

Comments
 (0)