From bf7fd8510e29687c9bce591dc40f03c1f5577875 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 11 Jun 2022 01:16:39 +0200 Subject: improve gateway pinning: continue parsing presorted gateway lists in debug builds, if no gateway was pinned --- .../main/java/se/leap/bitmaskclient/eip/GatewaysManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java index 7fc810cc..d573e70c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java @@ -420,9 +420,10 @@ public class GatewaysManager { private void configureFromCurrentProvider() { Provider provider = ProviderObservable.getInstance().getCurrentProvider(); parseDefaultGateways(provider); - if (BuildConfig.BUILD_TYPE.equals("debug")) { - keepOnlyPinnedGateway(); - } else if (hasSortedGatewaysWithLoad(provider)) { + if (BuildConfig.BUILD_TYPE.equals("debug") && handleGatewayPinning()) { + return; + } + if (hasSortedGatewaysWithLoad(provider)) { parseGatewaysWithLoad(provider); } else { parseSimpleGatewayList(provider); @@ -430,16 +431,17 @@ public class GatewaysManager { } - private void keepOnlyPinnedGateway() { + private boolean handleGatewayPinning() { String host = PreferenceHelper.getPinnedGateway(this.context); if (host == null) { - return; + return false; } Gateway gateway = gateways.get(host); gateways.clear(); if (gateway != null) { gateways.put(host, gateway); } + return true; } } -- cgit v1.2.3 From 899c19a87260a708d11e095083077daf42fa5c37 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 11 Jun 2022 01:37:44 +0200 Subject: show ConfigParseErrors in log view --- app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java index d573e70c..a11c7e34 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java @@ -339,9 +339,11 @@ public class GatewaysManager { if (gateways.get(aux.getHost()) == null) { addGateway(aux); } - } catch (JSONException | ConfigParser.ConfigParseError | IOException e) { + } catch (JSONException | IOException e) { e.printStackTrace(); VpnStatus.logError("Unable to parse gateway config!"); + } catch (ConfigParser.ConfigParseError e) { + VpnStatus.logError("Unable to parse gateway config: " + e.getLocalizedMessage()); } } } catch (NullPointerException npe) { -- cgit v1.2.3