update
This commit is contained in:
parent
00dd6e6b8d
commit
7b4a30f30a
8 changed files with 24 additions and 19 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -11,3 +11,5 @@ flamegraph.svg
|
|||
# nix flake
|
||||
/flake.nix
|
||||
/flake.lock
|
||||
|
||||
.vscode
|
||||
14
Cargo.toml
14
Cargo.toml
|
|
@ -47,7 +47,7 @@ tracing = "0.1.40"
|
|||
base64 = "0.22.1"
|
||||
rand = "0.8.5"
|
||||
rsa = "0.9.6"
|
||||
once_cell = "1.19.0"
|
||||
once_cell = "1.20.1"
|
||||
http = "1.1.0"
|
||||
sha2 = { version = "0.10.8", features = ["oid"] }
|
||||
thiserror = "1.0.63"
|
||||
|
|
@ -63,15 +63,15 @@ http-signature-normalization-reqwest = { version = "0.12.0", default-features =
|
|||
"default-spawner",
|
||||
] }
|
||||
http-signature-normalization = "0.7.0"
|
||||
bytes = "1.6.1"
|
||||
bytes = "1.7.2"
|
||||
futures-core = { version = "0.3.30", default-features = false }
|
||||
pin-project-lite = "0.2.14"
|
||||
activitystreams-kinds = "0.3.0"
|
||||
regex = { version = "1.10.5", default-features = false, features = [
|
||||
regex = { version = "1.11.0", default-features = false, features = [
|
||||
"std",
|
||||
"unicode",
|
||||
] }
|
||||
tokio = { version = "1.38.0", features = [
|
||||
tokio = { version = "1.40.0", features = [
|
||||
"sync",
|
||||
"rt",
|
||||
"rt-multi-thread",
|
||||
|
|
@ -90,21 +90,21 @@ actix-web = { version = "4.8.0", default-features = false, optional = true }
|
|||
axum = { git = "https://github.com/tokio-rs/axum.git", features = [
|
||||
"json",
|
||||
], default-features = false, optional = true }
|
||||
tower = { version = "0.4.13", optional = true }
|
||||
tower = { version = "0.5.1", optional = true }
|
||||
hyper = { version = "1.4.1", optional = true }
|
||||
http-body-util = { version = "0.1.2", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0.86"
|
||||
env_logger = "0.11.3"
|
||||
tower-http = { version = "0.5.2", features = ["map-request-body", "util"] }
|
||||
tower-http = { version = "0.6.1", features = ["map-request-body", "util"] }
|
||||
axum = { git = "https://github.com/tokio-rs/axum.git", features = [
|
||||
"http1",
|
||||
"tokio",
|
||||
"query",
|
||||
], default-features = false }
|
||||
axum-macros = { git = "https://github.com/tokio-rs/axum.git" }
|
||||
tokio = { version = "1.38.1", features = ["full"] }
|
||||
tokio = { version = "1.40.0", features = ["full"] }
|
||||
|
||||
[profile.dev]
|
||||
strip = "symbols"
|
||||
|
|
|
|||
|
|
@ -32,15 +32,16 @@ where
|
|||
.headers()
|
||||
.get("Digest")
|
||||
.map(|v| reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default()))
|
||||
.and_then(|v| v.ok());
|
||||
.and_then(std::result::Result::ok);
|
||||
verify_body_hash(header_value.as_ref(), &body)?;
|
||||
|
||||
let (activity, actor) = parse_received_activity::<Activity, ActorT, _>(&body, data).await?;
|
||||
|
||||
let mut vec = Vec::<(_, _)>::with_capacity(request.headers().len());
|
||||
request.headers().iter().for_each(|(k, v)| {
|
||||
let k = reqwest::header::HeaderName::from_str(k.as_str()).unwrap();
|
||||
let v = reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default()).unwrap();
|
||||
let k = reqwest::header::HeaderName::from_str(k.as_str()).expect("Failed to parse header");
|
||||
let v = reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default())
|
||||
.expect("Failed to parse header");
|
||||
vec.push((k, v));
|
||||
});
|
||||
let headers = vec.iter().map(|(k, v)| (k, v)).collect::<Vec<(_, _)>>();
|
||||
|
|
@ -49,7 +50,8 @@ where
|
|||
headers,
|
||||
&reqwest::Method::from_str(request.method().as_str())
|
||||
.map_err(|err| Error::Other(err.to_string()))?,
|
||||
&http::Uri::from_str(&request.uri().to_string()).unwrap(),
|
||||
&http::Uri::from_str(&request.uri().to_string())
|
||||
.map_err(|err| Error::Other(err.to_string()))?,
|
||||
actor.public_key_pem(),
|
||||
)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,13 +30,14 @@ where
|
|||
.headers()
|
||||
.get("Digest")
|
||||
.map(|v| reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default()))
|
||||
.and_then(|v| v.ok());
|
||||
.and_then(std::result::Result::ok);
|
||||
verify_body_hash(header_value.as_ref(), &body.unwrap_or_default())?;
|
||||
|
||||
let mut vec = Vec::<(_, _)>::with_capacity(request.headers().len());
|
||||
request.headers().iter().for_each(|(k, v)| {
|
||||
let k = reqwest::header::HeaderName::from_str(k.as_str()).unwrap();
|
||||
let v = reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default()).unwrap();
|
||||
let k = reqwest::header::HeaderName::from_str(k.as_str()).expect("Failed to parse header");
|
||||
let v = reqwest::header::HeaderValue::from_str(v.to_str().unwrap_or_default())
|
||||
.expect("Failed to parse header");
|
||||
vec.push((k, v));
|
||||
});
|
||||
let headers = vec.iter().map(|(k, v)| (k, v)).collect::<Vec<(_, _)>>();
|
||||
|
|
@ -45,7 +46,8 @@ where
|
|||
headers,
|
||||
&reqwest::Method::from_str(request.method().as_str())
|
||||
.map_err(|err| Error::Other(err.to_string()))?,
|
||||
&http::Uri::from_str(&request.uri().to_string()).unwrap(),
|
||||
&http::Uri::from_str(&request.uri().to_string())
|
||||
.map_err(|err| Error::Other(err.to_string()))?,
|
||||
data,
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use crate::{
|
|||
traits::{ActivityHandler, Actor, Object},
|
||||
};
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRequest, Request},
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
|
|
@ -58,7 +57,6 @@ pub struct ActivityData {
|
|||
body: Vec<u8>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequest<S> for ActivityData
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::config::{Data, FederationConfig, FederationMiddleware};
|
||||
use axum::{async_trait, body::Body, extract::FromRequestParts, http::Request, response::Response};
|
||||
use axum::{body::Body, extract::FromRequestParts, http::Request, response::Response};
|
||||
use http::{request::Parts, StatusCode};
|
||||
use std::task::{Context, Poll};
|
||||
use tower::{Layer, Service};
|
||||
|
|
@ -43,7 +43,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S, T: Clone + 'static> FromRequestParts<S> for Data<T>
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
|
|
|||
|
|
@ -345,6 +345,7 @@ const _IMPL_DIESEL_NEW_TYPE_FOR_OBJECT_ID: () = {
|
|||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
#[allow(missing_docs)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::traits::tests::DbUser;
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ pub(crate) fn verify_body_hash(
|
|||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
#[allow(missing_docs)]
|
||||
pub mod test {
|
||||
use super::*;
|
||||
use crate::activity_sending::generate_request_headers;
|
||||
|
|
|
|||
Loading…
Reference in a new issue