diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/base')
3 files changed, 126 insertions, 8 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java index ee5bd2a7..57467974 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Constants.java @@ -179,10 +179,19 @@ public interface Constants { String PORTS = "ports"; String PROTOCOLS = "protocols"; String UDP = "udp"; + String TCP = "tcp"; + String KCP = "kcp"; String CAPABILITIES = "capabilities"; String TRANSPORT = "transport"; String TYPE = "type"; String OPTIONS = "options"; + String IAT_MODE = "iatMode"; + String CERT = "cert"; + String CERTS = "certs"; + String ENDPOINTS = "endpoints"; + String PORT_SEED = "port_seed"; + String PORT_COUNT = "port_count"; + String EXPERIMENTAL = "experimental"; String VERSION = "version"; String NAME = "name"; String TIMEZONE = "timezone"; diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java index 62fb1fd2..57653263 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Provider.java @@ -19,6 +19,7 @@ package se.leap.bitmaskclient.base.models; import static de.blinkt.openvpn.core.connection.Connection.TransportProtocol.KCP; import static de.blinkt.openvpn.core.connection.Connection.TransportProtocol.TCP; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; +import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4_HOP; import static se.leap.bitmaskclient.base.models.Constants.CAPABILITIES; import static se.leap.bitmaskclient.base.models.Constants.GATEWAYS; import static se.leap.bitmaskclient.base.models.Constants.LOCATIONS; @@ -184,13 +185,13 @@ public final class Provider implements Parcelable { public boolean supportsPluggableTransports() { if (useObfsVpn()) { - return supportsTransports(new Pair[]{new Pair<>(OBFS4, TCP), new Pair<>(OBFS4, KCP)}); + return supportsTransports(new Pair[]{new Pair<>(OBFS4, TCP), new Pair<>(OBFS4, KCP), new Pair<>(OBFS4_HOP, TCP), new Pair<>(OBFS4_HOP, KCP)}); } return supportsTransports(new Pair[]{new Pair<>(OBFS4, TCP)}); } public boolean supportsExperimentalPluggableTransports() { - return supportsTransports(new Pair[]{new Pair<>(OBFS4, KCP)}); + return supportsTransports(new Pair[]{new Pair<>(OBFS4, KCP), new Pair<>(OBFS4_HOP, TCP), new Pair<>(OBFS4_HOP, KCP)}); } private boolean supportsTransports(Pair<TransportType, TransportProtocol>[] transportTypes) { diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Transport.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Transport.java index 90a033dd..7d9b61a7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/models/Transport.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Transport.java @@ -1,21 +1,57 @@ package se.leap.bitmaskclient.base.models; +import androidx.annotation.Nullable; + +import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.annotations.SerializedName; import org.json.JSONObject; -public class Transport { +import java.io.Serializable; + +import de.blinkt.openvpn.core.connection.Connection; + +public class Transport implements Serializable { private String type; private String[] protocols; + @Nullable private String[] ports; + @Nullable private Options options; public Transport(String type, String[] protocols, String[] ports, String cert) { + this(type, protocols, ports, new Options(cert, "0")); + } + + public Transport(String type, String[] protocols, String[] ports, Options options) { this.type = type; this.protocols = protocols; this.ports = ports; - this.options = new Options(cert); + this.options = options; + } + + public String getType() { + return type; + } + + public Connection.TransportType getTransportType() { + return Connection.TransportType.fromString(type); + } + + public String[] getProtocols() { + return protocols; + } + + @Nullable + public String[] getPorts() { + return ports; + } + + @Nullable + public Options getOptions() { + return options; } @Override @@ -25,16 +61,65 @@ public class Transport { public static Transport fromJson(JSONObject json) { GsonBuilder builder = new GsonBuilder(); - return builder.create().fromJson(json.toString(), Transport.class); + return builder. + setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES). + create(). + fromJson(json.toString(), Transport.class); } - public static class Options { + public static class Options implements Serializable { + @Nullable private String cert; + @SerializedName("iatMode") private String iatMode; - public Options(String cert) { + @Nullable + private Endpoint[] endpoints; + + private boolean experimental; + + private int portSeed; + + private int portCount; + + + public Options(String cert, String iatMode) { this.cert = cert; - this.iatMode = "0"; + this.iatMode = iatMode; + } + + public Options(String iatMode, Endpoint[] endpoints, int portSeed, int portCount, boolean experimental) { + this.iatMode = iatMode; + this.endpoints = endpoints; + this.portSeed = portSeed; + this.portCount = portCount; + this.experimental = experimental; + } + + @Nullable + public String getCert() { + return cert; + } + + public String getIatMode() { + return iatMode; + } + + @Nullable + public Endpoint[] getEndpoints() { + return endpoints; + } + + public boolean isExperimental() { + return experimental; + } + + public int getPortSeed() { + return portSeed; + } + + public int getPortCount() { + return portCount; } @Override @@ -44,6 +129,29 @@ public class Transport { } + public static class Endpoint implements Serializable { + private String ip; + private String cert; + + public Endpoint(String ip, String cert) { + this.ip = ip; + this.cert = cert; + } + + @Override + public String toString() { + return new Gson().toJson(this); + } + + public String getIp() { + return ip; + } + + public String getCert() { + return cert; + } + } + } |