diff --git a/Cargo.toml b/Cargo.toml index 6b10a96..02fe7eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,11 +25,12 @@ http = "0.2.9" sha2 = "0.10.6" thiserror = "1.0.40" derive_builder = "0.12.0" -itertools = "0.10.5" +itertools = "0.11.0" dyn-clone = "1.0.11" enum_delegate = "0.2.0" httpdate = "1.0.2" -http-signature-normalization-reqwest = { version = "0.8.0", default-features = false, features = [ +http-signature-normalization-reqwest = { version = "0.10.0", default-features = false, features = [ + "default-spawner", "sha-2", "middleware", ] } @@ -50,14 +51,13 @@ tokio = { version = "1.21.2", features = [ actix-web = { version = "4.3.1", default-features = false, optional = true } # Axum -axum = { version = "0.6.18", features = [ +axum = { git = "https://github.com/tokio-rs/axum.git", features = [ "json", - "headers", ], default-features = false, optional = true } -tower = { version = "0.4.13", optional = true } -hyper = { version = "0.14", optional = true } -futures = "0.3.28" -moka = { version = "0.11.2", features = ["future"] } +tower = { version = "*", optional = true } +hyper = { version = "*", optional = true } +futures = "*" +moka = { version = "0.12.1", features = ["future"] } [features] default = ["actix-web", "axum"] @@ -67,14 +67,14 @@ axum = ["dep:axum", "dep:tower", "dep:hyper"] [dev-dependencies] rand = "0.8.5" env_logger = "0.10.0" -tower-http = { version = "0.4.0", features = ["map-request-body", "util"] } -axum = { version = "0.6.18", features = [ +tower-http = { version = "*", features = ["map-request-body", "util"] } +axum = { git = "https://github.com/tokio-rs/axum.git", features = [ "http1", "tokio", "query", ], default-features = false } -axum-macros = "0.3.7" -tokio = { version = "1.21.2", features = ["full"] } +axum-macros = { git = "https://github.com/tokio-rs/axum.git" } +tokio = { version = "*", features = ["full"] } [profile.dev] strip = "symbols" diff --git a/examples/live_federation/main.rs b/examples/live_federation/main.rs index 4326226..ca92764 100644 --- a/examples/live_federation/main.rs +++ b/examples/live_federation/main.rs @@ -10,10 +10,8 @@ use axum::{ Router, }; use error::Error; -use std::{ - net::ToSocketAddrs, - sync::{Arc, Mutex}, -}; +use std::sync::{Arc, Mutex}; +use tokio::net::TcpListener; use tracing::log::{info, LevelFilter}; mod activities; @@ -58,13 +56,8 @@ async fn main() -> Result<(), Error> { .route("/.well-known/webfinger", get(webfinger)) .layer(FederationMiddleware::new(config)); - let addr = BIND_ADDRESS - .to_socket_addrs()? - .next() - .expect("Failed to lookup domain name"); - axum::Server::bind(&addr) - .serve(app.into_make_service()) - .await?; + let addr = TcpListener::bind(BIND_ADDRESS).await?; + axum::serve(addr, app.into_make_service()).await?; Ok(()) } diff --git a/examples/local_federation/axum/http.rs b/examples/local_federation/axum/http.rs index 3202117..16c5f0e 100644 --- a/examples/local_federation/axum/http.rs +++ b/examples/local_federation/axum/http.rs @@ -22,7 +22,7 @@ use axum::{ }; use axum_macros::debug_handler; use serde::Deserialize; -use std::net::ToSocketAddrs; +use std::net::TcpListener; use tracing::info; pub fn listen(config: &FederationConfig) -> Result<(), Error> { @@ -35,11 +35,8 @@ pub fn listen(config: &FederationConfig) -> Result<(), Error> { .route("/.well-known/webfinger", get(webfinger)) .layer(FederationMiddleware::new(config)); - let addr = hostname - .to_socket_addrs()? - .next() - .expect("Failed to lookup domain name"); - let server = axum::Server::bind(&addr).serve(app.into_make_service()); + let addr = tokio::net::TcpListener::from_std(TcpListener::bind(hostname)?)?; + let server = axum::serve(addr, app.into_make_service()); tokio::spawn(server); Ok(()) diff --git a/src/activity_sending.rs b/src/activity_sending.rs index 30713b4..ef23fb5 100644 --- a/src/activity_sending.rs +++ b/src/activity_sending.rs @@ -215,6 +215,7 @@ mod tests { sync::{atomic::AtomicUsize, Arc}, time::Instant, }; + use tokio::net::TcpListener; use tracing::info; use crate::{config::FederationConfig, http_signatures::generate_actor_keypair}; @@ -247,10 +248,12 @@ mod tests { .route("/", post(dodgy_handler)) .with_state(state); - axum::Server::bind(&"0.0.0.0:8001".parse().unwrap()) - .serve(app.into_make_service()) - .await - .unwrap(); + axum::serve( + TcpListener::bind("0.0.0.0:8001").await.unwrap(), + app.into_make_service(), + ) + .await + .unwrap(); } #[tokio::test(flavor = "multi_thread")] diff --git a/src/axum/inbox.rs b/src/axum/inbox.rs index 6c20e25..546f7be 100644 --- a/src/axum/inbox.rs +++ b/src/axum/inbox.rs @@ -11,7 +11,7 @@ use crate::{ }; use axum::{ async_trait, - body::{Bytes, HttpBody}, + body::Body, extract::FromRequest, http::{Request, StatusCode}, response::{IntoResponse, Response}, @@ -67,17 +67,13 @@ pub struct ActivityData { } #[async_trait] -impl FromRequest for ActivityData +impl FromRequest for ActivityData where - Bytes: FromRequest, - B: HttpBody + Send + 'static, S: Send + Sync, - ::Error: std::fmt::Display, - ::Data: Send, { type Rejection = Response; - async fn from_request(req: Request, _state: &S) -> Result { + async fn from_request(req: Request, _state: &S) -> Result { let (parts, body) = req.into_parts(); // this wont work if the body is an long running stream