-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
mullvad debug block-connection
command
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters