mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
aquatic_http: serialize info_hash and peer_id properly
This commit is contained in:
parent
bfabd1fe57
commit
16333b5a08
2 changed files with 22 additions and 5 deletions
|
|
@ -14,6 +14,7 @@ use serde_helpers::*;
|
|||
pub struct PeerId(
|
||||
#[serde(
|
||||
deserialize_with = "deserialize_20_bytes",
|
||||
serialize_with = "serialize_20_bytes",
|
||||
)]
|
||||
pub [u8; 20]
|
||||
);
|
||||
|
|
@ -24,11 +25,13 @@ pub struct PeerId(
|
|||
pub struct InfoHash(
|
||||
#[serde(
|
||||
deserialize_with = "deserialize_20_bytes",
|
||||
serialize_with = "serialize_20_bytes",
|
||||
)]
|
||||
pub [u8; 20]
|
||||
);
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize)]
|
||||
pub struct ResponsePeer {
|
||||
pub ip_address: IpAddr,
|
||||
|
|
@ -225,6 +228,13 @@ pub enum Response {
|
|||
|
||||
impl Response {
|
||||
pub fn to_bytes(self) -> Vec<u8> {
|
||||
bendy::serde::to_bytes(&self).unwrap()
|
||||
match bendy::serde::to_bytes(&self){
|
||||
Ok(bytes) => bytes,
|
||||
Err(err) => {
|
||||
log::error!("error encoding response: {}", err);
|
||||
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue