From 7f54714177366b4500f7255f0a1a311abec35674 Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Wed, 29 Nov 2023 13:55:15 +0200 Subject: [PATCH] Fix VPN connection close on switch off The parcel was duplicated and not casted from mutable to imutable instance as it was expected in start() so stop() did not destroy interface completely. Test: switch 'Enable Yggdrasil' on, appro e VPN connection, wait 10 secobds, switch off, observe no VPN notification (key symbol). Signed-off-by: Vasyl Gello --- .../java/eu/neilalexander/yggdrasil/PacketTunnelProvider.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/PacketTunnelProvider.kt b/app/src/main/java/eu/neilalexander/yggdrasil/PacketTunnelProvider.kt index 7259e80..a8e2ca0 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/PacketTunnelProvider.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/PacketTunnelProvider.kt @@ -152,8 +152,7 @@ open class PacketTunnelProvider: VpnService() { builder.addRoute("2001:4860:4860::8888", 128) } - parcel = builder.establish() - val parcel = parcel + val parcel = builder.establish() if (parcel == null || !parcel.fileDescriptor.valid()) { stop() return @@ -172,6 +171,8 @@ open class PacketTunnelProvider: VpnService() { updater() } + this.parcel = parcel + var intent = Intent(YGG_STATE_INTENT) intent.putExtra("state", STATE_ENABLED) LocalBroadcastManager.getInstance(this).sendBroadcast(intent)