From 2877757396adf6093dcfc7f4852be61c4a9dd246 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Wed, 11 Dec 2024 01:32:39 -0500 Subject: [PATCH] fix: kernel mode toggle bug --- .../wireguardautotunnel/service/tunnel/WireGuardTunnel.kt | 2 ++ .../ui/screens/settings/killswitch/KillSwitchScreen.kt | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt index 4c81940..955bf16 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/WireGuardTunnel.kt @@ -85,6 +85,7 @@ constructor( private suspend fun setState(tunnelConfig: TunnelConfig, tunnelState: TunnelState): Result { return runCatching { + updateTunnelConfig(tunnelConfig) //need so kernel can get tunnel name or it breaks kernel when (val backend = backend()) { is Backend -> backend.setState(this, tunnelState.toWgState(), TunnelConfig.configFromWgQuick(tunnelConfig.wgQuick)).let { TunnelState.from(it) } is org.amnezia.awg.backend.Backend -> { @@ -102,6 +103,7 @@ constructor( else -> throw NotImplementedError() } }.onFailure { + //TODO add better error message and comms to user Timber.e(it) } } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/killswitch/KillSwitchScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/killswitch/KillSwitchScreen.kt index a2dddf8..39a29f7 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/killswitch/KillSwitchScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/killswitch/KillSwitchScreen.kt @@ -25,7 +25,9 @@ import com.zaneschepke.wireguardautotunnel.ui.common.button.surface.SelectionIte import com.zaneschepke.wireguardautotunnel.ui.common.button.surface.SurfaceSelectionGroupButton import com.zaneschepke.wireguardautotunnel.ui.common.navigation.TopNavBar import com.zaneschepke.wireguardautotunnel.ui.common.permission.vpn.withVpnPermission +import com.zaneschepke.wireguardautotunnel.ui.common.snackbar.SnackbarController import com.zaneschepke.wireguardautotunnel.ui.screens.settings.components.ForwardButton +import com.zaneschepke.wireguardautotunnel.util.StringValue import com.zaneschepke.wireguardautotunnel.util.extensions.isRunningOnTv import com.zaneschepke.wireguardautotunnel.util.extensions.launchVpnSettings import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight @@ -39,6 +41,8 @@ fun KillSwitchScreen(uiState: AppUiState, appViewModel: AppViewModel) { fun toggleVpnKillSwitch() { with(uiState.settings) { + //TODO improve this error message + if(isKernelEnabled) return SnackbarController.showMessage(StringValue.StringResource(R.string.kernel_not_supported)) if (isVpnKillSwitchEnabled) { appViewModel.onToggleVpnKillSwitch(false) } else {