Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelvalle committed May 20, 2024
1 parent 03b2cbc commit 9f3ddc5
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ impl Decoder for FrameCodec {
// * Use src.reserve. This is a more efficient way to allocate space in the buffer.
// * Read more here: https://docs.rs/tokio-util/latest/tokio_util/codec/index.html
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
// Check if the frame size exceeds a certain limit to prevent DoS attacks

println!("src.len(): {}", src.len());

// Check if the frame size exceeds the limit to prevent DoS attacks.
if src.len() > FrameCodec::max_frame_size() {
return Err("frame size exceeds limit".into());
}

print!("processing frame: ");

let mut cursor = Cursor::new(&src[..]);
let frame = match Frame::parse(&mut cursor) {
Ok(frame) => frame,
Expand Down

0 comments on commit 9f3ddc5

Please sign in to comment.