mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
http: add AnnounceResponse.warning_message; set in http_private
This commit is contained in:
parent
44f4474fb2
commit
70d79b1871
5 changed files with 25 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ pub fn bench(c: &mut Criterion) {
|
|||
incomplete: 500,
|
||||
peers: ResponsePeerListV4(peers),
|
||||
peers6: ResponsePeerListV6(Vec::new()),
|
||||
warning_message: None,
|
||||
};
|
||||
|
||||
let response = Response::Announce(announce_response);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ pub struct AnnounceResponse {
|
|||
pub peers: ResponsePeerListV4,
|
||||
#[serde(default)]
|
||||
pub peers6: ResponsePeerListV6,
|
||||
#[serde(rename = "warning message")]
|
||||
pub warning_message: Option<String>,
|
||||
}
|
||||
|
||||
impl AnnounceResponse {
|
||||
|
|
@ -95,6 +97,17 @@ impl AnnounceResponse {
|
|||
}
|
||||
bytes_written += output.write(b"e")?;
|
||||
|
||||
if let Some(ref warning_message) = self.warning_message {
|
||||
let message_bytes = warning_message.as_bytes();
|
||||
|
||||
bytes_written += output.write(b"d15:warning message")?;
|
||||
bytes_written +=
|
||||
output.write(itoa::Buffer::new().format(message_bytes.len()).as_bytes())?;
|
||||
bytes_written += output.write(b":")?;
|
||||
bytes_written += output.write(message_bytes)?;
|
||||
bytes_written += output.write(b"e")?;
|
||||
}
|
||||
|
||||
Ok(bytes_written)
|
||||
}
|
||||
}
|
||||
|
|
@ -232,6 +245,7 @@ impl quickcheck::Arbitrary for AnnounceResponse {
|
|||
incomplete: usize::arbitrary(g),
|
||||
peers: ResponsePeerListV4::arbitrary(g),
|
||||
peers6: ResponsePeerListV6::arbitrary(g),
|
||||
warning_message: quickcheck::Arbitrary::arbitrary(g),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue