From 8826ae271c6183a9d61d5e784ab2181277815bc1 Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Tue, 16 Apr 2024 16:10:13 -0600 Subject: [PATCH] build: upgrade tungstenite-rs --- Cargo.lock | 116 ++++++++--------------- crates/trycp_server/Cargo.toml | 17 +++- crates/trycp_server/src/admin_call.rs | 15 +-- crates/trycp_server/src/app_interface.rs | 17 ++-- package.json | 2 +- 5 files changed, 70 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2214803c..8a09bebb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,15 +182,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -592,6 +583,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + [[package]] name = "derivative" version = "2.2.0" @@ -616,22 +613,13 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", ] @@ -895,7 +883,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap 2.2.6", "slab", "tokio", @@ -1178,6 +1166,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1185,7 +1184,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -1212,7 +1211,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -1232,7 +1231,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.12", "hyper", "rustls", "tokio", @@ -1304,15 +1303,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "input_buffer" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" -dependencies = [ - "bytes", -] - [[package]] name = "integrity" version = "0.1.0" @@ -1588,12 +1578,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "openssl-probe" version = "0.1.5" @@ -1646,26 +1630,6 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2 1.0.80", - "quote 1.0.36", - "syn 2.0.59", -] - [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1903,7 +1867,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-rustls", @@ -2240,26 +2204,24 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.9.8" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ - "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "digest", ] [[package]] -name = "sha-1" -version = "0.10.1" +name = "sha1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -2552,7 +2514,7 @@ dependencies = [ "hex", "num-traits", "serde", - "sha-1 0.10.1", + "sha-1", "test-fuzz-internal", ] @@ -2641,13 +2603,12 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.14.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", - "pin-project", "tokio", "tungstenite", ] @@ -2751,19 +2712,18 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.13.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ - "base64 0.13.1", "byteorder", "bytes", - "http", + "data-encoding", + "http 1.1.0", "httparse", - "input_buffer", "log", "rand", - "sha-1 0.9.8", + "sha1", "thiserror", "url", "utf-8", diff --git a/crates/trycp_server/Cargo.toml b/crates/trycp_server/Cargo.toml index d98bb570..5ce11925 100644 --- a/crates/trycp_server/Cargo.toml +++ b/crates/trycp_server/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["holochain", "holo", "p2p", "network", "simulation"] homepage = "https://github.com/holochain/tryorama" documentation = "https://github.com/holochain/tryorma/crates/trycp_server" repository = "https://github.com/holochain/tryorma" -authors = [ "Holochain Core Dev Team " ] +authors = ["Holochain Core Dev Team "] edition = "2021" [dependencies] @@ -15,13 +15,22 @@ futures = "0.3" nix = { version = "0.28", features = ["signal"] } once_cell = "1.5.0" parking_lot = "0.12" -reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "rustls-tls-native-roots"] } +reqwest = { version = "0.11", default-features = false, features = [ + "blocking", + "json", + "rustls-tls-native-roots", +] } rmp-serde = "=0.15.5" serde = { version = "1.0.181", features = ["derive"] } serde_bytes = "0.11" slab = "0.4" snafu = "0.6" structopt = "0.2" -tokio = { version = "1.24", features = ["macros", "rt-multi-thread", "process", "fs"]} -tokio-tungstenite = "0.14" +tokio = { version = "1.24", features = [ + "macros", + "rt-multi-thread", + "process", + "fs", +] } +tokio-tungstenite = "0.21" url = "2" diff --git a/crates/trycp_server/src/admin_call.rs b/crates/trycp_server/src/admin_call.rs index 45ff0d14..e950eff1 100644 --- a/crates/trycp_server/src/admin_call.rs +++ b/crates/trycp_server/src/admin_call.rs @@ -4,7 +4,7 @@ use snafu::{OptionExt, ResultExt, Snafu}; use tokio::time::error::Elapsed; use tokio_tungstenite::tungstenite::{ self, - handshake::client::Request, + client::IntoClientRequest, protocol::{frame::coding::CloseCode, CloseFrame, WebSocketConfig}, Message, }; @@ -35,12 +35,13 @@ pub(crate) async fn admin_call(id: String, message: Vec) -> Result, .await .context(TcpConnect)?; let uri = format!("ws://{}", addr); - let request = Request::builder() - .uri(uri.clone()) - // needed for admin websocket connection to be accepted - .header("origin", "trycp-admin") - .body(()) - .expect("request to be valid"); + let mut request = uri.clone().into_client_request().expect("not a valid URI"); + // needed for admin websocket connection to be accepted + request.headers_mut().insert( + "origin", + "trycp-admin".parse().expect("invalid origin header value"), + ); + request.body(); println!("Establishing admin interface with {:?}", uri); diff --git a/crates/trycp_server/src/app_interface.rs b/crates/trycp_server/src/app_interface.rs index c3e3e428..213814ef 100644 --- a/crates/trycp_server/src/app_interface.rs +++ b/crates/trycp_server/src/app_interface.rs @@ -4,7 +4,7 @@ use futures::{future, SinkExt, StreamExt, TryStreamExt}; use once_cell::sync::Lazy; use slab::Slab; use snafu::{IntoError, OptionExt, ResultExt, Snafu}; -use tokio_tungstenite::tungstenite::handshake::client::Request; +use tokio_tungstenite::tungstenite::client::IntoClientRequest; use tokio_tungstenite::tungstenite::protocol::WebSocketConfig; use tokio_tungstenite::tungstenite::{self, protocol::CloseFrame}; use tokio_tungstenite::tungstenite::{protocol::frame::coding::CloseCode, Message}; @@ -53,12 +53,15 @@ pub(crate) async fn connect( .await .context(TcpConnect)?; let uri = format!("ws://{}", addr); - let request = Request::builder() - .uri(uri.clone()) - // needed for admin websocket connection to be accepted - .header("origin", "tryorama-interface") - .body(()) - .expect("request to be valid"); + let mut request = uri.clone().into_client_request().expect("not a valid URI"); + // needed for app websocket connection to be accepted + request.headers_mut().insert( + "origin", + "tryorama-interface" + .parse() + .expect("invalid origin header value"), + ); + request.body(); println!("Establishing app interface with {:?}", uri); diff --git a/package.json b/package.json index 7dc16e87..a896dbfa 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "@holochain/client": "^0.17.0-dev.9", + "@holochain/client": "^0.17.0-dev.8", "get-port": "^6.1.2", "lodash": "^4.17.21", "uuid": "^8.3.2",