mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-22 04:00:59 +00:00
improve error output
This commit is contained in:
parent
8c431650e2
commit
a014477773
4 changed files with 4 additions and 3 deletions
|
@ -120,7 +120,7 @@ impl<'a> Endpoint<'a> {
|
||||||
|
|
||||||
let public_key = PublicKey::from_pem(remote_actor.public_key.pem.as_bytes())?;
|
let public_key = PublicKey::from_pem(remote_actor.public_key.pem.as_bytes())?;
|
||||||
if ! (self.signature.verify(&public_key)?) {
|
if ! (self.signature.verify(&public_key)?) {
|
||||||
return Err(Error::SignatureFail);
|
return Err(Error::SignatureFail(self.remote_actor_uri.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(remote_actor)
|
Ok(remote_actor)
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub enum Error {
|
||||||
#[error("Signature error")]
|
#[error("Signature error")]
|
||||||
Signature(#[from] Arc<sigh::Error>),
|
Signature(#[from] Arc<sigh::Error>),
|
||||||
#[error("Signature verification failure")]
|
#[error("Signature verification failure")]
|
||||||
SignatureFail,
|
SignatureFail(String),
|
||||||
#[error("HTTP request error")]
|
#[error("HTTP request error")]
|
||||||
HttpReq(#[from] Arc<http::Error>),
|
HttpReq(#[from] Arc<http::Error>),
|
||||||
#[error("HTTP client error")]
|
#[error("HTTP client error")]
|
||||||
|
|
|
@ -138,6 +138,7 @@ async fn post_relay(
|
||||||
Ok(remote_actor) => remote_actor,
|
Ok(remote_actor) => remote_actor,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
track_request("POST", "relay", "bad_actor");
|
track_request("POST", "relay", "bad_actor");
|
||||||
|
tracing::error!("post_relay bad actor: {e:?}");
|
||||||
return (
|
return (
|
||||||
StatusCode::BAD_REQUEST,
|
StatusCode::BAD_REQUEST,
|
||||||
format!("Bad actor: {:?}", e)
|
format!("Bad actor: {:?}", e)
|
||||||
|
@ -160,6 +161,7 @@ async fn post_relay(
|
||||||
Ok(action) => action,
|
Ok(action) => action,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
track_request("POST", "relay", "bad_action");
|
track_request("POST", "relay", "bad_action");
|
||||||
|
tracing::error!("post_relay bad action: {e:?}");
|
||||||
return (
|
return (
|
||||||
StatusCode::BAD_REQUEST,
|
StatusCode::BAD_REQUEST,
|
||||||
format!("Bad action: {:?}", e)
|
format!("Bad action: {:?}", e)
|
||||||
|
|
|
@ -55,7 +55,6 @@ pub async fn send_raw(
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
histogram!("relay_http_response_duration", t3 - t2, "res" => "err", "host" => host);
|
histogram!("relay_http_response_duration", t3 - t2, "res" => "err", "host" => host);
|
||||||
tracing::error!("send_raw {} response HTTP {}", url, res.status());
|
|
||||||
let response = res.text().await?;
|
let response = res.text().await?;
|
||||||
Err(Error::Response(response))
|
Err(Error::Response(response))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue