fix vpn close when getting new subnet route (#179)

This commit is contained in:
Sijie.Sun
2024-07-18 08:48:45 +08:00
committed by GitHub
parent 5987528f59
commit 8858492fb4
2 changed files with 59 additions and 31 deletions

View File

@@ -57,21 +57,23 @@ class TauriVpnService : VpnService() {
override fun onDestroy() {
println("vpn on destroy")
self = null
super.onDestroy()
disconnect()
self = null
}
override fun onRevoke() {
println("vpn on revoke")
self = null
super.onRevoke()
disconnect()
self = null
}
private fun disconnect() {
triggerCallback("vpn_service_stop", JSObject())
vpnInterface.close()
if (self == this && this::vpnInterface.isInitialized) {
triggerCallback("vpn_service_stop", JSObject())
vpnInterface.close()
}
}
private fun createVpnInterface(args: Bundle?): ParcelFileDescriptor {