fix: kernel mode toggle bug

This commit is contained in:
Zane Schepke 2024-12-11 01:32:39 -05:00
parent c657c62640
commit 2877757396
2 changed files with 6 additions and 0 deletions

View File

@ -85,6 +85,7 @@ constructor(
private suspend fun setState(tunnelConfig: TunnelConfig, tunnelState: TunnelState): Result<TunnelState> {
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)
}
}

View File

@ -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 {