From 283e7531d551521dc48efa9b010127ff54316326 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 4 Jul 2019 16:44:35 +0200 Subject: create one vpnprofile per transport per gateway. implement basis to switch between obfs4 and plain openvpn connections --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index a5434871..1d702ec1 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -53,6 +53,8 @@ import se.leap.bitmaskclient.R; import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; import static android.content.Intent.CATEGORY_DEFAULT; +import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; +import static de.blinkt.openvpn.core.connection.Connection.TransportType.OPENVPN; import static se.leap.bitmaskclient.Constants.BROADCAST_EIP_EVENT; import static se.leap.bitmaskclient.Constants.BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT; import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_CODE; @@ -203,7 +205,7 @@ public final class EIP extends JobIntentService implements Observer { GatewaysManager gatewaysManager = gatewaysFromPreferences(); Gateway gateway = gatewaysManager.select(nClosestGateway); - if (gateway != null && gateway.getProfile() != null) { + if (gateway != null && !gateway.getProfiles().isEmpty()) { launchActiveGateway(gateway, nClosestGateway); tellToReceiverOrBroadcast(EIP_ACTION_START, RESULT_OK); } else @@ -218,7 +220,7 @@ public final class EIP extends JobIntentService implements Observer { GatewaysManager gatewaysManager = gatewaysFromPreferences(); Gateway gateway = gatewaysManager.select(0); - if (gateway != null && gateway.getProfile() != null) { + if (gateway != null && !gateway.getProfiles().isEmpty()) { launchActiveGateway(gateway, 0); } else { Log.d(TAG, "startEIPAlwaysOnVpn no active profile available!"); @@ -242,7 +244,7 @@ public final class EIP extends JobIntentService implements Observer { */ private void launchActiveGateway(@NonNull Gateway gateway, int nClosestGateway) { Intent intent = new Intent(BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT); - intent.putExtra(PROVIDER_PROFILE, gateway.getProfile()); + intent.putExtra(PROVIDER_PROFILE, gateway.getProfile(OPENVPN)); intent.putExtra(Gateway.KEY_N_CLOSEST_GATEWAY, nClosestGateway); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); -- cgit v1.2.3 From 2ae968a8cfcfeb51874a206fd1abbf40f06cf98b Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 4 Jul 2019 17:08:29 +0200 Subject: 'using an obfusctation connection' in italic --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 1d702ec1..9b5176e7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -244,7 +244,7 @@ public final class EIP extends JobIntentService implements Observer { */ private void launchActiveGateway(@NonNull Gateway gateway, int nClosestGateway) { Intent intent = new Intent(BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT); - intent.putExtra(PROVIDER_PROFILE, gateway.getProfile(OPENVPN)); + intent.putExtra(PROVIDER_PROFILE, gateway.getProfile(OBFS4)); intent.putExtra(Gateway.KEY_N_CLOSEST_GATEWAY, nClosestGateway); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); -- cgit v1.2.3 From 0917317c006b8a3b0a8ee1c991a6287623c9562a Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 19 Jul 2019 14:44:05 +0200 Subject: adapt error handling during eip setup: refresh UI if gateway profile could not be started --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 9b5176e7..3855fa12 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -43,6 +43,7 @@ import java.util.Observer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.ConnectionStatus; import de.blinkt.openvpn.core.IOpenVPNServiceInternal; import de.blinkt.openvpn.core.OpenVPNService; @@ -53,7 +54,6 @@ import se.leap.bitmaskclient.R; import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; import static android.content.Intent.CATEGORY_DEFAULT; -import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OPENVPN; import static se.leap.bitmaskclient.Constants.BROADCAST_EIP_EVENT; import static se.leap.bitmaskclient.Constants.BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT; @@ -205,11 +205,11 @@ public final class EIP extends JobIntentService implements Observer { GatewaysManager gatewaysManager = gatewaysFromPreferences(); Gateway gateway = gatewaysManager.select(nClosestGateway); - if (gateway != null && !gateway.getProfiles().isEmpty()) { - launchActiveGateway(gateway, nClosestGateway); + if (launchActiveGateway(gateway, nClosestGateway)) { tellToReceiverOrBroadcast(EIP_ACTION_START, RESULT_OK); - } else + } else { tellToReceiverOrBroadcast(EIP_ACTION_START, RESULT_CANCELED); + } } /** @@ -242,11 +242,18 @@ public final class EIP extends JobIntentService implements Observer { * * @param gateway to connect to */ - private void launchActiveGateway(@NonNull Gateway gateway, int nClosestGateway) { + private boolean launchActiveGateway(Gateway gateway, int nClosestGateway) { + VpnProfile profile; + if (gateway == null || + (profile = gateway.getProfile(OPENVPN)) == null) { + return false; + } + Intent intent = new Intent(BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT); - intent.putExtra(PROVIDER_PROFILE, gateway.getProfile(OBFS4)); + intent.putExtra(PROVIDER_PROFILE, profile); intent.putExtra(Gateway.KEY_N_CLOSEST_GATEWAY, nClosestGateway); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); + return true; } -- cgit v1.2.3 From 990c4fa151adf9f91dc729c21b44edb0f0b55ccf Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 19 Jul 2019 18:46:12 +0200 Subject: add simple UI to enable/disable PT usage --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 3855fa12..9431ef61 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -48,12 +48,14 @@ import de.blinkt.openvpn.core.ConnectionStatus; import de.blinkt.openvpn.core.IOpenVPNServiceInternal; import de.blinkt.openvpn.core.OpenVPNService; import de.blinkt.openvpn.core.VpnStatus; +import de.blinkt.openvpn.core.connection.Connection; import se.leap.bitmaskclient.OnBootReceiver; import se.leap.bitmaskclient.R; import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; import static android.content.Intent.CATEGORY_DEFAULT; +import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OPENVPN; import static se.leap.bitmaskclient.Constants.BROADCAST_EIP_EVENT; import static se.leap.bitmaskclient.Constants.BROADCAST_GATEWAY_SETUP_OBSERVER_EVENT; @@ -76,6 +78,7 @@ import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.MainActivityErrorDialog.DOWNLOAD_ERRORS.ERROR_INVALID_VPN_CERTIFICATE; import static se.leap.bitmaskclient.R.string.vpn_certificate_is_invalid; import static se.leap.bitmaskclient.utils.ConfigHelper.ensureNotOnMainThread; +import static se.leap.bitmaskclient.utils.PreferenceHelper.getUsePluggableTransports; /** * EIP is the abstract base class for interacting with and managing the Encrypted @@ -244,8 +247,9 @@ public final class EIP extends JobIntentService implements Observer { */ private boolean launchActiveGateway(Gateway gateway, int nClosestGateway) { VpnProfile profile; + Connection.TransportType transportType = getUsePluggableTransports(this) ? OBFS4 : OPENVPN; if (gateway == null || - (profile = gateway.getProfile(OPENVPN)) == null) { + (profile = gateway.getProfile(transportType)) == null) { return false; } -- cgit v1.2.3 From 84d5cf342d8e085be1996980c005b6c014f20379 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 19 Jul 2019 18:46:41 +0200 Subject: minor cleanup in EIP --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 9431ef61..fd498df8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -223,9 +223,7 @@ public final class EIP extends JobIntentService implements Observer { GatewaysManager gatewaysManager = gatewaysFromPreferences(); Gateway gateway = gatewaysManager.select(0); - if (gateway != null && !gateway.getProfiles().isEmpty()) { - launchActiveGateway(gateway, 0); - } else { + if (!launchActiveGateway(gateway, 0)) { Log.d(TAG, "startEIPAlwaysOnVpn no active profile available!"); } } -- cgit v1.2.3 From fa04548dbdf1403e67682fc984bef9941e2f4c78 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 2 Aug 2019 00:47:26 +0200 Subject: remove unused context from GatewaysManager --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index fd498df8..19c539e8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -288,7 +288,7 @@ public final class EIP extends JobIntentService implements Observer { * @return GatewaysManager */ private GatewaysManager gatewaysFromPreferences() { - GatewaysManager gatewaysManager = new GatewaysManager(this, preferences); + GatewaysManager gatewaysManager = new GatewaysManager(preferences); gatewaysManager.configureFromPreferences(); return gatewaysManager; } -- cgit v1.2.3