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

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

No files matched your search

@@ -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 {