use system resolver if no dns servers specified, make invalid frame type more verbose

This commit is contained in:
Toshit Chawda 2024-09-22 09:07:44 -07:00
parent f798b5544e
commit fdd641c67f
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
5 changed files with 53 additions and 16 deletions

View file

@ -70,7 +70,7 @@ pub enum WispError {
StreamAlreadyClosed,
/// The websocket frame received had an invalid type.
WsFrameInvalidType,
WsFrameInvalidType(ws::OpCode),
/// The websocket frame received was not finished.
WsFrameNotFinished,
/// Error specific to the websocket implementation.
@ -133,7 +133,7 @@ impl std::fmt::Display for WispError {
Self::MaxStreamCountReached => write!(f, "Maximum stream count reached"),
Self::IncompatibleProtocolVersion => write!(f, "Incompatible Wisp protocol version"),
Self::StreamAlreadyClosed => write!(f, "Stream already closed"),
Self::WsFrameInvalidType => write!(f, "Invalid websocket frame type"),
Self::WsFrameInvalidType(ty) => write!(f, "Invalid websocket frame type: {:?}", ty),
Self::WsFrameNotFinished => write!(f, "Unfinished websocket frame"),
Self::WsImplError(err) => write!(f, "Websocket implementation error: {}", err),
Self::WsImplSocketClosed => {

View file

@ -487,7 +487,7 @@ impl<'a> Packet<'a> {
return Err(WispError::WsFrameNotFinished);
}
if frame.opcode != OpCode::Binary {
return Err(WispError::WsFrameInvalidType);
return Err(WispError::WsFrameInvalidType(frame.opcode));
}
let mut bytes = frame.payload;
if bytes.remaining() < 1 {
@ -511,7 +511,7 @@ impl<'a> Packet<'a> {
return Err(WispError::WsFrameNotFinished);
}
if frame.opcode != OpCode::Binary {
return Err(WispError::WsFrameInvalidType);
return Err(WispError::WsFrameInvalidType(frame.opcode));
}
let mut bytes = frame.payload;
if bytes.remaining() < 5 {
@ -587,7 +587,7 @@ impl<'a> TryFrom<ws::Frame<'a>> for Packet<'a> {
return Err(Self::Error::WsFrameNotFinished);
}
if frame.opcode != ws::OpCode::Binary {
return Err(Self::Error::WsFrameInvalidType);
return Err(Self::Error::WsFrameInvalidType(frame.opcode));
}
Packet::try_from(frame.payload)
}