From 0bee6e8104f4a5d2726919031444eeebabb8f5c5 Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Tue, 24 Sep 2024 08:54:31 +0200 Subject: [PATCH 1/3] Add `parity-tokio-ipc` to workspace dependencies Also regroup networking-related crates --- Cargo.toml | 1 + mullvad-management-interface/Cargo.toml | 5 +++-- talpid-openvpn-plugin/Cargo.toml | 4 ++-- talpid-openvpn/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0b674d289be5..565d52466d89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ unused_async = "deny" [workspace.dependencies] tokio = { version = "1.8" } +parity-tokio-ipc = "0.9" # Tonic and related crates tonic = "0.10.0" tonic-build = { version = "0.10.0", default-features = false } diff --git a/mullvad-management-interface/Cargo.toml b/mullvad-management-interface/Cargo.toml index 75c6f1b0adc0..004d5a4d56ce 100644 --- a/mullvad-management-interface/Cargo.toml +++ b/mullvad-management-interface/Cargo.toml @@ -11,19 +11,20 @@ rust-version.workspace = true workspace = true [dependencies] +log = { workspace = true } chrono = { workspace = true } thiserror = { workspace = true } mullvad-types = { path = "../mullvad-types" } mullvad-paths = { path = "../mullvad-paths" } talpid-types = { path = "../talpid-types" } + tonic = { workspace = true } tower = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } -parity-tokio-ipc = "0.9" futures = "0.3" tokio = { workspace = true, features = ["rt"] } -log = { workspace = true } +parity-tokio-ipc = { workspace = true } [target.'cfg(unix)'.dependencies] nix = "0.23" diff --git a/talpid-openvpn-plugin/Cargo.toml b/talpid-openvpn-plugin/Cargo.toml index 6c397ed6c441..6706674c6990 100644 --- a/talpid-openvpn-plugin/Cargo.toml +++ b/talpid-openvpn-plugin/Cargo.toml @@ -17,12 +17,12 @@ crate-type = ["cdylib"] thiserror = { workspace = true } log = { workspace = true } env_logger = { workspace = true } -parity-tokio-ipc = "0.9" -tokio = { workspace = true, features = ["rt"] } openvpn-plugin = { version = "0.4.2", features = ["serde", "log", "auth-failed-event"] } talpid-types = { path = "../talpid-types" } +tokio = { workspace = true, features = ["rt"] } +parity-tokio-ipc = { workspace = true } tonic = { workspace = true } tower = { workspace = true } prost = { workspace = true } diff --git a/talpid-openvpn/Cargo.toml b/talpid-openvpn/Cargo.toml index 4450d56a039d..3d62366bab9b 100644 --- a/talpid-openvpn/Cargo.toml +++ b/talpid-openvpn/Cargo.toml @@ -24,7 +24,7 @@ tokio = { workspace = true, features = ["process", "rt-multi-thread", "fs"] } shadowsocks-service = { workspace = true, features = [ "local", "stream-cipher" ] } [target.'cfg(not(target_os="android"))'.dependencies] -parity-tokio-ipc = "0.9" +parity-tokio-ipc = { workspace = true } triggered = "0.1.1" tonic = { workspace = true } prost = { workspace = true } From 1c69b721b61b08ab93cd9d7186a3a2983b2aedf2 Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Tue, 24 Sep 2024 09:00:14 +0200 Subject: [PATCH 2/3] Add `futures` to workspace dependencies --- Cargo.toml | 1 + mullvad-api/Cargo.toml | 2 +- mullvad-cli/Cargo.toml | 2 +- mullvad-daemon/Cargo.toml | 2 +- mullvad-jni/Cargo.toml | 2 +- mullvad-management-interface/Cargo.toml | 2 +- talpid-core/Cargo.toml | 2 +- talpid-openvpn/Cargo.toml | 2 +- talpid-routing/Cargo.toml | 2 +- talpid-tunnel/Cargo.toml | 2 +- talpid-windows/Cargo.toml | 2 +- talpid-wireguard/Cargo.toml | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 565d52466d89..2be4cf2b8a75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,7 @@ unused_async = "deny" [workspace.dependencies] tokio = { version = "1.8" } parity-tokio-ipc = "0.9" +futures = "0.3.15" # Tonic and related crates tonic = "0.10.0" tonic-build = { version = "0.10.0", default-features = false } diff --git a/mullvad-api/Cargo.toml b/mullvad-api/Cargo.toml index dacb6a79789a..c181694a4bae 100644 --- a/mullvad-api/Cargo.toml +++ b/mullvad-api/Cargo.toml @@ -18,7 +18,7 @@ api-override = [] libc = "0.2" chrono = { workspace = true } thiserror = { workspace = true } -futures = "0.3" +futures = { workspace = true } http = "0.2" hyper = { version = "0.14", features = ["client", "stream", "http1", "tcp" ] } ipnetwork = { workspace = true } diff --git a/mullvad-cli/Cargo.toml b/mullvad-cli/Cargo.toml index 5be2adfd5757..9c43a875cc94 100644 --- a/mullvad-cli/Cargo.toml +++ b/mullvad-cli/Cargo.toml @@ -19,7 +19,7 @@ anyhow = "1.0" chrono = { workspace = true } clap = { workspace = true } thiserror = { workspace = true } -futures = "0.3" +futures = { workspace = true } itertools = "0.10" natord = "1.0.9" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 7a231ff69eb8..9342062d36ee 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -19,7 +19,7 @@ chrono = { workspace = true } thiserror = { workspace = true } either = "1.11" fern = { version = "0.6", features = ["colored"] } -futures = "0.3" +futures = { workspace = true } libc = "0.2" log = { workspace = true } regex = "1.0" diff --git a/mullvad-jni/Cargo.toml b/mullvad-jni/Cargo.toml index 09cca4588685..6af0c9c12b4d 100644 --- a/mullvad-jni/Cargo.toml +++ b/mullvad-jni/Cargo.toml @@ -21,7 +21,7 @@ crate-type = ["cdylib"] tokio = { workspace = true, features = ["rt"] } thiserror = { workspace = true } -futures = "0.3" +futures = { workspace = true } ipnetwork = { workspace = true } jnix = { version = "0.5.1", features = ["derive"] } log = { workspace = true } diff --git a/mullvad-management-interface/Cargo.toml b/mullvad-management-interface/Cargo.toml index 004d5a4d56ce..5577ae941d7d 100644 --- a/mullvad-management-interface/Cargo.toml +++ b/mullvad-management-interface/Cargo.toml @@ -22,7 +22,7 @@ tonic = { workspace = true } tower = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } -futures = "0.3" +futures = { workspace = true } tokio = { workspace = true, features = ["rt"] } parity-tokio-ipc = { workspace = true } diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index d4d02f14f765..5fab3022aba3 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] chrono = { workspace = true, features = ["clock"] } thiserror = { workspace = true } -futures = "0.3.15" +futures = { workspace = true } ipnetwork = { workspace = true } libc = "0.2" log = { workspace = true } diff --git a/talpid-openvpn/Cargo.toml b/talpid-openvpn/Cargo.toml index 3d62366bab9b..34df09becf41 100644 --- a/talpid-openvpn/Cargo.toml +++ b/talpid-openvpn/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] async-trait = "0.1" thiserror = { workspace = true } -futures = "0.3.15" +futures = { workspace = true } log = { workspace = true } shell-escape = "0.1" talpid-routing = { path = "../talpid-routing" } diff --git a/talpid-routing/Cargo.toml b/talpid-routing/Cargo.toml index 2c8b99a00b09..14f30b83338a 100644 --- a/talpid-routing/Cargo.toml +++ b/talpid-routing/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] thiserror = { workspace = true } -futures = "0.3.15" +futures = { workspace = true } ipnetwork = { workspace = true } log = { workspace = true } tokio = { workspace = true, features = ["process", "rt-multi-thread", "net", "io-util", "time"] } diff --git a/talpid-tunnel/Cargo.toml b/talpid-tunnel/Cargo.toml index 21312912f4eb..8fcd27037060 100644 --- a/talpid-tunnel/Cargo.toml +++ b/talpid-tunnel/Cargo.toml @@ -16,7 +16,7 @@ cfg-if = "1.0" ipnetwork = { workspace = true } talpid-routing = { path = "../talpid-routing" } talpid-types = { path = "../talpid-types" } -futures = "0.3.15" +futures = { workspace = true } tokio = { workspace = true, features = ["process", "rt-multi-thread", "fs"] } [target.'cfg(all(unix, not(target_os = "android")))'.dependencies] diff --git a/talpid-windows/Cargo.toml b/talpid-windows/Cargo.toml index c786ac7a6673..a44229b61d07 100644 --- a/talpid-windows/Cargo.toml +++ b/talpid-windows/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [target.'cfg(windows)'.dependencies] thiserror = { workspace = true } socket2 = { version = "0.5.3" } -futures = "0.3.15" +futures = { workspace = true } talpid-types = { path = "../talpid-types" } diff --git a/talpid-wireguard/Cargo.toml b/talpid-wireguard/Cargo.toml index f9ed01856236..b4b5e1148121 100644 --- a/talpid-wireguard/Cargo.toml +++ b/talpid-wireguard/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] thiserror = { workspace = true } -futures = "0.3.15" +futures = { workspace = true } hex = "0.4" ipnetwork = { workspace = true } once_cell = { workspace = true } From cb234d5e1b6e061ed6f3f209cae00e0dba9e9624 Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Mon, 23 Sep 2024 17:16:24 +0200 Subject: [PATCH 3/3] Upgrade `tonic` to 0.12 and `prost` to 0.13 Upgrading `tonic` is a prerequisite to later on upgrading `hyper` to version 1.0. As of version 1.0, `hyper` no longer uses `tokio`s `AsyncWriter` and `AsyncReader` traits, instead defining its own versions, see . As tonic `0.12` is updated to use the `hyper 1.0` ecosystem, it changed some of its trait-bounds to the new `hyper` traits. The `hyper-utils` crate provides the wrapper `TokioIo`, which converts between the two. `prost` had to be upgraded as well, for compatibility. --- Cargo.lock | 141 ++++++---- Cargo.toml | 7 +- mullvad-ios/Cargo.toml | 1 + .../src/ephemeral_peer_proxy/ios_runtime.rs | 20 +- mullvad-management-interface/Cargo.toml | 1 + mullvad-management-interface/src/lib.rs | 4 +- talpid-openvpn-plugin/Cargo.toml | 2 + talpid-openvpn-plugin/src/processing.rs | 10 +- talpid-tunnel-config-client/Cargo.toml | 2 + talpid-tunnel-config-client/src/lib.rs | 3 + test/Cargo.lock | 244 ++++++++++++++---- test/Cargo.toml | 6 +- test/test-manager/Cargo.toml | 1 + test/test-manager/src/mullvad_daemon.rs | 13 +- 14 files changed, 327 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed52bbb2f8e3..5245ae7961c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,18 +225,17 @@ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "itoa", "matchit", "memchr", @@ -253,17 +252,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -1544,7 +1546,6 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -1581,14 +1582,35 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 0.14.28", + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.4.1", "pin-project-lite", + "socket2", "tokio", - "tokio-io-timeout", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2422,6 +2444,7 @@ name = "mullvad-ios" version = "0.0.0" dependencies = [ "cbindgen", + "hyper-util", "libc", "log", "mullvad-encrypted-dns-proxy", @@ -2462,13 +2485,14 @@ version = "0.0.0" dependencies = [ "chrono", "futures", + "hyper-util", "log", "mullvad-paths", "mullvad-types", "nix 0.23.2", "parity-tokio-ipc", - "prost", - "prost-types", + "prost 0.13.3", + "prost-types 0.13.3", "talpid-types", "thiserror", "tokio", @@ -3229,7 +3253,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.4", +] + +[[package]] +name = "prost" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive 0.13.3", ] [[package]] @@ -3246,8 +3280,8 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.12.4", + "prost-types 0.12.4", "regex", "syn 2.0.60", "tempfile", @@ -3266,13 +3300,35 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "prost-types" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ - "prost", + "prost 0.12.4", +] + +[[package]] +name = "prost-types" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +dependencies = [ + "prost 0.13.3", ] [[package]] @@ -3982,9 +4038,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "synstructure" @@ -4112,7 +4168,7 @@ dependencies = [ "log", "once_cell", "parity-tokio-ipc", - "prost", + "prost 0.13.3", "shadowsocks-service", "shell-escape", "talpid-routing", @@ -4135,11 +4191,13 @@ name = "talpid-openvpn-plugin" version = "0.0.0" dependencies = [ "env_logger 0.10.2", + "futures", + "hyper-util", "log", "mullvad-version", "openvpn-plugin", "parity-tokio-ipc", - "prost", + "prost 0.13.3", "talpid-types", "thiserror", "tokio", @@ -4215,11 +4273,13 @@ name = "talpid-tunnel-config-client" version = "0.0.0" dependencies = [ "classic-mceliece-rust", + "futures", + "hyper-util", "libc", "log", "oslog", "pqc_kyber", - "prost", + "prost 0.13.3", "rand 0.8.5", "talpid-types", "tokio", @@ -4402,16 +4462,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.4.0" @@ -4512,23 +4562,26 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64 0.22.0", "bytes", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.3", + "socket2", "tokio", "tokio-stream", "tower", diff --git a/Cargo.toml b/Cargo.toml index 2be4cf2b8a75..a8a0eb4f3c39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,11 +69,12 @@ tokio = { version = "1.8" } parity-tokio-ipc = "0.9" futures = "0.3.15" # Tonic and related crates -tonic = "0.10.0" +tonic = "0.12.2" tonic-build = { version = "0.10.0", default-features = false } tower = "0.4" -prost = "0.12.0" -prost-types = "0.12.0" +prost = "0.13.3" +prost-types = "0.13.3" +hyper-util = "0.1.8" env_logger = "0.10.0" thiserror = "1.0.57" diff --git a/mullvad-ios/Cargo.toml b/mullvad-ios/Cargo.toml index 83d3af744750..294d707e79e6 100644 --- a/mullvad-ios/Cargo.toml +++ b/mullvad-ios/Cargo.toml @@ -15,6 +15,7 @@ libc = "0.2" log = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } +hyper-util = { workspace = true } tower = { workspace = true } tunnel-obfuscation = { path = "../tunnel-obfuscation" } oslog = "0.2" diff --git a/mullvad-ios/src/ephemeral_peer_proxy/ios_runtime.rs b/mullvad-ios/src/ephemeral_peer_proxy/ios_runtime.rs index 7dbf5c21e1c4..19107689ab29 100644 --- a/mullvad-ios/src/ephemeral_peer_proxy/ios_runtime.rs +++ b/mullvad-ios/src/ephemeral_peer_proxy/ios_runtime.rs @@ -3,10 +3,7 @@ use super::{ }; use libc::c_void; use std::{ - future::Future, - io, - pin::Pin, - ptr, + io, ptr, sync::{Arc, Mutex}, }; use talpid_tunnel_config_client::{request_ephemeral_peer_with, Error, RelayConfigService}; @@ -104,14 +101,13 @@ impl IOSRuntime { // One (1) TCP connection let mut one_tcp_connection = Some(tcp_provider); let conn = endpoint - .connect_with_connector(service_fn( - move |_| -> Pin + Send>> { - if let Some(connection) = one_tcp_connection.take() { - return Box::pin(async move { Ok::<_, Error>(connection) }); - } - Box::pin(async { Err(Error::TcpConnectionExpired) }) - }, - )) + .connect_with_connector(service_fn(move |_| { + let connection = one_tcp_connection + .take() + .map(hyper_util::rt::tokio::TokioIo::new) + .ok_or(Error::TcpConnectionExpired); + async { connection } + })) .await .map_err(Error::GrpcConnectError)?; diff --git a/mullvad-management-interface/Cargo.toml b/mullvad-management-interface/Cargo.toml index 5577ae941d7d..54a3f496ceb0 100644 --- a/mullvad-management-interface/Cargo.toml +++ b/mullvad-management-interface/Cargo.toml @@ -20,6 +20,7 @@ talpid-types = { path = "../talpid-types" } tonic = { workspace = true } tower = { workspace = true } +hyper-util = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } futures = { workspace = true } diff --git a/mullvad-management-interface/src/lib.rs b/mullvad-management-interface/src/lib.rs index 7abe9f761c08..b26f29fe71bd 100644 --- a/mullvad-management-interface/src/lib.rs +++ b/mullvad-management-interface/src/lib.rs @@ -117,12 +117,14 @@ pub enum Error { #[cfg(not(target_os = "android"))] #[deprecated(note = "Prefer MullvadProxyClient")] pub async fn new_rpc_client() -> Result { + use futures::TryFutureExt; + let ipc_path = mullvad_paths::get_rpc_socket_path(); // The URI will be ignored let channel = Endpoint::from_static("lttp://[::]:50051") .connect_with_connector(service_fn(move |_: Uri| { - IpcEndpoint::connect(ipc_path.clone()) + IpcEndpoint::connect(ipc_path.clone()).map_ok(hyper_util::rt::tokio::TokioIo::new) })) .await .map_err(Error::GrpcTransportError)?; diff --git a/talpid-openvpn-plugin/Cargo.toml b/talpid-openvpn-plugin/Cargo.toml index 6706674c6990..1c3f80b62acc 100644 --- a/talpid-openvpn-plugin/Cargo.toml +++ b/talpid-openvpn-plugin/Cargo.toml @@ -26,6 +26,8 @@ parity-tokio-ipc = { workspace = true } tonic = { workspace = true } tower = { workspace = true } prost = { workspace = true } +hyper-util = { workspace = true } +futures = { workspace = true } [build-dependencies] tonic-build = { workspace = true, default-features = false, features = ["transport", "prost"] } diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs index 8ef6c337e947..cb2a42213845 100644 --- a/talpid-openvpn-plugin/src/processing.rs +++ b/talpid-openvpn-plugin/src/processing.rs @@ -1,11 +1,11 @@ use super::{Arguments, Error}; -use parity_tokio_ipc::Endpoint as IpcEndpoint; use std::collections::HashMap; -use tower::service_fn; - -use tonic::transport::{Endpoint, Uri}; +use futures::TryFutureExt; +use parity_tokio_ipc::Endpoint as IpcEndpoint; use tokio::runtime::{self, Runtime}; +use tonic::transport::{Endpoint, Uri}; +use tower::service_fn; #[allow(clippy::derive_partial_eq_without_eq)] mod proto { @@ -42,7 +42,7 @@ impl EventProcessor { // The URI will be ignored let channel = Endpoint::from_static("lttp://[::]:50051") .connect_with_connector(service_fn(move |_: Uri| { - IpcEndpoint::connect(ipc_path.clone()) + IpcEndpoint::connect(ipc_path.clone()).map_ok(hyper_util::rt::tokio::TokioIo::new) })) .await?; diff --git a/talpid-tunnel-config-client/Cargo.toml b/talpid-tunnel-config-client/Cargo.toml index cec3e36d4658..54966873ce7d 100644 --- a/talpid-tunnel-config-client/Cargo.toml +++ b/talpid-tunnel-config-client/Cargo.toml @@ -14,9 +14,11 @@ workspace = true log = { workspace = true } rand = "0.8" talpid-types = { path = "../talpid-types" } +futures = { workspace = true } tonic = { workspace = true } tower = { workspace = true } prost = { workspace = true } +hyper-util = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } classic-mceliece-rust = { version = "2.0.0", features = [ "mceliece460896f", diff --git a/talpid-tunnel-config-client/src/lib.rs b/talpid-tunnel-config-client/src/lib.rs index d40245ffdb26..9820a71a7317 100644 --- a/talpid-tunnel-config-client/src/lib.rs +++ b/talpid-tunnel-config-client/src/lib.rs @@ -217,6 +217,8 @@ fn xor_assign(dst: &mut [u8; 32], src: &[u8; 32]) { #[cfg(not(target_os = "ios"))] async fn new_client(addr: Ipv4Addr) -> Result { + use futures::TryFutureExt; + let endpoint = Endpoint::from_static("tcp://0.0.0.0:0"); let addr = IpAddr::V4(addr); @@ -224,6 +226,7 @@ async fn new_client(addr: Ipv4Addr) -> Result { .connect_with_connector(service_fn(move |_| async move { let sock = socket::TcpSocket::new()?; sock.connect(SocketAddr::new(addr, CONFIG_SERVICE_PORT)) + .map_ok(hyper_util::rt::tokio::TokioIo::new) .await })) .await diff --git a/test/Cargo.lock b/test/Cargo.lock index 1350b740b5bc..e12e3add158f 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -194,6 +194,12 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.2.0" @@ -202,18 +208,17 @@ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "itoa", "matchit", "memchr", @@ -222,7 +227,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 1.0.1", "tower", "tower-layer", "tower-service", @@ -230,17 +235,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", ] @@ -1146,7 +1154,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.2.6", "slab", "tokio", @@ -1275,6 +1302,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" @@ -1282,7 +1320,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -1314,9 +1375,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1328,6 +1389,27 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1335,8 +1417,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "log", "rustls", "rustls-native-certs", @@ -1347,14 +1429,35 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper", + "hyper 1.4.1", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", + "pin-project-lite", + "socket2 0.5.6", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1831,8 +1934,8 @@ dependencies = [ "cbindgen", "chrono", "futures", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "ipnetwork", "libc", "log", @@ -1867,13 +1970,14 @@ version = "0.0.0" dependencies = [ "chrono", "futures", + "hyper-util", "log", "mullvad-paths", "mullvad-types", "nix 0.23.2", "parity-tokio-ipc", - "prost", - "prost-types", + "prost 0.13.3", + "prost-types 0.13.3", "talpid-types", "thiserror", "tokio", @@ -2411,7 +2515,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.4", +] + +[[package]] +name = "prost" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive 0.13.3", ] [[package]] @@ -2428,8 +2542,8 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.12.4", + "prost-types 0.12.4", "regex", "syn 2.0.60", "tempfile", @@ -2448,13 +2562,35 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "prost-types" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ - "prost", + "prost 0.12.4", +] + +[[package]] +name = "prost-types" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +dependencies = [ + "prost 0.13.3", ] [[package]] @@ -2621,10 +2757,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", "ipnet", "js-sys", @@ -2638,7 +2774,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-rustls", @@ -3173,6 +3309,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -3297,6 +3439,7 @@ dependencies = [ "dirs", "env_logger", "futures", + "hyper-util", "inventory", "ipnetwork", "itertools 0.10.5", @@ -3341,7 +3484,7 @@ dependencies = [ "bytes", "colored", "futures", - "hyper", + "hyper 0.14.28", "hyper-rustls", "log", "rustls-pemfile 0.2.1", @@ -3494,16 +3637,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.2.0" @@ -3619,23 +3752,26 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64 0.22.0", "bytes", - "h2", - "http", - "http-body", - "hyper", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.3", + "socket2 0.5.6", "tokio", "tokio-stream", "tower", diff --git a/test/Cargo.toml b/test/Cargo.toml index ed56ad455ba1..d436ee9b1ea0 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -54,11 +54,11 @@ serde_json = "1.0" tokio-serde = { version = "0.8.0", features = ["json"] } # Tonic and related crates -tonic = "0.10.0" +tonic = "0.12.2" tonic-build = { version = "0.10.0", default-features = false } tower = "0.4" -prost = "0.12.0" -prost-types = "0.12.0" +prost = "0.13.3" +prost-types = "0.13.3" tarpc = { version = "0.30", features = ["tokio1", "serde-transport", "serde1"] } # Logging diff --git a/test/test-manager/Cargo.toml b/test/test-manager/Cargo.toml index 7285a9e837e5..3331cb19bb90 100644 --- a/test/test-manager/Cargo.toml +++ b/test/test-manager/Cargo.toml @@ -49,6 +49,7 @@ socks-server = { path = "../socks-server" } env_logger = { workspace = true } tonic = { workspace = true } +hyper-util = "0.1.8" tower = { workspace = true } colored = { workspace = true } diff --git a/test/test-manager/src/mullvad_daemon.rs b/test/test-manager/src/mullvad_daemon.rs index 251ed3d1fe99..b03981347001 100644 --- a/test/test-manager/src/mullvad_daemon.rs +++ b/test/test-manager/src/mullvad_daemon.rs @@ -2,6 +2,7 @@ use std::{io, time::Duration}; use futures::{channel::mpsc, future::BoxFuture, pin_mut, FutureExt, SinkExt, StreamExt}; +use hyper_util::rt::TokioIo; use mullvad_management_interface::{ManagementServiceClient, MullvadProxyClient}; use test_rpc::{ mullvad_daemon::MullvadClientVersion, @@ -16,13 +17,13 @@ const CONVERTER_BUF_SIZE: usize = 16 * 1024; #[derive(Clone)] struct DummyService { - management_channel_provider_tx: mpsc::UnboundedSender, + management_channel_provider_tx: mpsc::UnboundedSender>, } impl Service for DummyService { - type Response = DuplexStream; + type Response = TokioIo; type Error = std::io::Error; - type Future = BoxFuture<'static, Result>; + type Future = BoxFuture<'static, Result, Self::Error>>; fn poll_ready( &mut self, @@ -39,9 +40,9 @@ impl Service for DummyService { Box::pin(async move { notifier_tx - .unbounded_send(channel_in) + .unbounded_send(TokioIo::new(channel_in)) .map_err(|_| io::Error::new(io::ErrorKind::Other, "stream receiver is down"))?; - Ok(channel_out) + Ok(TokioIo::new(channel_out)) }) } } @@ -94,7 +95,7 @@ pub fn new_rpc_client( let mut management_channel_in: DuplexStream = match management_channel_provider_rx.next().await { - Some(channel) => channel, + Some(channel) => TokioIo::into_inner(channel), None => { log::trace!("exiting management interface forward loop"); break;