Merge pull request #4498 from nymtech/jon/ipr-codec-improvements

IPR codec improvements for icmp beacon
This commit is contained in:
Jon Häggblad
2024-03-25 11:12:28 +01:00
committed by GitHub
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -34,6 +34,13 @@ impl MultiIpPacketCodec {
}
}
pub fn bundle_one_packet(packet: Bytes) -> Bytes {
let mut bundled_packets = BytesMut::new();
bundled_packets.extend_from_slice(&(packet.len() as u16).to_be_bytes());
bundled_packets.extend_from_slice(&packet);
bundled_packets.freeze()
}
// Append a packet to the buffer and return the buffer if it's full
pub fn append_packet(&mut self, packet: Bytes) -> Option<Bytes> {
let mut bundled_packets = BytesMut::new();
@@ -47,7 +54,7 @@ impl MultiIpPacketCodec {
}
// Flush the current buffer and return it.
fn flush_current_buffer(&mut self) -> Bytes {
pub fn flush_current_buffer(&mut self) -> Bytes {
let mut output_buffer = BytesMut::new();
std::mem::swap(&mut output_buffer, &mut self.buffer);
output_buffer.freeze()
@@ -174,6 +174,7 @@ impl MixnetClient {
}
}
#[derive(Clone)]
pub struct MixnetClientSender {
client_input: ClientInput,
packet_type: Option<PacketType>,