From fb8a6e47515e8a510ed3f4d0a4e1d6a4436a287e Mon Sep 17 00:00:00 2001 From: koe Date: Wed, 4 Oct 2023 14:44:58 -0500 Subject: [PATCH] update to tokio-tungstenite v0.20 --- Cargo.toml | 2 +- src/error.rs | 11 +++++++---- src/native.rs | 12 +++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b3e0b8b..7333645 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ httparse = "1.3.4" futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio-tungstenite = "0.16" +tokio-tungstenite = "0.20" tokio = { version = "1.15", default-features = false, features = ["net"] } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/src/error.rs b/src/error.rs index 789f769..a1310e1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -51,18 +51,21 @@ pub enum Error { /// Protocol violation. #[error("WebSocket protocol error: {0}")] Protocol(#[from] ProtocolError), - /// Message send queue full. - #[error("Send queue is full")] - SendQueueFull(crate::Message), + /// Message write buffer is full. + #[error("Write buffer is full")] + WriteBufferFull(crate::Message), /// UTF coding error. #[error("UTF-8 encoding error")] Utf8, + /// Attack attempt detected. + #[error("Attack attempt detected")] + AttackAttempt, /// Invalid URL. #[error("URL error: {0}")] Url(#[from] UrlError), /// HTTP error. #[error("HTTP error: {}", .0.status())] - Http(Response>), + Http(Response>>), /// HTTP format error. #[error("HTTP format error: {0}")] HttpFormat(#[from] http::Error), diff --git a/src/native.rs b/src/native.rs index 23c4a14..d0e849a 100644 --- a/src/native.rs +++ b/src/native.rs @@ -80,7 +80,7 @@ fn msg_conv(msg: Result) -> MsgConvFut { Message::Text(inner) => Ok(crate::Message::Text(inner)), Message::Binary(inner) => Ok(crate::Message::Binary(inner)), Message::Close(inner) => Ok(crate::Message::Close(inner.map(Into::into))), - Message::Ping(_) | Message::Pong(_) => return None, + Message::Ping(_) | Message::Pong(_) | Message::Frame(_) => return None, }, Err(err) => Err(crate::Error::from(err)), }; @@ -113,7 +113,9 @@ impl From for crate::Message { Message::Text(inner) => crate::Message::Text(inner), Message::Binary(inner) => crate::Message::Binary(inner), Message::Close(inner) => crate::Message::Close(inner.map(Into::into)), - Message::Ping(_) | Message::Pong(_) => unreachable!("Unsendable via interface."), + Message::Ping(_) | Message::Pong(_) | Message::Frame(_) => { + unreachable!("Unsendable via interface.") + } } } } @@ -137,8 +139,9 @@ impl From for crate::Error { Error::Tls(inner) => crate::Error::Tls(inner.into()), Error::Capacity(inner) => crate::Error::Capacity(inner.into()), Error::Protocol(inner) => crate::Error::Protocol(inner.into()), - Error::SendQueueFull(inner) => crate::Error::SendQueueFull(inner.into()), + Error::WriteBufferFull(inner) => crate::Error::WriteBufferFull(inner.into()), Error::Utf8 => crate::Error::Utf8, + Error::AttackAttempt => crate::Error::AttackAttempt, Error::Url(inner) => crate::Error::Url(inner.into()), Error::Http(inner) => crate::Error::Http(inner), Error::HttpFormat(inner) => crate::Error::HttpFormat(inner), @@ -194,6 +197,9 @@ impl From for crate::error::ProtocolError { ProtocolError::CustomResponseSuccessful => { crate::error::ProtocolError::CustomResponseSuccessful } + ProtocolError::InvalidHeader(header_name) => { + crate::error::ProtocolError::InvalidHeader(header_name) + } ProtocolError::HandshakeIncomplete => crate::error::ProtocolError::HandshakeIncomplete, ProtocolError::HttparseError(inner) => { crate::error::ProtocolError::HttparseError(inner)