diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 1462010..396bfad 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -106,6 +106,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | + SHA256 fingerprint: ```${{ steps.checksum.outputs.checksum }}``` tag_name: ${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3ac882..36f6436 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,6 +112,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | + SHA256 fingerprint: ```${{ steps.checksum.outputs.checksum }}``` tag_name: ${{ github.ref_name }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e2c2e2c..b36fadf 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -160,8 +160,8 @@ dependencies { debugImplementation(libs.androidx.compose.ui.tooling) debugImplementation(libs.androidx.compose.manifest) - // get tunnel lib from github packages or mavenLocal - implementation(libs.tunnel) + // tunnel + implementation(libs.amneziawg.android) coreLibraryDesugaring(libs.desugar.jdk.libs) // logging diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/data/model/TunnelConfig.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/data/model/TunnelConfig.kt index b16b372..56618ef 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/data/model/TunnelConfig.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/data/model/TunnelConfig.kt @@ -4,7 +4,7 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey -import com.wireguard.config.Config +import org.amnezia.awg.config.Config import java.io.InputStream @Entity(indices = [Index(value = ["name"], unique = true)]) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/module/TunnelModule.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/module/TunnelModule.kt index 1d01659..eb07ef0 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/module/TunnelModule.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/module/TunnelModule.kt @@ -1,11 +1,6 @@ package com.zaneschepke.wireguardautotunnel.module import android.content.Context -import com.wireguard.android.backend.Backend -import com.wireguard.android.backend.GoBackend -import com.wireguard.android.backend.WgQuickBackend -import com.wireguard.android.util.RootShell -import com.wireguard.android.util.ToolsInstaller import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository import com.zaneschepke.wireguardautotunnel.service.foreground.ServiceManager import com.zaneschepke.wireguardautotunnel.service.tunnel.VpnService @@ -15,6 +10,11 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import org.amnezia.awg.backend.AwgQuickBackend +import org.amnezia.awg.backend.Backend +import org.amnezia.awg.backend.GoBackend +import org.amnezia.awg.util.RootShell +import org.amnezia.awg.util.ToolsInstaller import javax.inject.Singleton @Module @@ -37,7 +37,7 @@ class TunnelModule { @Singleton @Kernel fun provideKernelBackend(@ApplicationContext context: Context, rootShell: RootShell): Backend { - return WgQuickBackend(context, rootShell, ToolsInstaller(context, rootShell)) + return AwgQuickBackend(context, rootShell, ToolsInstaller(context, rootShell)) } @Provides diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WatcherState.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WatcherState.kt index 4e22360..60db9c9 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WatcherState.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WatcherState.kt @@ -1,8 +1,8 @@ package com.zaneschepke.wireguardautotunnel.service.foreground -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.data.model.Settings import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig +import org.amnezia.awg.backend.Tunnel data class WatcherState( val isWifiConnected: Boolean = false, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt index be31496..0f569c3 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.os.PowerManager import androidx.core.app.ServiceCompat import androidx.lifecycle.lifecycleScope -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.R import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository @@ -25,6 +24,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Tunnel import timber.log.Timber import java.net.InetAddress import javax.inject.Inject diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt index b6c2052..4968229 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt @@ -5,7 +5,6 @@ import android.content.Intent import android.os.Bundle import androidx.core.app.ServiceCompat import androidx.lifecycle.lifecycleScope -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.R import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository import com.zaneschepke.wireguardautotunnel.receiver.NotificationActionReceiver @@ -21,6 +20,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Tunnel import timber.log.Timber import javax.inject.Inject diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt index eb221b6..57eb38f 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt @@ -3,7 +3,6 @@ package com.zaneschepke.wireguardautotunnel.service.tile import android.os.Build import android.service.quicksettings.Tile import android.service.quicksettings.TileService -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository import com.zaneschepke.wireguardautotunnel.service.foreground.ServiceManager @@ -13,6 +12,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Tunnel import timber.log.Timber import javax.inject.Inject diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnService.kt index 285ba40..b67f689 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnService.kt @@ -1,8 +1,8 @@ package com.zaneschepke.wireguardautotunnel.service.tunnel -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import kotlinx.coroutines.flow.StateFlow +import org.amnezia.awg.backend.Tunnel interface VpnService : Tunnel { suspend fun startTunnel(tunnelConfig: TunnelConfig? = null): Tunnel.State diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnState.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnState.kt index e409980..fa58e24 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnState.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tunnel/VpnState.kt @@ -1,8 +1,8 @@ package com.zaneschepke.wireguardautotunnel.service.tunnel -import com.wireguard.android.backend.Statistics -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig +import org.amnezia.awg.backend.Statistics +import org.amnezia.awg.backend.Tunnel data class VpnState( val status: Tunnel.State = Tunnel.State.DOWN, 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 4f6b6e4..bb228ea 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 @@ -1,9 +1,5 @@ package com.zaneschepke.wireguardautotunnel.service.tunnel -import com.wireguard.android.backend.Backend -import com.wireguard.android.backend.BackendException -import com.wireguard.android.backend.Statistics -import com.wireguard.android.backend.Tunnel.State import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository @@ -19,6 +15,10 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Backend +import org.amnezia.awg.backend.BackendException +import org.amnezia.awg.backend.Statistics +import org.amnezia.awg.backend.Tunnel import timber.log.Timber import javax.inject.Inject @@ -56,7 +56,7 @@ constructor( } } - override suspend fun startTunnel(tunnelConfig: TunnelConfig?): State { + override suspend fun startTunnel(tunnelConfig: TunnelConfig?): Tunnel.State { return try { //TODO we need better error handling here val config = tunnelConfig ?: appDataRepository.getPrimaryOrFirstTunnel() @@ -66,18 +66,18 @@ constructor( val state = backend.setState( this, - State.UP, + Tunnel.State.UP, wgConfig, ) state } else throw Exception("No tunnels") } catch (e: BackendException) { Timber.e("Failed to start tunnel with error: ${e.message}") - State.DOWN + Tunnel.State.DOWN } } - private fun emitTunnelState(state: State) { + private fun emitTunnelState(state: Tunnel.State) { _vpnState.tryEmit( _vpnState.value.copy( status = state, @@ -103,8 +103,8 @@ constructor( override suspend fun stopTunnel() { try { - if (getState() == State.UP) { - val state = backend.setState(this, State.DOWN, null) + if (getState() == Tunnel.State.UP) { + val state = backend.setState(this, Tunnel.State.DOWN, null) emitTunnelState(state) } } catch (e: BackendException) { @@ -112,7 +112,7 @@ constructor( } } - override fun getState(): State { + override fun getState(): Tunnel.State { return backend.getState(this) } @@ -120,11 +120,11 @@ constructor( return _vpnState.value.tunnelConfig?.name ?: "" } - override fun onStateChange(state: State) { + override fun onStateChange(state: Tunnel.State) { val tunnel = this emitTunnelState(state) WireGuardAutoTunnel.requestTunnelTileServiceStateUpdate(WireGuardAutoTunnel.instance) - if (state == State.UP) { + if (state == Tunnel.State.UP) { statsJob = scope.launch { while (true) { @@ -134,7 +134,7 @@ constructor( } } } - if (state == State.DOWN) { + if (state == Tunnel.State.DOWN) { try { statsJob?.cancel() } catch (e : CancellationException) { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/AppViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/AppViewModel.kt index 8555d8d..bb714e2 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/AppViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/AppViewModel.kt @@ -8,7 +8,6 @@ import android.widget.Toast import androidx.compose.runtime.mutableStateListOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.wireguard.android.backend.GoBackend import com.zaneschepke.logcatter.Logcatter import com.zaneschepke.logcatter.model.LogMessage import com.zaneschepke.wireguardautotunnel.R @@ -20,6 +19,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import org.amnezia.awg.backend.GoBackend import timber.log.Timber import java.time.Instant import javax.inject.Inject diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/RowListItem.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/RowListItem.kt index 87964b2..3bf6526 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/RowListItem.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/RowListItem.kt @@ -17,9 +17,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.wireguard.android.backend.Statistics import com.zaneschepke.wireguardautotunnel.util.NumberUtils import com.zaneschepke.wireguardautotunnel.util.toThreeDecimalPlaceString +import org.amnezia.awg.backend.Statistics @OptIn(ExperimentalFoundationApi::class) @Composable diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/InterfaceProxy.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/InterfaceProxy.kt index 76189a5..b71a129 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/InterfaceProxy.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/InterfaceProxy.kt @@ -1,6 +1,6 @@ package com.zaneschepke.wireguardautotunnel.ui.models -import com.wireguard.config.Interface +import org.amnezia.awg.config.Interface data class InterfaceProxy( var privateKey: String = "", diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/PeerProxy.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/PeerProxy.kt index abf78d3..b4a01ce 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/PeerProxy.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/models/PeerProxy.kt @@ -1,6 +1,6 @@ package com.zaneschepke.wireguardautotunnel.ui.models -import com.wireguard.config.Peer +import org.amnezia.awg.config.Peer data class PeerProxy( var publicKey: String = "", diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt index b7a4fdc..555ae16 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigViewModel.kt @@ -7,11 +7,6 @@ import android.content.pm.PackageManager import android.os.Build import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.wireguard.config.Config -import com.wireguard.config.Interface -import com.wireguard.config.Peer -import com.wireguard.crypto.Key -import com.wireguard.crypto.KeyPair import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository @@ -28,6 +23,11 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import org.amnezia.awg.config.Config +import org.amnezia.awg.config.Interface +import org.amnezia.awg.config.Peer +import org.amnezia.awg.crypto.Key +import org.amnezia.awg.crypto.KeyPair import timber.log.Timber import javax.inject.Inject @@ -198,12 +198,12 @@ constructor( val tunnelConfig = when (uiState.value.tunnel) { null -> TunnelConfig( name = _uiState.value.tunnelName, - wgQuick = config.toWgQuickString(), + wgQuick = config.toAwgQuickString(), ) else -> uiState.value.tunnel!!.copy( name = _uiState.value.tunnelName, - wgQuick = config.toWgQuickString(), + wgQuick = config.toAwgQuickString(), ) } updateTunnelConfig(tunnelConfig) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt index 05202b1..90ca7fe 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt @@ -89,7 +89,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavController import com.journeyapps.barcodescanner.ScanContract import com.journeyapps.barcodescanner.ScanOptions -import com.wireguard.android.backend.Tunnel import com.zaneschepke.wireguardautotunnel.R import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig @@ -110,6 +109,7 @@ import com.zaneschepke.wireguardautotunnel.util.truncateWithEllipsis import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Tunnel @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt index c18a73f..675c9e1 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt @@ -7,7 +7,6 @@ import android.net.Uri import android.provider.OpenableColumns import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.wireguard.config.Config import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.data.model.Settings import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig @@ -25,6 +24,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.amnezia.awg.config.Config import timber.log.Timber import java.io.InputStream import java.util.zip.ZipInputStream @@ -119,7 +119,7 @@ constructor( val bufferReader = stream.bufferedReader(charset = Charsets.UTF_8) val config = Config.parse(bufferReader) val tunnelName = getNameFromFileName(fileName) - addTunnel(TunnelConfig(name = tunnelName, wgQuick = config.toWgQuickString())) + addTunnel(TunnelConfig(name = tunnelName, wgQuick = config.toAwgQuickString())) withContext(Dispatchers.IO) { stream.close() } } @@ -164,7 +164,7 @@ constructor( val name = getNameFromFileName(it.name) val config = Config.parse(zip) viewModelScope.launch(Dispatchers.IO) { - addTunnel(TunnelConfig(name = name, wgQuick = config.toWgQuickString())) + addTunnel(TunnelConfig(name = name, wgQuick = config.toAwgQuickString())) } } } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt index bef66b0..9e256c3 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt @@ -71,8 +71,6 @@ import androidx.navigation.NavController import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted import com.google.accompanist.permissions.rememberPermissionState -import com.wireguard.android.backend.Tunnel -import com.wireguard.android.backend.WgQuickBackend import com.zaneschepke.wireguardautotunnel.R import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.ui.AppViewModel @@ -86,6 +84,8 @@ import com.zaneschepke.wireguardautotunnel.util.FileUtils import com.zaneschepke.wireguardautotunnel.util.Result import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.amnezia.awg.backend.AwgQuickBackend +import org.amnezia.awg.backend.Tunnel import timber.log.Timber import xyz.teamgravity.pin_lock_compose.PinManager import java.io.File @@ -551,7 +551,7 @@ fun SettingsScreen( } } } - if (WgQuickBackend.hasKernelSupport()) { + if (AwgQuickBackend.hasKernelSupport()) { Surface( tonalElevation = 2.dp, shadowElevation = 2.dp, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsViewModel.kt index d71ce51..40d0195 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsViewModel.kt @@ -6,7 +6,6 @@ import android.location.LocationManager import androidx.core.location.LocationManagerCompat import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.wireguard.android.util.RootShell import com.zaneschepke.wireguardautotunnel.WireGuardAutoTunnel import com.zaneschepke.wireguardautotunnel.data.model.Settings import com.zaneschepke.wireguardautotunnel.data.repository.AppDataRepository @@ -20,6 +19,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch +import org.amnezia.awg.util.RootShell import timber.log.Timber import javax.inject.Inject diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/Extensions.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/Extensions.kt index e82ea9f..6fa1b23 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/Extensions.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/Extensions.kt @@ -2,15 +2,14 @@ package com.zaneschepke.wireguardautotunnel.util import android.content.BroadcastReceiver import android.content.pm.PackageInfo -import com.wireguard.android.backend.Statistics -import com.wireguard.android.backend.Statistics.PeerStats -import com.wireguard.crypto.Key import com.zaneschepke.wireguardautotunnel.data.model.TunnelConfig import com.zaneschepke.wireguardautotunnel.service.tunnel.HandshakeStatus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import org.amnezia.awg.backend.Statistics +import org.amnezia.awg.crypto.Key import java.math.BigDecimal import java.text.DecimalFormat import kotlin.coroutines.CoroutineContext @@ -50,15 +49,15 @@ typealias TunnelConfigs = List typealias Packages = List -fun Statistics.mapPeerStats(): Map { +fun Statistics.mapPeerStats(): Map { return this.peers().associateWith { key -> (this.peer(key)) } } -fun PeerStats.latestHandshakeSeconds(): Long? { +fun Statistics.PeerStats.latestHandshakeSeconds(): Long? { return NumberUtils.getSecondsBetweenTimestampAndNow(this.latestHandshakeEpochMillis) } -fun PeerStats.handshakeStatus(): HandshakeStatus { +fun Statistics.PeerStats.handshakeStatus(): HandshakeStatus { // TODO add never connected status after duration return this.latestHandshakeSeconds().let { when { diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt index c8a68a7..056887d 100644 --- a/buildSrc/src/main/kotlin/Constants.kt +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -1,7 +1,7 @@ object Constants { - const val VERSION_NAME = "3.4.2" + const val VERSION_NAME = "3.4.3-alpha" const val JVM_TARGET = "17" - const val VERSION_CODE = 34200 + const val VERSION_CODE = 34201 const val TARGET_SDK = 34 const val MIN_SDK = 26 const val APP_ID = "com.zaneschepke.wireguardautotunnel" diff --git a/fastlane/metadata/android/en-US/changelogs/34201.txt b/fastlane/metadata/android/en-US/changelogs/34201.txt new file mode 100644 index 0000000..21d5aa2 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/34201.txt @@ -0,0 +1,2 @@ +What's new: +- AmneziaWG support \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 092ac5d..b4951a6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] accompanist = "0.34.0" activityCompose = "1.8.2" +amneziawgAndroid = "1.1.0" androidx-junit = "1.1.5" appcompat = "1.6.1" biometricKtx = "1.2.0-alpha05" @@ -41,6 +42,7 @@ accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayo accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } #room +amneziawg-android = { module = "com.zaneschepke:amneziawg-android", version.ref = "amneziawgAndroid" } androidx-biometric-ktx = { module = "androidx.biometric:biometric-ktx", version.ref = "biometricKtx" } androidx-core = { module = "androidx.core:core", version.ref = "coreKtx" } androidx-core-google-shortcuts = { module = "androidx.core:core-google-shortcuts", version.ref = "coreGoogleShortcuts" }