summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-08-05 18:15:25 +0200
committercyBerta <cyberta@riseup.net>2022-08-05 18:15:25 +0200
commitf0899797c8907d1ebcba205dad69f2a8a6594bcd (patch)
treeaaad402387f6510ef796c3eeade78f33ebf27a70 /app/src/main/java/se/leap
parent66d9dd4b2b46ed98e811c31152b2d04e3ccbe771 (diff)
revert gateway selection during gateway pinning
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java24
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java22
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java6
5 files changed, 5 insertions, 57 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java
index df78214d..e2247e1e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java
@@ -31,12 +31,10 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment {
AppCompatEditText ipField;
AppCompatEditText portField;
AppCompatEditText certificateField;
- AppCompatSpinner gatewayHost;
AppCompatButton saveButton;
AppCompatButton useDefaultsButton;
AppCompatButton cancelButton;
IconSwitchEntry kcpSwitch;
- ArrayAdapter<String> gatewayHosts;
@NonNull
@Override
@@ -49,7 +47,6 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment {
ipField = binding.ipField;
portField = binding.portField;
certificateField = binding.certField;
- gatewayHost = binding.gatewayHost;
saveButton = binding.buttonSave;
useDefaultsButton = binding.buttonDefaults;
cancelButton = binding.buttonCancel;
@@ -61,16 +58,6 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment {
kcpSwitch.setChecked(PreferenceHelper.getObfuscationPinningKCP(getContext()));
GatewaysManager gatewaysManager = new GatewaysManager(getContext());
- ArrayList<String> hostsList = gatewaysManager.getHosts();
-
- hostsList.add(0, "Select a Gateway");
- gatewayHosts = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, hostsList);
- gatewayHosts.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- gatewayHost.setAdapter(gatewayHosts);
- String selectedHost = PreferenceHelper.getObfuscationPinningGatewayHost(getContext());
- if (selectedHost != null) {
- gatewayHost.setSelection(gatewayHosts.getPosition(selectedHost));
- }
saveButton.setOnClickListener(v -> {
String ip = TextUtils.isEmpty(ipField.getText()) ? null : ipField.getText().toString();
@@ -79,12 +66,8 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment {
PreferenceHelper.setObfuscationPinningPort(v.getContext(), port);
String cert = TextUtils.isEmpty(certificateField.getText()) ? null : certificateField.getText().toString();
PreferenceHelper.setObfuscationPinningCert(v.getContext(), cert);
- String gatewayHostName = gatewayHost.getSelectedItemPosition() == 0 ? null : gatewayHosts.getItem(gatewayHost.getSelectedItemPosition());
- PreferenceHelper.setObfuscationPinningGatewayHost(v.getContext(), gatewayHostName);
- PreferenceHelper.setObfuscationPinningGatewayIP(v.getContext(), gatewaysManager.getIpForHost(gatewayHostName));
PreferenceHelper.setObfuscationPinningKCP(v.getContext(), kcpSwitch.isChecked());
- PreferenceHelper.setUseObfuscationPinning(v.getContext(), ip != null && port != null && cert != null && gatewayHostName != null);
- PreferenceHelper.setObfuscationPinningGatewayLocation(v.getContext(), gatewaysManager.getLocationNameForHost(gatewayHostName));
+ PreferenceHelper.setUseObfuscationPinning(v.getContext(), ip != null && port != null && cert != null);
dismiss();
});
@@ -93,11 +76,6 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment {
ipField.setText(ObfsVpnHelper.obfsvpnIP());
portField.setText(ObfsVpnHelper.obfsvpnPort());
certificateField.setText(ObfsVpnHelper.obfsvpnCert());
- int position = gatewayHosts.getPosition(ObfsVpnHelper.gatewayHost());
- if (position == -1) {
- position = 0;
- }
- gatewayHost.setSelection(position);
kcpSwitch.setChecked(ObfsVpnHelper.useKcp());
});
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java
index 8fbac35e..fd9f2a9b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java
@@ -50,8 +50,6 @@ public interface Constants {
String OBFUSCATION_PINNING_PORT = "obfuscation_pinning_port";
String OBFUSCATION_PINNING_CERT = "obfuscation_pinning_cert";
String OBFUSCATION_PINNING_KCP = "obfuscation_pinning_udp";
- String OBFUSCATION_PINNING_GW_HOST = "obfuscation_pinning_gw_host";
- String OBFUSCATION_PINNING_GW_IP = "obfuscation_pinning_gw_ip";
String OBFUSCATION_PINNING_LOCATION = "obfuscation_pinning_location";
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
index c4e2fb17..91894fb8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
@@ -290,11 +290,9 @@ public class ConfigHelper {
return BuildConfig.obfsvpn_ip != null &&
BuildConfig.obfsvpn_port != null &&
BuildConfig.obfsvpn_cert != null &&
- BuildConfig.obfsvpn_gateway_host != null &&
!BuildConfig.obfsvpn_ip.isEmpty() &&
!BuildConfig.obfsvpn_port.isEmpty() &&
- !BuildConfig.obfsvpn_cert.isEmpty() &&
- !BuildConfig.obfsvpn_gateway_host.isEmpty();
+ !BuildConfig.obfsvpn_cert.isEmpty();
}
public static String obfsvpnIP() {
return BuildConfig.obfsvpn_ip;
@@ -305,10 +303,6 @@ public class ConfigHelper {
public static String obfsvpnCert() {
return BuildConfig.obfsvpn_cert;
}
- public static String gatewayHost() {
- return BuildConfig.obfsvpn_gateway_host;
- }
-
public static boolean useKcp() {
return BuildConfig.obfsvpn_use_kcp;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
index d9beffd3..eebae87a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
@@ -12,8 +12,6 @@ import static se.leap.bitmaskclient.base.models.Constants.GATEWAY_PINNING;
import static se.leap.bitmaskclient.base.models.Constants.LAST_UPDATE_CHECK;
import static se.leap.bitmaskclient.base.models.Constants.LAST_USED_PROFILE;
import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_CERT;
-import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_GW_HOST;
-import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_GW_IP;
import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_IP;
import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_KCP;
import static se.leap.bitmaskclient.base.models.Constants.OBFUSCATION_PINNING_LOCATION;
@@ -279,8 +277,7 @@ public class PreferenceHelper {
getBoolean(context, USE_OBFUSCATION_PINNING, false) &&
!TextUtils.isEmpty(getObfuscationPinningIP(context)) &&
!TextUtils.isEmpty(getObfuscationPinningCert(context)) &&
- !TextUtils.isEmpty(getObfuscationPinningPort(context)) &&
- !TextUtils.isEmpty(getObfuscationPinningGatewayHost(context));
+ !TextUtils.isEmpty(getObfuscationPinningPort(context));
}
public static void setObfuscationPinningIP(Context context, String ip) {
@@ -307,23 +304,6 @@ public class PreferenceHelper {
return getString(context, OBFUSCATION_PINNING_CERT, null);
}
- public static void setObfuscationPinningGatewayHost(Context context, String gatewayIP) {
- putString(context, OBFUSCATION_PINNING_GW_HOST, gatewayIP);
- }
-
- public static String getObfuscationPinningGatewayHost(Context context) {
- return getString(context, OBFUSCATION_PINNING_GW_HOST, null);
- }
-
-
- public static void setObfuscationPinningGatewayIP(Context context, String ipForHost) {
- putString(context, OBFUSCATION_PINNING_GW_IP, ipForHost);
- }
-
- public static String getObfuscationPinningGatewayIP(Context context) {
- return getString(context, OBFUSCATION_PINNING_GW_IP, null);
- }
-
public static void setObfuscationPinningGatewayLocation(Context context, String location) {
putString(context, OBFUSCATION_PINNING_LOCATION, location);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
index ff1dd05e..929935eb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
@@ -29,8 +29,6 @@ import static se.leap.bitmaskclient.base.models.Constants.VERSION;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.allowExperimentalTransports;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getExcludedApps;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningCert;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningGatewayHost;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningGatewayIP;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningGatewayLocation;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningIP;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getObfuscationPinningKCP;
@@ -50,11 +48,11 @@ import org.json.JSONObject;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Set;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ConfigParser;
import de.blinkt.openvpn.core.connection.Connection;
+import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.base.utils.ConfigHelper;
/**
@@ -112,9 +110,9 @@ public class Gateway {
config.experimentalTransports = allowExperimentalTransports(context);
config.excludedApps = getExcludedApps(context);
+ config.remoteGatewayIP = config.useObfuscationPinning ? getObfuscationPinningIP(context) : gateway.optString(IP_ADDRESS);
config.useObfuscationPinning = useObfuscationPinning(context);
config.profileName = config.useObfuscationPinning ? getObfuscationPinningGatewayLocation(context) : locationAsName(eipDefinition);
- config.remoteGatewayIP = config.useObfuscationPinning ? getObfuscationPinningGatewayIP(context) : gateway.optString(IP_ADDRESS);
if (config.useObfuscationPinning) {
config.obfuscationProxyIP = getObfuscationPinningIP(context);
config.obfuscationProxyPort = getObfuscationPinningPort(context);