mirror of
https://github.com/actix/actix-web.git
synced 2025-04-05 01:29:36 +00:00
Log errors
This commit is contained in:
parent
1be9ecf668
commit
b5b91fce05
2 changed files with 16 additions and 2 deletions
|
@ -104,13 +104,21 @@ impl Decoder for Codec {
|
|||
Ok(Some((finished, opcode, payload))) => {
|
||||
// continuation is not supported
|
||||
if !finished {
|
||||
error!("No continuation 1");
|
||||
return Err(ProtocolError::NoContinuation);
|
||||
}
|
||||
|
||||
match opcode {
|
||||
OpCode::Continue => Err(ProtocolError::NoContinuation),
|
||||
OpCode::Bad => Err(ProtocolError::BadOpCode),
|
||||
OpCode::Continue => {
|
||||
error!("No continuation 2");
|
||||
Err(ProtocolError::NoContinuation)
|
||||
}
|
||||
OpCode::Bad => {
|
||||
error!("Bad opcode");
|
||||
Err(ProtocolError::BadOpCode)
|
||||
}
|
||||
OpCode::Close => {
|
||||
warn!("Got a close frame!");
|
||||
if let Some(ref pl) = payload {
|
||||
let close_reason = Parser::parse_close_payload(pl);
|
||||
Ok(Some(Frame::Close(close_reason)))
|
||||
|
|
|
@ -32,8 +32,10 @@ impl Parser {
|
|||
// check masking
|
||||
let masked = second & 0x80 != 0;
|
||||
if !masked && server {
|
||||
error!("Protocol unmasked frame");
|
||||
return Err(ProtocolError::UnmaskedFrame);
|
||||
} else if masked && !server {
|
||||
error!("Protocol masked frame");
|
||||
return Err(ProtocolError::MaskedFrame);
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,7 @@ impl Parser {
|
|||
let opcode = OpCode::from(first & 0x0F);
|
||||
|
||||
if let OpCode::Bad = opcode {
|
||||
error!("Protocol invalid opcode");
|
||||
return Err(ProtocolError::InvalidOpcode(first & 0x0F));
|
||||
}
|
||||
|
||||
|
@ -60,6 +63,7 @@ impl Parser {
|
|||
}
|
||||
let len = u64::from_be_bytes(TryFrom::try_from(&src[idx..idx + 8]).unwrap());
|
||||
if len > max_size as u64 {
|
||||
error!("Protocol overflow 1");
|
||||
return Err(ProtocolError::Overflow);
|
||||
}
|
||||
idx += 8;
|
||||
|
@ -70,6 +74,7 @@ impl Parser {
|
|||
|
||||
// check for max allowed size
|
||||
if length > max_size {
|
||||
error!("Protocol overflow 2");
|
||||
return Err(ProtocolError::Overflow);
|
||||
}
|
||||
|
||||
|
@ -120,6 +125,7 @@ impl Parser {
|
|||
// control frames must have length <= 125
|
||||
match opcode {
|
||||
OpCode::Ping | OpCode::Pong if length > 125 => {
|
||||
error!("Protocol invalid length");
|
||||
return Err(ProtocolError::InvalidLength(length));
|
||||
}
|
||||
OpCode::Close if length > 125 => {
|
||||
|
|
Loading…
Reference in a new issue