mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +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
|
|
@ -91,6 +91,15 @@ pub fn deserialize_20_bytes<'de, D>(
|
|||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn serialize_20_bytes<S>(
|
||||
bytes: &[u8; 20],
|
||||
serializer: S
|
||||
) -> Result<S::Ok, S::Error> where S: Serializer {
|
||||
serializer.serialize_bytes(bytes)
|
||||
}
|
||||
|
||||
|
||||
pub struct InfoHashVecVisitor;
|
||||
|
||||
|
||||
|
|
@ -162,12 +171,10 @@ pub fn serialize_response_peers_compact<S>(
|
|||
bytes.extend_from_slice(&peer.port.to_be_bytes())
|
||||
},
|
||||
IpAddr::V6(_) => {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let text: String = bytes.into_iter().map(|byte| byte as char).collect();
|
||||
|
||||
serializer.serialize_str(&text)
|
||||
serializer.serialize_bytes(&bytes)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue