Skip to content

Commit

Permalink
Upgrade tonic to 0.12 and prost to 0.13
Browse files Browse the repository at this point in the history
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 <hyperium/hyper#3110>. 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.
  • Loading branch information
Serock3 committed Sep 25, 2024
1 parent 1c69b72 commit cb234d5
Show file tree
Hide file tree
Showing 14 changed files with 327 additions and 128 deletions.
141 changes: 97 additions & 44 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions mullvad-ios/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 8 additions & 12 deletions mullvad-ios/src/ephemeral_peer_proxy/ios_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<Box<dyn Future<Output = _> + 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)?;

Expand Down
1 change: 1 addition & 0 deletions mullvad-management-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 3 additions & 1 deletion mullvad-management-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ pub enum Error {
#[cfg(not(target_os = "android"))]
#[deprecated(note = "Prefer MullvadProxyClient")]
pub async fn new_rpc_client() -> Result<ManagementServiceClient, Error> {
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)?;
Expand Down
2 changes: 2 additions & 0 deletions talpid-openvpn-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
Loading

0 comments on commit cb234d5

Please sign in to comment.