summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds/debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-cli/src/cmds/debug.rs')
-rw-r--r--mullvad-cli/src/cmds/debug.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/mullvad-cli/src/cmds/debug.rs b/mullvad-cli/src/cmds/debug.rs
new file mode 100644
index 0000000000..47db11ee05
--- /dev/null
+++ b/mullvad-cli/src/cmds/debug.rs
@@ -0,0 +1,40 @@
+use anyhow::Result;
+use mullvad_management_interface::MullvadProxyClient;
+use mullvad_types::relay_constraints::{Constraint, 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?;
+ eprintln!("WARNING: ENTERED BLOCKED MODE");
+ Ok(())
+ }
+ }
+ }
+}