summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-06-27 15:57:25 +0200
committercyBerta <cyberta@riseup.net>2019-08-02 01:49:37 +0200
commitbdea6b5469d6a3a136e6a847d1097fbd56ee1053 (patch)
tree0635e939781c056009370650bf597cc17ad3e12c /app/src/main
parent8f7146a89fba31bcb9a204415a38e796cfa7d403 (diff)
use api version 3 for pluggable Transports
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java12
1 files changed, 7 insertions, 5 deletions
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;