Skip to content

Commit

Permalink
[BACKPORT] hyperledger-iroha#4120: Do not use the tungstenite re-ex…
Browse files Browse the repository at this point in the history
…ported from `tokio_tungstenite`

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 8, 2023
1 parent 35fc900 commit b9b1537
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 8 deletions.
101 changes: 100 additions & 1 deletion 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
30 changes: 28 additions & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledg
is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" }
maintenance = { status = "actively-developed" }

[features]
# Use rustls by default to avoid OpenSSL dependency, simplifying compilation with musl
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]
iroha_config = { workspace = true }
iroha_crypto = { workspace = true }
Expand All @@ -31,7 +56,7 @@ iroha_logger = { workspace = true }
iroha_telemetry = { workspace = true }
iroha_version = { workspace = true, features = ["http"] }

attohttpc = "0.26.1"
attohttpc = { version = "0.26.1", default-features = false }
eyre = { workspace = true }
http = "0.2.9"
url = { workspace = true }
Expand All @@ -44,7 +69,8 @@ displaydoc = { workspace = true }
derive_more = { workspace = true }
parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] }
tokio = { workspace = true, features = ["rt"] }
tokio-tungstenite = { workspace = true, features = ["native-tls"] }
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 b9b1537

Please sign in to comment.