blob: 5a66d899ab8c290e841a21f9ff70c2817b1e7caf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
use anyhow::Result;
use clap::Subcommand;
use mullvad_management_interface::MullvadProxyClient;
/// Manage split tunneling. To launch applications outside the tunnel, use the program
/// 'mullvad-exclude' instead of this command
#[derive(Subcommand, Debug)]
pub enum SplitTunnel {
/// List all processes that are excluded from the tunnel
List,
/// Add a PID to exclude from the tunnel
Add { pid: i32 },
/// Stop excluding a PID from the tunnel
Delete { pid: i32 },
/// Stop excluding all processes from the tunnel
Clear,
}
impl SplitTunnel {
pub async fn handle(self) -> Result<()> {
match self {
SplitTunnel::List => {
let pids = MullvadProxyClient::new()
.await?
.get_split_tunnel_processes()
.await?;
println!("Excluded PIDs:");
for pid in &pids {
println!("{pid}");
}
Ok(())
}
SplitTunnel::Add { pid } => {
MullvadProxyClient::new()
.await?
.add_split_tunnel_process(pid)
.await?;
println!("Excluding process");
Ok(())
}
SplitTunnel::Delete { pid } => {
MullvadProxyClient::new()
.await?
.remove_split_tunnel_process(pid)
.await?;
println!("Stopped excluding process");
Ok(())
}
SplitTunnel::Clear => {
MullvadProxyClient::new()
.await?
.clear_split_tunnel_processes()
.await?;
println!("Stopped excluding all processes");
Ok(())
}
}
}
}
|