summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds/split_tunnel
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-06-16 15:13:32 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-08-20 14:41:41 +0200
commit8cf02b29a718a7856c80323ee0cf496b9ee24648 (patch)
tree16f378f2cc3d3101d01d58435bf54824e57683a6 /mullvad-cli/src/cmds/split_tunnel
parentc2e9303cc7aff29df7941fc08df19b8ffcffa48f (diff)
downloadmullvadvpn-8cf02b29a718a7856c80323ee0cf496b9ee24648.tar.xz
mullvadvpn-8cf02b29a718a7856c80323ee0cf496b9ee24648.zip
Use gRPC for management interface in backend and CLI
Diffstat (limited to 'mullvad-cli/src/cmds/split_tunnel')
-rw-r--r--mullvad-cli/src/cmds/split_tunnel/linux.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/mullvad-cli/src/cmds/split_tunnel/linux.rs b/mullvad-cli/src/cmds/split_tunnel/linux.rs
index 95b172eb6b..5e8a9b9644 100644
--- a/mullvad-cli/src/cmds/split_tunnel/linux.rs
+++ b/mullvad-cli/src/cmds/split_tunnel/linux.rs
@@ -1,8 +1,9 @@
-use crate::{new_rpc_client, Command, Result};
+use crate::{new_grpc_client, Command, Result};
use clap::value_t_or_exit;
pub struct SplitTunnel;
+#[async_trait::async_trait]
impl Command for SplitTunnel {
fn name(&self) -> &'static str {
"split-tunnel"
@@ -15,9 +16,9 @@ impl Command for SplitTunnel {
.subcommand(create_pid_subcommand())
}
- fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
+ async fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
- ("pid", Some(pid_matches)) => Self::handle_pid_cmd(pid_matches),
+ ("pid", Some(pid_matches)) => Self::handle_pid_cmd(pid_matches).await,
_ => unreachable!("unhandled comand"),
}
}
@@ -38,27 +39,40 @@ fn create_pid_subcommand() -> clap::App<'static, 'static> {
}
impl SplitTunnel {
- fn handle_pid_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
+ async fn handle_pid_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("add", Some(matches)) => {
let pid = value_t_or_exit!(matches.value_of("pid"), i32);
- new_rpc_client()?.add_split_tunnel_process(pid)?;
+ new_grpc_client()
+ .await?
+ .add_split_tunnel_process(pid)
+ .await?;
Ok(())
}
("delete", Some(matches)) => {
let pid = value_t_or_exit!(matches.value_of("pid"), i32);
- new_rpc_client()?.remove_split_tunnel_process(pid)?;
+ new_grpc_client()
+ .await?
+ .remove_split_tunnel_process(pid)
+ .await?;
Ok(())
}
("clear", Some(_)) => {
- new_rpc_client()?.clear_split_tunnel_processes()?;
+ new_grpc_client()
+ .await?
+ .clear_split_tunnel_processes(())
+ .await?;
Ok(())
}
("list", Some(_)) => {
- let pids = new_rpc_client()?.get_split_tunnel_processes()?;
+ let mut pids_stream = new_grpc_client()
+ .await?
+ .get_split_tunnel_processes(())
+ .await?
+ .into_inner();
println!("Excluded PIDs:");
- for pid in pids.iter() {
+ while let Some(pid) = pids_stream.message().await? {
println!(" {}", pid);
}