Skip to content

Commit

Permalink
Fix VPN connection close on switch off
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
basilgello committed Nov 29, 2023
1 parent 733d6db commit 7f54714
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 7f54714

Please sign in to comment.