mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
aquatic_http: check info_hash and peer_id len when deserializing
This commit is contained in:
parent
5e7f8bea20
commit
c8de9857f8
3 changed files with 33 additions and 61 deletions
|
|
@ -4,9 +4,9 @@ use serde::{Serialize, Deserialize, Serializer};
|
|||
|
||||
use crate::common::Peer;
|
||||
|
||||
// mod serde_helpers;
|
||||
mod serde_helpers;
|
||||
|
||||
// use serde_helpers::*;
|
||||
use serde_helpers::*;
|
||||
|
||||
|
||||
pub fn serialize_response_peers_compact<S>(
|
||||
|
|
@ -36,10 +36,9 @@ pub fn serialize_response_peers_compact<S>(
|
|||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct PeerId(
|
||||
// #[serde(
|
||||
// deserialize_with = "deserialize_20_bytes",
|
||||
// serialize_with = "serialize_20_bytes"
|
||||
// )]
|
||||
#[serde(
|
||||
deserialize_with = "deserialize_20_char_string",
|
||||
)]
|
||||
pub String
|
||||
);
|
||||
|
||||
|
|
@ -47,10 +46,9 @@ pub struct PeerId(
|
|||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct InfoHash(
|
||||
// #[serde(
|
||||
// deserialize_with = "deserialize_20_bytes",
|
||||
// serialize_with = "serialize_20_bytes"
|
||||
// )]
|
||||
#[serde(
|
||||
deserialize_with = "deserialize_20_char_string",
|
||||
)]
|
||||
pub String
|
||||
);
|
||||
|
||||
|
|
@ -129,7 +127,10 @@ pub struct AnnounceResponseFailure {
|
|||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct ScrapeRequest {
|
||||
#[serde(rename = "info_hash")]
|
||||
#[serde(
|
||||
rename = "info_hash",
|
||||
deserialize_with = "deserialize_info_hashes" // FIXME: does this work?
|
||||
)]
|
||||
pub info_hashes: Vec<InfoHash>,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue