summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-07-04 16:44:35 +0200
committercyBerta <cyberta@riseup.net>2019-08-02 01:49:37 +0200
commit283e7531d551521dc48efa9b010127ff54316326 (patch)
tree79682df8fae07b85a583d059a6c7a4f82fb8afe6 /app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
parent2a8bb775183dd08388460c711dc650d3110ca76c (diff)
create one vpnprofile per transport per gateway. implement basis to switch between obfs4 and plain openvpn connections
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java19
1 files changed, 10 insertions, 9 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 18c557dc..6b76e8d9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
@@ -22,6 +22,7 @@ import org.json.JSONObject;
import java.io.IOException;
import java.io.StringReader;
+import java.util.HashMap;
import java.util.Iterator;
import de.blinkt.openvpn.VpnProfile;
@@ -52,8 +53,6 @@ public class VpnConfigGenerator {
private JSONObject obfs4Transport;
private int apiVersion;
- private ConfigParser icsOpenvpnConfigParser = new ConfigParser();
-
public final static String TAG = VpnConfigGenerator.class.getSimpleName();
private final String newLine = System.getProperty("line.separator"); // Platform new line
@@ -85,16 +84,17 @@ public class VpnConfigGenerator {
}
}
- public VpnProfile generateVpnProfile() throws IllegalStateException,
- IOException,
+ public HashMap<Connection.TransportType, VpnProfile> generateVpnProfiles() throws
ConfigParser.ConfigParseError,
- NumberFormatException, JSONException {
-
+ NumberFormatException,
+ JSONException,
+ IOException {
+ HashMap<Connection.TransportType, VpnProfile> profiles = new HashMap<>();
+ profiles.put(OPENVPN, createProfile(OPENVPN));
if (supportsObfs4()) {
- return createProfile(OBFS4);
+ profiles.put(OBFS4, createProfile(OBFS4));
}
-
- return createProfile(OPENVPN);
+ return profiles;
}
private boolean supportsObfs4(){
@@ -113,6 +113,7 @@ public class VpnConfigGenerator {
private VpnProfile createProfile(Connection.TransportType transportType) throws IOException, ConfigParser.ConfigParseError, JSONException {
String configuration = getConfigurationString(transportType);
+ ConfigParser icsOpenvpnConfigParser = new ConfigParser();
icsOpenvpnConfigParser.parseConfig(new StringReader(configuration));
if (transportType == OBFS4) {
icsOpenvpnConfigParser.setDispatcherOptions(getDispatcherOptions());