diff options
author | cyBerta <cyberta@riseup.net> | 2021-03-16 22:09:07 +0100 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2021-04-22 22:53:01 +0200 |
commit | c02cfd04253c5f5c839410d418789884b9bfb13a (patch) | |
tree | 531b31fa02ca89c0486d1b4afa8a304b7c991177 /app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java | |
parent | a5a3dd31e53b772ccdddd6aaa6125968a894054c (diff) |
Adapt gateway selector to check for nearest gateway within a city. Also optionally parse sortedGateways json object from menshen backend reponse
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java | 15 |
1 files changed, 14 insertions, 1 deletions
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 6b44856e..763b5449 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java @@ -17,6 +17,7 @@ package se.leap.bitmaskclient.eip; import android.content.Context; + import androidx.annotation.NonNull; import com.google.gson.Gson; @@ -59,7 +60,9 @@ public class Gateway { private JSONObject generalConfiguration; private JSONObject secrets; private JSONObject gateway; + private JSONObject load; + // the location of a gateway is its name private String name; private int timezone; private int apiVersion; @@ -71,9 +74,15 @@ public class Gateway { */ public Gateway(JSONObject eipDefinition, JSONObject secrets, JSONObject gateway, Context context) throws ConfigParser.ConfigParseError, JSONException, IOException { + this(eipDefinition, secrets, gateway, null, context); + } + + public Gateway(JSONObject eipDefinition, JSONObject secrets, JSONObject gateway, JSONObject load, Context context) + throws ConfigParser.ConfigParseError, JSONException, IOException { this.gateway = gateway; this.secrets = secrets; + this.load = load; generalConfiguration = getGeneralConfiguration(eipDefinition); timezone = getTimezone(eipDefinition); @@ -82,6 +91,10 @@ public class Gateway { vpnProfiles = createVPNProfiles(context); } + public void updateLoad(JSONObject load) { + this.load = load; + } + private void addProfileInfos(Context context, HashMap<Connection.TransportType, VpnProfile> profiles) { Set<String> excludedAppsVpn = PreferenceHelper.getExcludedApps(context); for (VpnProfile profile : profiles.values()) { @@ -156,7 +169,7 @@ public class Gateway { return vpnProfiles.get(transportType); } - public boolean suppoortsTransport(Connection.TransportType transportType) { + public boolean supportsTransport(Connection.TransportType transportType) { return vpnProfiles.get(transportType) != null; } |