Skip to content

Commit

Permalink
Upgrade tonic and prost
Browse files Browse the repository at this point in the history
Upgrade `tonic` to version 0.12, as a prerequisite
to later on upgrading `hyper`.

As of version 1, `hyper` no longer uses tokios `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 24, 2024
1 parent 7807b09 commit 5b4e6c5
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 119 deletions.
139 changes: 95 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 @@ -67,11 +67,12 @@ unused_async = "deny"
[workspace.dependencies]
tokio = { version = "1.8" }
# 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-management-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mullvad-paths = { path = "../mullvad-paths" }
talpid-types = { path = "../talpid-types" }
tonic = { workspace = true }
tower = { workspace = true }
hyper-util = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
parity-tokio-ipc = "0.9"
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 @@ talpid-types = { path = "../talpid-types" }
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
10 changes: 5 additions & 5 deletions talpid-openvpn-plugin/src/processing.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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?;

Expand Down
1 change: 1 addition & 0 deletions talpid-tunnel-config-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ talpid-types = { path = "../talpid-types" }
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",
Expand Down
7 changes: 4 additions & 3 deletions talpid-tunnel-config-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ async fn new_client(addr: Ipv4Addr) -> Result<RelayConfigService, Error> {

#[cfg(not(target_os = "windows"))]
try_set_tcp_sock_mtu(&addr, sock.as_raw_fd(), CONFIG_CLIENT_MTU);

sock.connect(SocketAddr::new(addr, CONFIG_SERVICE_PORT))
.await
let stream = sock
.connect(SocketAddr::new(addr, CONFIG_SERVICE_PORT))
.await?;
Ok::<_, std::io::Error>(hyper_util::rt::tokio::TokioIo::new(stream))
}))
.await
.map_err(Error::GrpcConnectError)?;
Expand Down
Loading

0 comments on commit 5b4e6c5

Please sign in to comment.