summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds/debug.rs
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2023-11-17 15:15:41 +0100
committerSebastian Holmin <sebastian.holmin@mullvad.net>2023-11-23 15:14:21 +0100
commitfc1fa55b697cfd00a20345d9ded123483cf366d6 (patch)
tree5811053f7c0ced350a29bc36eb50588baf866d2f /mullvad-cli/src/cmds/debug.rs
parenta897d8c5981fe0bf02ec0c085b381ce5c2fadc57 (diff)
downloadmullvadvpn-fc1fa55b697cfd00a20345d9ded123483cf366d6.tar.xz
mullvadvpn-fc1fa55b697cfd00a20345d9ded123483cf366d6.zip
Add `mullvad debug block-connection` command
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(())
+ }
+ }
+ }
+}