-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'override-relay-ip' into main
- Loading branch information
Showing
16 changed files
with
663 additions
and
166 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
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
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 |
---|---|---|
@@ -1,32 +1,14 @@ | ||
use super::receive_confirmation; | ||
use anyhow::Result; | ||
use mullvad_management_interface::MullvadProxyClient; | ||
use std::io::stdin; | ||
|
||
pub async fn handle() -> Result<()> { | ||
if receive_confirmation().await { | ||
let mut rpc = MullvadProxyClient::new().await?; | ||
rpc.factory_reset().await?; | ||
#[cfg(target_os = "linux")] | ||
println!("If you're running systemd, to remove all logs, you must use journalctl"); | ||
if !receive_confirmation("Are you sure you want to disconnect, log out, delete all settings, logs and cache files for the Mullvad VPN system service?", false).await { | ||
return Ok(()); | ||
} | ||
let mut rpc = MullvadProxyClient::new().await?; | ||
rpc.factory_reset().await?; | ||
#[cfg(target_os = "linux")] | ||
println!("If you're running systemd, to remove all logs, you must use journalctl"); | ||
Ok(()) | ||
} | ||
|
||
async fn receive_confirmation() -> bool { | ||
println!("Are you sure you want to disconnect, log out, delete all settings, logs and cache files for the Mullvad VPN system service? [Yes/No (default)]"); | ||
|
||
tokio::task::spawn_blocking(|| loop { | ||
let mut buf = String::new(); | ||
if let Err(e) = stdin().read_line(&mut buf) { | ||
eprintln!("Couldn't read from STDIN: {e}"); | ||
return false; | ||
} | ||
match buf.trim() { | ||
"Yes" => return true, | ||
"No" | "no" | "" => return false, | ||
_ => eprintln!("Unexpected response. Please enter \"Yes\" or \"No\""), | ||
} | ||
}) | ||
.await | ||
.unwrap() | ||
} |
Oops, something went wrong.