fix: kernel mode and slowness

Switch to amenzia backend by default.

Revert to wg official kernel backend as Amnezia's does not work.
This commit is contained in:
Zane Schepke 2024-09-20 21:53:55 -04:00
parent 4355e2e9ce
commit 03fdb82c24
4 changed files with 8 additions and 24 deletions

View File

@ -4,7 +4,9 @@ import android.content.Context
import com.wireguard.android.backend.Backend import com.wireguard.android.backend.Backend
import com.wireguard.android.backend.GoBackend import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.RootTunnelActionHandler import com.wireguard.android.backend.RootTunnelActionHandler
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.util.RootShell import com.wireguard.android.util.RootShell
import com.wireguard.android.util.ToolsInstaller
import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository
import com.zaneschepke.wireguardautotunnel.service.tunnel.TunnelService import com.zaneschepke.wireguardautotunnel.service.tunnel.TunnelService
import com.zaneschepke.wireguardautotunnel.service.tunnel.WireGuardTunnel import com.zaneschepke.wireguardautotunnel.service.tunnel.WireGuardTunnel
@ -43,8 +45,8 @@ class TunnelModule {
@Provides @Provides
@Singleton @Singleton
@Kernel @Kernel
fun provideKernelBackend(@ApplicationContext context: Context, rootShell: org.amnezia.awg.util.RootShell): org.amnezia.awg.backend.Backend { fun provideKernelBackend(@ApplicationContext context: Context, rootShell: RootShell): Backend {
return org.amnezia.awg.backend.AwgQuickBackend(context, rootShell, org.amnezia.awg.util.ToolsInstaller(context, rootShell)) return WgQuickBackend(context, rootShell, ToolsInstaller(context, rootShell), RootTunnelActionHandler(rootShell))
} }
@Provides @Provides
@ -57,15 +59,13 @@ class TunnelModule {
@Singleton @Singleton
fun provideVpnService( fun provideVpnService(
amneziaBackend: Provider<org.amnezia.awg.backend.Backend>, amneziaBackend: Provider<org.amnezia.awg.backend.Backend>,
@Userspace userspaceBackend: Provider<Backend>, @Kernel kernelBackend: Provider<Backend>,
@Kernel kernelBackend: Provider<org.amnezia.awg.backend.Backend>,
appDataRepository: AppDataRepository, appDataRepository: AppDataRepository,
@ApplicationScope applicationScope: CoroutineScope, @ApplicationScope applicationScope: CoroutineScope,
@IoDispatcher ioDispatcher: CoroutineDispatcher, @IoDispatcher ioDispatcher: CoroutineDispatcher,
): TunnelService { ): TunnelService {
return WireGuardTunnel( return WireGuardTunnel(
amneziaBackend, amneziaBackend,
userspaceBackend,
kernelBackend, kernelBackend,
appDataRepository, appDataRepository,
applicationScope, applicationScope,

View File

@ -32,8 +32,7 @@ class WireGuardTunnel
@Inject @Inject
constructor( constructor(
private val amneziaBackend: Provider<org.amnezia.awg.backend.Backend>, private val amneziaBackend: Provider<org.amnezia.awg.backend.Backend>,
@Userspace private val userspaceBackend: Provider<Backend>, @Kernel private val kernelBackend: Provider<Backend>,
@Kernel private val kernelBackend: Provider<org.amnezia.awg.backend.Backend>,
private val appDataRepository: AppDataRepository, private val appDataRepository: AppDataRepository,
@ApplicationScope private val applicationScope: CoroutineScope, @ApplicationScope private val applicationScope: CoroutineScope,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher, @IoDispatcher private val ioDispatcher: CoroutineDispatcher,
@ -78,8 +77,7 @@ constructor(
private suspend fun backend(): Any { private suspend fun backend(): Any {
val settings = appDataRepository.settings.getSettings() val settings = appDataRepository.settings.getSettings()
if (settings.isKernelEnabled) return kernelBackend.get() if (settings.isKernelEnabled) return kernelBackend.get()
if (settings.isAmneziaEnabled) return amneziaBackend.get() return amneziaBackend.get()
return userspaceBackend.get()
} }
override suspend fun startTunnel(tunnelConfig: TunnelConfig): Result<TunnelState> { override suspend fun startTunnel(tunnelConfig: TunnelConfig): Result<TunnelState> {

View File

@ -491,20 +491,6 @@ fun SettingsScreen(
title = stringResource(id = R.string.backend), title = stringResource(id = R.string.backend),
padding = screenPadding, padding = screenPadding,
) )
ConfigurationToggle(
stringResource(R.string.use_amnezia),
enabled =
!(
uiState.settings.isAutoTunnelEnabled ||
uiState.settings.isAlwaysOnVpnEnabled ||
(uiState.vpnState.status == TunnelState.UP) || uiState.settings.isKernelEnabled
),
checked = uiState.settings.isAmneziaEnabled,
padding = screenPadding,
onCheckChanged = {
viewModel.onToggleAmnezia()
},
)
ConfigurationToggle( ConfigurationToggle(
stringResource(R.string.use_kernel), stringResource(R.string.use_kernel),
enabled = enabled =

View File

@ -13,7 +13,7 @@ espressoCore = "3.6.1"
hiltAndroid = "2.52" hiltAndroid = "2.52"
hiltNavigationCompose = "1.2.0" hiltNavigationCompose = "1.2.0"
junit = "4.13.2" junit = "4.13.2"
kotlinx-serialization-json = "1.7.2" kotlinx-serialization-json = "1.7.3"
lifecycle-runtime-compose = "2.8.6" lifecycle-runtime-compose = "2.8.6"
material3 = "1.3.0" material3 = "1.3.0"
navigationCompose = "2.8.1" navigationCompose = "2.8.1"