Skip to content

Commit

Permalink
Rename wireguard key removal function
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Mar 14, 2022
1 parent 2ea9a77 commit 8f00a86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist-assets/linux/before-remove.sh
Expand Up @@ -26,4 +26,4 @@ fi
pkill -x "mullvad-gui" || true

/opt/Mullvad\ VPN/resources/mullvad-setup reset-firewall || echo "Failed to reset firewall"
/opt/Mullvad\ VPN/resources/mullvad-setup remove-wireguard-key || echo "Failed to remove leftover WireGuard key"
/opt/Mullvad\ VPN/resources/mullvad-setup remove-device || echo "Failed to remove device from account"
2 changes: 1 addition & 1 deletion dist-assets/uninstall_macos.sh
Expand Up @@ -23,7 +23,7 @@ sudo dscl . -delete /groups/mullvad-exclusion || echo "Failed to remove 'mullvad

echo "Resetting firewall"
sudo /Applications/Mullvad\ VPN.app/Contents/Resources/mullvad-setup reset-firewall
sudo /Applications/Mullvad\ VPN.app/Contents/Resources/mullvad-setup remove-wireguard-key
sudo /Applications/Mullvad\ VPN.app/Contents/Resources/mullvad-setup remove-device

echo "Removing zsh shell completion symlink ..."
sudo rm -f /usr/local/share/zsh/site-functions/_mullvad
Expand Down
18 changes: 9 additions & 9 deletions dist-assets/windows/installer.nsh
Expand Up @@ -712,33 +712,33 @@
!define FirewallWarningCheck '!insertmacro "FirewallWarningCheck"'

#
# RemoveWireGuardKey
# RemoveCurrentDevice
#
# Remove the WireGuard key from the account, if there is one
# Remove the device from the account, if there is one
#
!macro RemoveWireGuardKey
!macro RemoveCurrentDevice

log::Log "RemoveWireGuardKey()"
log::Log "RemoveCurrentDevice()"

Push $0
Push $1

nsExec::ExecToStack '"$TEMP\mullvad-setup.exe" remove-wireguard-key'
nsExec::ExecToStack '"$TEMP\mullvad-setup.exe" remove-device'
Pop $0
Pop $1

${If} $0 != ${MVSETUP_OK}
log::LogWithDetails "RemoveWireGuardKey() failed" $1
log::LogWithDetails "RemoveCurrentDevice() failed" $1
${Else}
log::Log "RemoveWireGuardKey() completed successfully"
log::Log "RemoveCurrentDevice() completed successfully"
${EndIf}

Pop $1
Pop $0

!macroend

!define RemoveWireGuardKey '!insertmacro "RemoveWireGuardKey"'
!define RemoveCurrentDevice '!insertmacro "RemoveCurrentDevice"'


#
Expand Down Expand Up @@ -1170,7 +1170,7 @@

${If} $FullUninstall == 1
${ClearFirewallRules}
${RemoveWireGuardKey}
${RemoveCurrentDevice}

${ExtractWireGuard}
${RemoveWintun}
Expand Down
14 changes: 7 additions & 7 deletions mullvad-setup/src/main.rs
Expand Up @@ -17,7 +17,7 @@ lazy_static::lazy_static! {
}

const KEY_RETRY_INTERVAL: Duration = Duration::ZERO;
const KEY_RETRY_MAX_RETRIES: usize = 2;
const KEY_RETRY_MAX_RETRIES: usize = 4;

#[repr(i32)]
enum ExitStatus {
Expand Down Expand Up @@ -63,8 +63,8 @@ pub enum Error {
#[error(display = "Failed to initialize mullvad RPC runtime")]
RpcInitializationError(#[error(source)] mullvad_rpc::Error),

#[error(display = "Failed to remove WireGuard key for account")]
RemoveKeyError(#[error(source)] mullvad_rpc::rest::Error),
#[error(display = "Failed to remove device from account")]
RemoveDeviceError(#[error(source)] mullvad_rpc::rest::Error),

#[error(display = "Failed to obtain settings directory path")]
SettingsPathError(#[error(source)] SettingsPathErrorType),
Expand All @@ -90,7 +90,7 @@ async fn main() {
App::new("prepare-restart")
.about("Move a running daemon into a blocking state and save its target state"),
App::new("reset-firewall").about("Remove any firewall rules introduced by the daemon"),
App::new("remove-wireguard-key").about("Removes the WireGuard key from the active account"),
App::new("remove-device").about("Remove the current device from the active account"),
App::new("is-older-version")
.about("Checks whether the given version is older than the current version")
.arg(
Expand All @@ -113,7 +113,7 @@ async fn main() {
let result = match matches.subcommand() {
Some(("prepare-restart", _)) => prepare_restart().await,
Some(("reset-firewall", _)) => reset_firewall().await,
Some(("remove-wireguard-key", _)) => remove_wireguard_key().await,
Some(("remove-device", _)) => remove_device().await,
Some(("is-older-version", sub_matches)) => {
let old_version = sub_matches.value_of("OLDVERSION").unwrap();
match is_older_version(old_version).await {
Expand Down Expand Up @@ -162,7 +162,7 @@ async fn reset_firewall() -> Result<(), Error> {
.map_err(Error::FirewallError)
}

async fn remove_wireguard_key() -> Result<(), Error> {
async fn remove_device() -> Result<(), Error> {
let (cache_path, settings_path) = get_paths()?;
let (mut cacher, data) = mullvad_daemon::device::DeviceCacher::new(&settings_path)
.await
Expand Down Expand Up @@ -192,7 +192,7 @@ async fn remove_wireguard_key() -> Result<(), Error> {
KEY_RETRY_MAX_RETRIES,
)
.await
.map_err(Error::RemoveKeyError)?;
.map_err(Error::RemoveDeviceError)?;

cacher
.write(None)
Expand Down

0 comments on commit 8f00a86

Please sign in to comment.