blob: a8c275a0427d691f02afd716c4641665ce92be56 (
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
|
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");
}
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()
}
|