Skip to content

Commit

Permalink
[fix] #4120: Do not use the tungstenite re-exported from `tokio_tun…
Browse files Browse the repository at this point in the history
…gstenite`

Re-exported does not have the TLS fully functional if we only enable it on `tokio-tungstenite`, so a direct dependency is required

Signed-off-by: Nikita Strygin <[email protected]>
  • Loading branch information
DCNick3 committed Dec 7, 2023
1 parent 9b5559a commit 46117d5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ futures = { version = "0.3.28", default-features = false }
tokio = "1.33.0"
tokio-stream = "0.1.14"
tokio-tungstenite = "0.20.1"
tungstenite = "0.20.1"

crossbeam = "0.8.2"
crossbeam-queue = "0.3.8"
Expand Down
5 changes: 5 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ default = ["tls-rustls-native-roots"]
tls-native = [
"attohttpc/tls-native",
"tokio-tungstenite/native-tls",
"tungstenite/native-tls",
]
tls-native-vendored = [
"attohttpc/tls-native-vendored",
"tokio-tungstenite/native-tls-vendored",
"tungstenite/native-tls-vendored",
]
tls-rustls-native-roots = [
"attohttpc/tls-rustls-native-roots",
"tokio-tungstenite/rustls-tls-native-roots",
"tungstenite/rustls-tls-native-roots",
]
tls-rustls-webpki-roots = [
"attohttpc/tls-rustls-webpki-roots",
"tokio-tungstenite/rustls-tls-webpki-roots",
"tungstenite/rustls-tls-webpki-roots",
]

[dependencies]
Expand All @@ -66,6 +70,7 @@ derive_more = { workspace = true }
parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] }
tokio = { workspace = true, features = ["rt"] }
tokio-tungstenite = { workspace = true }
tungstenite = { workspace = true }
futures-util = "0.3.28"

[dev-dependencies]
Expand Down
8 changes: 3 additions & 5 deletions client/src/http_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use attohttpc::{
};
use eyre::{eyre, Error, Result, WrapErr};
use http::header::HeaderName;
use tokio_tungstenite::tungstenite::{
client::IntoClientRequest, stream::MaybeTlsStream, WebSocket,
};
pub use tokio_tungstenite::tungstenite::{Error as WebSocketError, Message as WebSocketMessage};
use tungstenite::{client::IntoClientRequest, stream::MaybeTlsStream, WebSocket};
pub use tungstenite::{Error as WebSocketError, Message as WebSocketMessage};
use url::Url;

use crate::http::{Method, RequestBuilder, Response};
Expand Down Expand Up @@ -137,7 +135,7 @@ pub struct DefaultWebSocketStreamRequest(http::Request<()>);
impl DefaultWebSocketStreamRequest {
/// Open [`WebSocketStream`] synchronously.
pub fn connect(self) -> Result<WebSocketStream> {
let (stream, _) = tokio_tungstenite::tungstenite::connect(self.0)?;
let (stream, _) = tungstenite::connect(self.0)?;
Ok(stream)
}

Expand Down

0 comments on commit 46117d5

Please sign in to comment.