From f0899797c8907d1ebcba205dad69f2a8a6594bcd Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 5 Aug 2022 18:15:25 +0200 Subject: revert gateway selection during gateway pinning --- .../base/fragments/ObfuscationProxyDialog.java | 24 +--------------------- .../leap/bitmaskclient/base/models/Constants.java | 2 -- .../bitmaskclient/base/utils/ConfigHelper.java | 8 +------- .../bitmaskclient/base/utils/PreferenceHelper.java | 22 +------------------- 4 files changed, 3 insertions(+), 53 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base') 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 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 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); } -- cgit v1.2.3 From 2fca50dee326ce6bd24f54a355f5c5ded0dbbf7f Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 5 Aug 2022 18:16:33 +0200 Subject: don't show load during obfuscation proxy pinning --- app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index d993a119..ded62fa6 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -467,7 +467,7 @@ public class EipFragment extends Fragment implements Observer { setMainButtonEnabled(true); mainButton.updateState(true, false, false); Connection.TransportType transportType = PreferenceHelper.getUseBridges(getContext()) ? Connection.TransportType.OBFS4 : Connection.TransportType.OPENVPN; - locationButton.setLocationLoad(gatewaysManager.getLoadForLocation(VpnStatus.getLastConnectedVpnName(), transportType)); + locationButton.setLocationLoad(PreferenceHelper.useObfuscationPinning(getContext()) ? GatewaysManager.Load.UNKNOWN : gatewaysManager.getLoadForLocation(VpnStatus.getLastConnectedVpnName(), transportType)); locationButton.setText(VpnStatus.getLastConnectedVpnName()); locationButton.showBridgeIndicator(VpnStatus.isUsingBridges()); locationButton.showRecommendedIndicator(getPreferredCity(getContext())== null); -- cgit v1.2.3 From d8a94fe975f85a17debcc5f4035299e639c4b3f3 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 5 Aug 2022 18:17:24 +0200 Subject: don't use preferred city while obfuscation proxy pinning --- .../main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base') 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 eebae87a..4abeed1a 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 @@ -337,7 +337,7 @@ public class PreferenceHelper { } public static String getPreferredCity(Context context) { - return getString(context, PREFERRED_CITY, null); + return useObfuscationPinning(context) ? null : getString(context, PREFERRED_CITY, null); } @WorkerThread -- cgit v1.2.3 From 5d9072d9739882386fe30419a25ceb80166a5990 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 5 Aug 2022 18:26:34 +0200 Subject: localize 'Unknown Location' --- .../se/leap/bitmaskclient/base/fragments/ObfuscationProxyDialog.java | 1 + 1 file changed, 1 insertion(+) (limited to 'app/src/main/java/se/leap/bitmaskclient/base') 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 e2247e1e..6829d9f1 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 @@ -68,6 +68,7 @@ public class ObfuscationProxyDialog extends AppCompatDialogFragment { PreferenceHelper.setObfuscationPinningCert(v.getContext(), cert); PreferenceHelper.setObfuscationPinningKCP(v.getContext(), kcpSwitch.isChecked()); PreferenceHelper.setUseObfuscationPinning(v.getContext(), ip != null && port != null && cert != null); + PreferenceHelper.setObfuscationPinningGatewayLocation(v.getContext(), gatewaysManager.getLocationNameForIP(ip, v.getContext())); dismiss(); }); -- cgit v1.2.3 From 598105bbaa383b27cadb682b76cdf00e5ad58369 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 5 Aug 2022 18:40:27 +0200 Subject: add missing GatewayJson class --- .../bitmaskclient/base/models/GatewayJson.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java (limited to 'app/src/main/java/se/leap/bitmaskclient/base') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java b/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java new file mode 100644 index 00000000..8aca58c6 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java @@ -0,0 +1,61 @@ +package se.leap.bitmaskclient.base.models; + +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.SerializedName; + +import org.json.JSONObject; + +public class GatewayJson { + private String location; + @SerializedName(value = "ip_address") + private String ipAddress; + @SerializedName(value = "ip_address6") + private String ipAddress6; + private String host; + private Capabilities capabilities; + + public GatewayJson(String location, String ipAddress, String ipAddress6, String host, Capabilities capabilities) { + this.location = location; + this.ipAddress = ipAddress; + this.ipAddress6 = ipAddress6; + this.host = host; + this.capabilities = capabilities; + } + + @NonNull + @Override + public String toString() { + return new Gson().toJson(this); + } + + public static GatewayJson fromJson(JSONObject json) { + GsonBuilder builder = new GsonBuilder(); + return builder.create().fromJson(json.toString(), GatewayJson.class); + } + + public static class Capabilities { + private Boolean adblock; + @SerializedName(value = "filter_dns") + private Boolean filterDns; + private Boolean limited; + private Transport[] transport; + @SerializedName(value = "user_ips") + private Boolean userIps; + + public Capabilities(Boolean adblock, Boolean filterDns, Boolean limited, Transport[] transport, Boolean userIps) { + this.adblock = adblock; + this.filterDns = filterDns; + this.limited = limited; + this.transport = transport; + this.userIps = userIps; + } + @NonNull + @Override + public String toString() { + return new Gson().toJson(this); + } + } +} -- cgit v1.2.3