From 7cb2f52e809a72201cfd3444166c500946de2e71 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 30 Oct 2019 00:04:39 +0100 Subject: make sure shapeshifter dispatcher is stopped between switching vpn processes --- .../de/blinkt/openvpn/core/OpenVPNService.java | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 2c4462e0..0863cc8e 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -248,6 +248,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac if (!replaceConnection) { if (shapeshifter != null) { shapeshifter.stop(); + shapeshifter = null; } VpnStatus.updateStateString("NOPROCESS", "VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED); } @@ -255,14 +256,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } return false; } else { - if (!replaceConnection) { - if (shapeshifter != null) { - shapeshifter.stop(); - } - VpnStatus.updateStateString("NOPROCESS", "VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED); - return true; - } - return false; + VpnStatus.updateStateString("NOPROCESS", "VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED); + return true; } } @@ -384,12 +379,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac Connection connection = mProfile.mConnections[0]; - if (mProfile.mUsePluggableTransports) { - Obfs4Connection obfs4Connection = (Obfs4Connection) connection; - shapeshifter = new Shapeshifter(obfs4Connection.getDispatcherOptions()); - shapeshifter.start(); - } - VpnStatus.logInfo(R.string.building_configration); VpnStatus.updateStateString("VPN_GENERATE_CONFIG", "", R.string.building_configration, ConnectionStatus.LEVEL_START); @@ -414,6 +403,14 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac // An old running VPN should now be exited mStarting = false; + if (mProfile.mUsePluggableTransports) { + Obfs4Connection obfs4Connection = (Obfs4Connection) connection; + if (shapeshifter == null) { + shapeshifter = new Shapeshifter(obfs4Connection.getDispatcherOptions()); + shapeshifter.start(); + } + } + // Start a new session by creating a new thread. boolean useOpenVPN3 = VpnProfile.doUseOpenVPN3(this); @@ -460,11 +457,17 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } private void stopOldOpenVPNProcess() { + Log.d(TAG, "stopOldVPNProcess"); if (mManagement != null) { if (mOpenVPNThread != null) ((OpenVPNThread) mOpenVPNThread).setReplaceConnection(); if (mManagement.stopVPN(true)) { // an old was asked to exit, wait 1s + if (shapeshifter != null) { + Log.d(TAG, "-> stop shapeshifter"); + shapeshifter.stop(); + shapeshifter = null; + } try { Thread.sleep(1000); } catch (InterruptedException e) { -- cgit v1.2.3