disconnection fix

This commit is contained in:
Розов Никита Валерьевич
2021-10-14 11:22:59 +03:00
parent 6a9cc9bf37
commit 88d5e9cbc3
2 changed files with 11 additions and 15 deletions
@@ -108,7 +108,7 @@ class VPNService : android.net.VpnService() {
get() {
return currentTunnelHandle >= 0
}
private set(value) {
set(value) {
if (value) {
mBinder.dispatchEvent(VPNServiceBinder.EVENTS.connected, "")
mConnectionTime = System.currentTimeMillis()
@@ -189,7 +189,7 @@ class VPNService : android.net.VpnService() {
Log.v(tag, "Try to disable tunnel")
when(mProtocol){
"wireguard" -> wgTurnOff(currentTunnelHandle)
"openvpn" -> mOpenVPNThreadv3?.stopVPN()
"openvpn" -> ovpnTurnOff()
else -> {
Log.e(tag, "No protocol")
}
@@ -201,6 +201,12 @@ class VPNService : android.net.VpnService() {
stopSelf();
}
private fun ovpnTurnOff() {
mOpenVPNThreadv3?.stop()
mOpenVPNThreadv3 = null
Log.e(tag, "mOpenVPNThreadv3?.stop()")
}
/**
* Configures an Android VPN Service Tunnel
* with a given Wireguard Config
@@ -299,16 +305,12 @@ class VPNService : android.net.VpnService() {
}
private fun startOpenVpn() {
mOpenVPNThreadv3 = OpenVPNThreadv3 (this)
Thread ({
mOpenVPNThreadv3?.run()
}).start()
}
fun openvpnConnected(){
isUp = true;
}
private fun startWireGuard(){
val wireguard_conf = buildWireugardConfig(mConfig!!)
if (currentTunnelHandle != -1) {