mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_ws: add ErrorResponse, send it when info hash is not allowed
This commit is contained in:
parent
28cc6c261a
commit
1d5eb0dff9
5 changed files with 43 additions and 4 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::Context;
|
||||
use hashbrown::HashMap;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
|
@ -221,6 +223,23 @@ pub struct ScrapeResponse {
|
|||
// pub flags: HashMap<String, usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ErrorResponseAction {
|
||||
Announce,
|
||||
Scrape,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ErrorResponse {
|
||||
pub failure_reason: Cow<'static, str>,
|
||||
/// Action of original request
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub action: Option<ErrorResponseAction>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub info_hash: Option<InfoHash>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum InMessage {
|
||||
|
|
@ -255,6 +274,7 @@ pub enum OutMessage {
|
|||
Answer(MiddlemanAnswerToPeer),
|
||||
AnnounceResponse(AnnounceResponse),
|
||||
ScrapeResponse(ScrapeResponse),
|
||||
ErrorResponse(ErrorResponse),
|
||||
}
|
||||
|
||||
impl OutMessage {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue