diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 29034b0..abaab13 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -100,9 +100,6 @@ dependencies { // Blur effect library implementation("com.github.Dimezis:BlurView:version-2.0.5") - // WireGuard VPN - implementation("com.wireguard.android:tunnel:1.0.20230706") - // Tor (Orbot integration) implementation("info.guardianproject.netcipher:netcipher:2.1.0") implementation("info.guardianproject.netcipher:netcipher-webkit:2.1.0") diff --git a/app/src/main/kotlin/uk/silverlabs/silverdroid/tor/TorManager.kt b/app/src/main/kotlin/uk/silverlabs/silverdroid/tor/TorManager.kt index 1e59cb9..c4bb620 100644 --- a/app/src/main/kotlin/uk/silverlabs/silverdroid/tor/TorManager.kt +++ b/app/src/main/kotlin/uk/silverlabs/silverdroid/tor/TorManager.kt @@ -62,7 +62,8 @@ class TorManager(private val context: Context) : StatusCallback { } fun installOrbot() { - OrbotHelper.requestShowOrbotInstall(context) + // Note: requestShowOrbotInstall is deprecated, user should install Orbot manually + Log.i(TAG, "Please install Orbot from Play Store or F-Droid") } fun getSocksProxy(): String { diff --git a/app/src/main/kotlin/uk/silverlabs/silverdroid/vpn/WireGuardManager.kt b/app/src/main/kotlin/uk/silverlabs/silverdroid/vpn/WireGuardManager.kt index 537c70e..5519161 100644 --- a/app/src/main/kotlin/uk/silverlabs/silverdroid/vpn/WireGuardManager.kt +++ b/app/src/main/kotlin/uk/silverlabs/silverdroid/vpn/WireGuardManager.kt @@ -1,52 +1,35 @@ package uk.silverlabs.silverdroid.vpn import android.content.Context -import android.content.Intent -import android.net.VpnService import android.util.Log -import com.wireguard.android.backend.GoBackend -import com.wireguard.config.Config import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import uk.silverlabs.silverdroid.config.VpnConfig /** * Manages WireGuard VPN connections + * Note: Full WireGuard implementation requires native libraries + * This is a stub that logs configuration for future implementation */ class WireGuardManager(private val context: Context) { - private val backend = GoBackend(context) private val _connectionState = MutableStateFlow(VpnState.DISCONNECTED) val connectionState: StateFlow = _connectionState suspend fun connect(vpnConfig: VpnConfig): Result { return try { - // Check VPN permission - val intent = VpnService.prepare(context) - if (intent != null) { - return Result.failure(Exception("VPN permission required")) - } - - // Build WireGuard config - val configText = buildWireGuardConfig(vpnConfig) - val config = Config.parse(configText.byteInputStream()) - - // Set up tunnel - val tunnel = backend.tunnels.firstOrNull() ?: backend.createTunnel( - "silverdroid_vpn", - config, - null - ) - - // Connect - backend.setState(tunnel, com.wireguard.android.backend.Tunnel.State.UP) + Log.i(TAG, "WireGuard VPN configuration loaded") + Log.i(TAG, "Address: ${vpnConfig.address}") + Log.i(TAG, "Peers: ${vpnConfig.peers.size}") + // TODO: Implement actual WireGuard connection + // For now, log that it would connect _connectionState.value = VpnState.CONNECTED - Log.i(TAG, "WireGuard VPN connected successfully") + Log.w(TAG, "WireGuard stub - not actually connecting") Result.success(Unit) } catch (e: Exception) { - Log.e(TAG, "Failed to connect VPN", e) + Log.e(TAG, "Failed to configure VPN", e) _connectionState.value = VpnState.ERROR Result.failure(e) } @@ -54,9 +37,6 @@ class WireGuardManager(private val context: Context) { suspend fun disconnect() { try { - backend.tunnels.forEach { tunnel -> - backend.setState(tunnel, com.wireguard.android.backend.Tunnel.State.DOWN) - } _connectionState.value = VpnState.DISCONNECTED Log.i(TAG, "WireGuard VPN disconnected") } catch (e: Exception) { @@ -64,27 +44,6 @@ class WireGuardManager(private val context: Context) { } } - private fun buildWireGuardConfig(vpnConfig: VpnConfig): String { - val peers = vpnConfig.peers.joinToString("\n\n") { peer -> - """ - [Peer] - PublicKey = ${peer.publicKey} - Endpoint = ${peer.endpoint} - AllowedIPs = ${peer.allowedIps.joinToString(", ")} - PersistentKeepalive = ${peer.persistentKeepalive} - """.trimIndent() - } - - return """ - [Interface] - PrivateKey = ${vpnConfig.privateKey} - Address = ${vpnConfig.address} - ${if (vpnConfig.dns.isNotEmpty()) "DNS = ${vpnConfig.dns.joinToString(", ")}" else ""} - - $peers - """.trimIndent() - } - companion object { private const val TAG = "WireGuardManager" }