diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models')
4 files changed, 159 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/HoppingConfig.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/HoppingConfig.java new file mode 100644 index 00000000..96b8c460 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/HoppingConfig.java @@ -0,0 +1,69 @@ +package se.leap.bitmaskclient.pluggableTransports.models; + +import androidx.annotation.NonNull; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import se.leap.bitmaskclient.base.models.Transport; + +public class HoppingConfig { + + /** + * Enabled bool `json:"enabled"` + * Remotes []string `json:"remotes"` + * Obfs4Certs []string `json:"obfs4_certs"` + * PortSeed int64 `json:"port_seed"` + * PortCount uint `json:"port_count"` + * MinHopSeconds uint `json:"min_hop_seconds"` + * HopJitter uint `json:"hop_jitter"` + * } + */ + + final boolean enabled; + final String proxyAddr; + final String[] remotes; + final String[] obfs4Certs; + final int portSeed; + final int portCount; + final int minHopSeconds; + final int hopJitter; + + public HoppingConfig(boolean enabled, + String proxyAddr, + Obfs4Options options, + int minHopSeconds, + int hopJitter) { + this.enabled = enabled; + this.proxyAddr = proxyAddr; + Transport transport = options.transport; + Transport.Endpoint[] endpoints = transport.getOptions().getEndpoints(); + if (endpoints == null) { + // only port hopping, we assume the gateway IP as hopping PT's IP + this.remotes = new String[]{ options.bridgeIP }; + this.obfs4Certs = new String[] { transport.getOptions().getCert() }; + } else { + // port+ip hopping + this.remotes = new String[endpoints.length]; + this.obfs4Certs = new String[endpoints.length]; + for (int i = 0; i < remotes.length; i++) { + remotes[i] = endpoints[i].getIp(); + obfs4Certs[i] = endpoints[i].getCert(); + } + } + this.portSeed = transport.getOptions().getPortSeed(); + this.portCount = transport.getOptions().getPortCount(); + this.minHopSeconds = minHopSeconds; + this.hopJitter = hopJitter; + } + + @NonNull + @Override + public String toString() { + Gson gson = new GsonBuilder() + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .create(); + return gson.toJson(this); + } +} diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/KcpConfig.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/KcpConfig.java new file mode 100644 index 00000000..255e7dd7 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/KcpConfig.java @@ -0,0 +1,39 @@ +package se.leap.bitmaskclient.pluggableTransports.models; + +import androidx.annotation.NonNull; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class KcpConfig { + + // check OpenVPN's --sndbuf size and --rcvbuf size + public static final int DEFAULT_KCP_SEND_WINDOW_SIZE = 32; + public static final int DEFAULT_KCP_RECEIVE_WINDOW_SIZE = 32; + public static final int DEFAULT_KCP_READ_BUFFER = 16 * 1024 * 1024; + public static final int DEFAULT_KCP_WRITE_BUFFER = 16 * 1024 * 1024; + + final boolean enabled; + final int sendWindowSize; + final int receiveWindowSize; + final int readBuffer; + final int writeBuffer; + + public KcpConfig(boolean enabled) { + this.enabled = enabled; + this.sendWindowSize = DEFAULT_KCP_SEND_WINDOW_SIZE; + this.receiveWindowSize = DEFAULT_KCP_RECEIVE_WINDOW_SIZE; + this.readBuffer = DEFAULT_KCP_READ_BUFFER; + this.writeBuffer = DEFAULT_KCP_WRITE_BUFFER; + } + + @NonNull + @Override + public String toString() { + Gson gson = new GsonBuilder() + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .create(); + return gson.toJson(this); + } +} diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/Obfs4Options.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/Obfs4Options.java new file mode 100644 index 00000000..1eec376a --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/Obfs4Options.java @@ -0,0 +1,16 @@ +package se.leap.bitmaskclient.pluggableTransports.models; + +import java.io.Serializable; + +import se.leap.bitmaskclient.base.models.Transport; + +public class Obfs4Options implements Serializable { + public String bridgeIP; + public Transport transport; + + public Obfs4Options(String bridgeIP, + Transport transport) { + this.bridgeIP = bridgeIP; + this.transport = transport; + } +} diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/ObfsvpnConfig.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/ObfsvpnConfig.java new file mode 100644 index 00000000..9f85c4a0 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/models/ObfsvpnConfig.java @@ -0,0 +1,35 @@ +package se.leap.bitmaskclient.pluggableTransports.models; + +import androidx.annotation.NonNull; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class ObfsvpnConfig { + + final String proxyAddr; + final HoppingConfig hoppingConfig; + final KcpConfig kcpConfig; + final String remoteIp; + final String remotePort; + final String obfs4Cert; + + public ObfsvpnConfig(String proxyAddress, HoppingConfig hoppingConfig, KcpConfig kcpConfig, String remoteIP, String remotePort, String obfsv4Cert) { + this.proxyAddr = proxyAddress; + this.hoppingConfig = hoppingConfig; + this.kcpConfig = kcpConfig; + this.remoteIp = remoteIP; + this.remotePort = remotePort; + this.obfs4Cert = obfsv4Cert; + } + + @NonNull + @Override + public String toString() { + Gson gson = new GsonBuilder() + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .create(); + return gson.toJson(this); + } +} |