From bdea6b5469d6a3a136e6a847d1097fbd56ee1053 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 27 Jun 2019 15:57:25 +0200 Subject: use api version 3 for pluggable Transports --- app/src/custom/assets/ptdemo.bitmask.eip-service.json | 4 ++-- .../java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/src/custom/assets/ptdemo.bitmask.eip-service.json b/app/src/custom/assets/ptdemo.bitmask.eip-service.json index 05dc1447..590652d3 100644 --- a/app/src/custom/assets/ptdemo.bitmask.eip-service.json +++ b/app/src/custom/assets/ptdemo.bitmask.eip-service.json @@ -59,6 +59,6 @@ "key-direction" : "1", "verb" : "3" }, - "serial":2, - "version":2 + "serial":3, + "version":3 } \ No newline at end of file diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java index a131bdd8..2214b592 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -58,7 +58,7 @@ public class VpnConfigGenerator { public final static String TAG = VpnConfigGenerator.class.getSimpleName(); private final String newLine = System.getProperty("line.separator"); // Platform new line - public VpnConfigGenerator(JSONObject generalConfiguration, JSONObject secrets, JSONObject gateway, int apiVersion) { + public VpnConfigGenerator(JSONObject generalConfiguration, JSONObject secrets, JSONObject gateway, int apiVersion) throws ConfigParser.ConfigParseError { this.generalConfiguration = generalConfiguration; this.gateway = gateway; this.secrets = secrets; @@ -66,21 +66,22 @@ public class VpnConfigGenerator { checkCapabilities(); } - public void checkCapabilities() { + public void checkCapabilities() throws ConfigParser.ConfigParseError { try { - if (apiVersion == 2) { + if (apiVersion == 3) { JSONArray supportedTransports = gateway.getJSONObject(CAPABILITIES).getJSONArray(TRANSPORT); for (int i = 0; i < supportedTransports.length(); i++) { JSONObject transport = supportedTransports.getJSONObject(i); if (transport.getString(TYPE).equals(OBFS4.toString())) { obfs4Transport = transport; + break; } } } } catch (JSONException e) { - e.printStackTrace(); + throw new ConfigParser.ConfigParseError("Api version ("+ apiVersion +") did not match required JSON fields"); } } @@ -161,9 +162,10 @@ public class VpnConfigGenerator { switch (apiVersion) { default: case 1: + case 2: gatewayConfigApiv1(stringBuilder, ipAddress, capabilities); break; - case 2: + case 3: JSONArray transports = capabilities.getJSONArray(TRANSPORT); gatewayConfigApiv2(transportType, stringBuilder, ipAddress, transports); break; -- cgit v1.2.3