blob: d67194b05855a29c19b0604a2835a21096627b4e (
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
|
use anyhow::Result;
use mullvad_management_interface::MullvadProxyClient;
use mullvad_types::{
constraints::Constraint,
relay_constraints::{RelayConstraints, RelaySettings},
};
#[derive(clap::Subcommand, Debug)]
pub enum DebugCommands {
/// Block all internet connection by setting an invalid relay constraint.
BlockConnection,
}
impl DebugCommands {
pub async fn handle(self) -> Result<()> {
match self {
DebugCommands::BlockConnection => {
let mut rpc = MullvadProxyClient::new().await?;
let settings = rpc.get_settings().await?;
let relay_settings = settings.get_relay_settings();
let mut constraints = match relay_settings {
RelaySettings::Normal(normal) => normal,
RelaySettings::CustomTunnelEndpoint(_custom) => {
println!("Removing custom relay settings");
RelayConstraints::default()
}
};
constraints.location = Constraint::Only(
mullvad_types::relay_constraints::LocationConstraint::Location(
mullvad_types::relay_constraints::GeographicLocationConstraint::Country(
"xx".into(),
),
),
);
rpc.set_relay_settings(RelaySettings::Normal(constraints))
.await?;
rpc.connect_tunnel().await?;
eprintln!("WARNING: ENTERED BLOCKED MODE");
Ok(())
}
}
}
}
|