summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-07-15 22:08:57 +0200
committercyBerta <cyberta@riseup.net>2022-07-19 00:06:12 +0200
commit472a3fdb9c9036f5666e65b5dfd9bd91a51563f8 (patch)
tree42d36b0adf658f41add285e48204ecd5b1ee5206 /app/src/main/java/se/leap
parent93c7fd8c592a85341e8dff594ba1ec535aa103c2 (diff)
add UI to enable experimental kcp transport if the client uses obfsvpn instead of shapeshifter and the provider supports the kcp variant
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java21
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java27
2 files changed, 44 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java
index f4531ff8..94f737b4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java
@@ -9,12 +9,15 @@ import static se.leap.bitmaskclient.base.models.Constants.PREFER_UDP;
import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES;
import static se.leap.bitmaskclient.base.models.Constants.USE_IPv6_FIREWALL;
+import static se.leap.bitmaskclient.base.utils.ConfigHelper.ObfsVpnHelper.useObfsVpn;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.allowExperimentalTransports;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferUDP;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getShowAlwaysOnDialog;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getUseBridges;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getUseSnowflake;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.hasSnowflakePrefs;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.preferUDP;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.setAllowExperimentalTransports;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.useBridges;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.useSnowflake;
import static se.leap.bitmaskclient.base.utils.ViewHelper.setActionBarTitle;
@@ -81,6 +84,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh
initFirewallEntry(view);
initTetheringEntry(view);
initGatewayPinningEntry(view);
+ initExperimentalTransportsEntry(view);
setActionBarTitle(this, advanced_settings);
return view;
}
@@ -249,6 +253,23 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh
});
}
+ public void initExperimentalTransportsEntry(View rootView) {
+ IconSwitchEntry experimentalTransports = rootView.findViewById(R.id.experimental_transports);
+ if (useObfsVpn() && ProviderObservable.getInstance().getCurrentProvider().supportsExperimentalPluggableTransports()) {
+ experimentalTransports.setVisibility(VISIBLE);
+ experimentalTransports.setChecked(allowExperimentalTransports(this.getContext()));
+ experimentalTransports.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ if (!buttonView.isPressed()) {
+ return;
+ }
+ setAllowExperimentalTransports(getContext(), isChecked);
+ });
+ } else {
+ experimentalTransports.setVisibility(GONE);
+ }
+
+ }
+
public void showTetheringAlert() {
try {
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java
index 02a9694a..7b8f22af 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java
@@ -30,6 +30,7 @@ import java.net.URL;
import java.util.Locale;
import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4;
+import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4_KCP;
import static se.leap.bitmaskclient.base.models.Constants.CAPABILITIES;
import static se.leap.bitmaskclient.base.models.Constants.GATEWAYS;
import static se.leap.bitmaskclient.base.models.Constants.LOCATIONS;
@@ -37,8 +38,12 @@ import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_ALLOWED_REGIS
import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_ALLOW_ANONYMOUS;
import static se.leap.bitmaskclient.base.models.Constants.TRANSPORT;
import static se.leap.bitmaskclient.base.models.Constants.TYPE;
+import static se.leap.bitmaskclient.base.utils.ConfigHelper.ObfsVpnHelper.useObfsVpn;
import static se.leap.bitmaskclient.providersetup.ProviderAPI.ERRORS;
+import de.blinkt.openvpn.core.connection.Connection;
+import de.blinkt.openvpn.core.connection.Connection.TransportType;
+
/**
* @author Sean Leonard <meanderingcode@aetherislands.net>
* @author Parménides GV <parmegv@sdf.org>
@@ -161,6 +166,17 @@ public final class Provider implements Parcelable {
}
public boolean supportsPluggableTransports() {
+ if (useObfsVpn()) {
+ return supportsTransports(new TransportType[]{OBFS4, OBFS4_KCP});
+ }
+ return supportsTransports(new TransportType[]{OBFS4});
+ }
+
+ public boolean supportsExperimentalPluggableTransports() {
+ return supportsTransports(new TransportType[]{OBFS4_KCP});
+ }
+
+ private boolean supportsTransports(TransportType[] transportTypes) {
try {
JSONArray gatewayJsons = eipServiceJson.getJSONArray(GATEWAYS);
for (int i = 0; i < gatewayJsons.length(); i++) {
@@ -168,15 +184,18 @@ public final class Provider implements Parcelable {
getJSONObject(CAPABILITIES).
getJSONArray(TRANSPORT);
for (int j = 0; j < transports.length(); j++) {
- if (OBFS4.toString().equals(transports.getJSONObject(j).getString(TYPE))) {
- return true;
+ String supportedTransportType = transports.getJSONObject(j).getString(TYPE);
+ for (TransportType transportType : transportTypes) {
+ if (transportType.toString().equals(supportedTransportType)) {
+ return true;
+ }
}
}
}
} catch (Exception e) {
- // ignore
+ // ignore
}
- return false;
+ return false;
}
public String getIpForHostname(String host) {