bump tungstenite to 0.20.1 (#2807)

Co-authored-by: Przemyslaw Hugh Kaznowski <hughkaznowski@protonmail.com>
Co-authored-by: Tristan F. <LeoDog896@hotmail.com>
This commit is contained in:
Brian 2023-10-18 17:54:04 +09:00 committed by GitHub
parent 3a3125d030
commit 87859158d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 82 deletions

92
Cargo.lock generated
View file

@ -591,7 +591,7 @@ dependencies = [
"sha1", "sha1",
"sync_wrapper", "sync_wrapper",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-tungstenite 0.20.0", "tokio-tungstenite 0.20.1",
"tower", "tower",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
@ -688,10 +688,10 @@ dependencies = [
"http-body", "http-body",
"hyper", "hyper",
"pin-project-lite", "pin-project-lite",
"rustls 0.21.6", "rustls",
"rustls-pemfile", "rustls-pemfile",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-rustls 0.24.1", "tokio-rustls",
"tower-service", "tower-service",
] ]
@ -2544,9 +2544,9 @@ dependencies = [
"futures-util", "futures-util",
"http", "http",
"hyper", "hyper",
"rustls 0.21.6", "rustls",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-rustls 0.24.1", "tokio-rustls",
] ]
[[package]] [[package]]
@ -4234,14 +4234,14 @@ dependencies = [
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustls 0.21.6", "rustls",
"rustls-pemfile", "rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-native-tls", "tokio-native-tls",
"tokio-rustls 0.24.1", "tokio-rustls",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
"url", "url",
@ -4249,7 +4249,7 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots 0.25.2", "webpki-roots",
"winreg", "winreg",
] ]
@ -4598,18 +4598,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "rustls"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
dependencies = [
"log",
"ring",
"sct",
"webpki",
]
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.21.6" version = "0.21.6"
@ -5322,7 +5310,7 @@ dependencies = [
"rquickjs", "rquickjs",
"rust-stemmers", "rust-stemmers",
"rust_decimal", "rust_decimal",
"rustls 0.20.8", "rustls",
"scrypt", "scrypt",
"semver 1.0.18", "semver 1.0.18",
"serde", "serde",
@ -5341,7 +5329,7 @@ dependencies = [
"thiserror", "thiserror",
"time 0.3.27", "time 0.3.27",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-tungstenite 0.18.0", "tokio-tungstenite 0.20.1",
"tokio-util", "tokio-util",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
@ -5799,24 +5787,13 @@ dependencies = [
"tokio-sync", "tokio-sync",
] ]
[[package]]
name = "tokio-rustls"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"rustls 0.20.8",
"tokio 1.32.0",
"webpki",
]
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.24.1" version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [ dependencies = [
"rustls 0.21.6", "rustls",
"tokio 1.32.0", "tokio 1.32.0",
] ]
@ -5892,26 +5869,25 @@ checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"log", "log",
"native-tls",
"rustls 0.20.8",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-native-tls",
"tokio-rustls 0.23.4",
"tungstenite 0.18.0", "tungstenite 0.18.0",
"webpki",
"webpki-roots 0.22.6",
] ]
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.20.0" version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"log", "log",
"native-tls",
"rustls",
"tokio 1.32.0", "tokio 1.32.0",
"tungstenite 0.20.0", "tokio-native-tls",
"tokio-rustls",
"tungstenite 0.20.1",
"webpki-roots",
] ]
[[package]] [[package]]
@ -6043,7 +6019,7 @@ dependencies = [
"prost", "prost",
"rustls-pemfile", "rustls-pemfile",
"tokio 1.32.0", "tokio 1.32.0",
"tokio-rustls 0.24.1", "tokio-rustls",
"tokio-stream", "tokio-stream",
"tower", "tower",
"tower-layer", "tower-layer",
@ -6229,21 +6205,18 @@ dependencies = [
"http", "http",
"httparse", "httparse",
"log", "log",
"native-tls",
"rand 0.8.5", "rand 0.8.5",
"rustls 0.20.8",
"sha1", "sha1",
"thiserror", "thiserror",
"url", "url",
"utf-8", "utf-8",
"webpki",
] ]
[[package]] [[package]]
name = "tungstenite" name = "tungstenite"
version = "0.20.0" version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"bytes 1.4.0", "bytes 1.4.0",
@ -6251,7 +6224,9 @@ dependencies = [
"http", "http",
"httparse", "httparse",
"log", "log",
"native-tls",
"rand 0.8.5", "rand 0.8.5",
"rustls",
"sha1", "sha1",
"thiserror", "thiserror",
"url", "url",
@ -6551,25 +6526,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.25.2" version = "0.25.2"

View file

@ -98,7 +98,7 @@ roaring = { version = "0.10.2", features = ["serde"] }
rocksdb = { version = "0.21.0", optional = true } rocksdb = { version = "0.21.0", optional = true }
rust_decimal = { version = "1.31.0", features = ["maths", "serde-str"] } rust_decimal = { version = "1.31.0", features = ["maths", "serde-str"] }
rust-stemmers = "1.2.0" rust-stemmers = "1.2.0"
rustls = { version = "0.20.8", optional = true } rustls = { version = "0.21.6", optional = true }
scrypt = "0.11.0" scrypt = "0.11.0"
semver = { version = "1.0.18", features = ["serde"] } semver = { version = "1.0.18", features = ["serde"] }
serde = { version = "1.0.183", features = ["derive"] } serde = { version = "1.0.183", features = ["derive"] }
@ -138,7 +138,7 @@ ws_stream_wasm = "0.7.4"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.31.0", default-features = false, features = ["macros", "io-util", "io-std", "fs", "rt-multi-thread", "time", "sync"] } tokio = { version = "1.31.0", default-features = false, features = ["macros", "io-util", "io-std", "fs", "rt-multi-thread", "time", "sync"] }
tokio-tungstenite = { version = "0.18.0", optional = true } tokio-tungstenite = { version = "0.20.1", optional = true }
uuid = { version = "1.4.1", features = ["serde", "v4", "v7"] } uuid = { version = "1.4.1", features = ["serde", "v4", "v7"] }
[lib] [lib]

View file

@ -174,14 +174,12 @@ impl Connection for Any {
let maybe_connector = address.config.tls_config.map(Connector::from); let maybe_connector = address.config.tls_config.map(Connector::from);
#[cfg(not(any(feature = "native-tls", feature = "rustls")))] #[cfg(not(any(feature = "native-tls", feature = "rustls")))]
let maybe_connector = None; let maybe_connector = None;
let config = WebSocketConfig { let config = WebSocketConfig {
max_send_queue: match capacity {
0 => None,
capacity => Some(capacity),
},
max_message_size: Some(engine::remote::ws::native::MAX_MESSAGE_SIZE), max_message_size: Some(engine::remote::ws::native::MAX_MESSAGE_SIZE),
max_frame_size: Some(engine::remote::ws::native::MAX_FRAME_SIZE), max_frame_size: Some(engine::remote::ws::native::MAX_FRAME_SIZE),
accept_unmasked_frames: false, max_write_buffer_size: engine::remote::ws::native::MAX_MESSAGE_SIZE,
..Default::default()
}; };
let socket = engine::remote::ws::native::connect( let socket = engine::remote::ws::native::connect(
&url, &url,

View file

@ -55,6 +55,9 @@ type WsResult<T> = std::result::Result<T, WsError>;
pub(crate) const MAX_MESSAGE_SIZE: usize = 64 << 20; // 64 MiB pub(crate) const MAX_MESSAGE_SIZE: usize = 64 << 20; // 64 MiB
pub(crate) const MAX_FRAME_SIZE: usize = 16 << 20; // 16 MiB pub(crate) const MAX_FRAME_SIZE: usize = 16 << 20; // 16 MiB
pub(crate) const WRITE_BUFFER_SIZE: usize = 128000; // tungstenite default
pub(crate) const MAX_WRITE_BUFFER_SIZE: usize = WRITE_BUFFER_SIZE + MAX_MESSAGE_SIZE; // Recommended max according to tungstenite docs
pub(crate) const NAGLE_ALG: bool = false;
pub(crate) enum Either { pub(crate) enum Either {
Request(Option<Route>), Request(Option<Route>),
@ -81,10 +84,11 @@ pub(crate) async fn connect(
) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>> { ) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>> {
#[cfg(any(feature = "native-tls", feature = "rustls"))] #[cfg(any(feature = "native-tls", feature = "rustls"))]
let (socket, _) = let (socket, _) =
tokio_tungstenite::connect_async_tls_with_config(url, config, maybe_connector).await?; tokio_tungstenite::connect_async_tls_with_config(url, config, NAGLE_ALG, maybe_connector)
.await?;
#[cfg(not(any(feature = "native-tls", feature = "rustls")))] #[cfg(not(any(feature = "native-tls", feature = "rustls")))]
let (socket, _) = tokio_tungstenite::connect_async_with_config(url, config).await?; let (socket, _) = tokio_tungstenite::connect_async_with_config(url, config, NAGLE_ALG).await?;
Ok(socket) Ok(socket)
} }
@ -111,13 +115,10 @@ impl Connection for Client {
let maybe_connector = None; let maybe_connector = None;
let config = WebSocketConfig { let config = WebSocketConfig {
max_send_queue: match capacity {
0 => None,
capacity => Some(capacity),
},
max_message_size: Some(MAX_MESSAGE_SIZE), max_message_size: Some(MAX_MESSAGE_SIZE),
max_frame_size: Some(MAX_FRAME_SIZE), max_frame_size: Some(MAX_FRAME_SIZE),
accept_unmasked_frames: false, max_write_buffer_size: MAX_WRITE_BUFFER_SIZE,
..Default::default()
}; };
let socket = connect(&url, Some(config), maybe_connector.clone()).await?; let socket = connect(&url, Some(config), maybe_connector.clone()).await?;