summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2023-04-16 00:23:02 +0200
committercyBerta <cyberta@riseup.net>2023-04-16 00:23:19 +0200
commitc2c3e13455ecfa310711e78aa830d14804aaaa5c (patch)
treeb8b01db0046caac9aa31e1537f3151ee17371c57 /app/src/main/java/se/leap
parent601a77ad059b3da754c3baaf10b01dbc19b927be (diff)
only take experimental transports into consideration in case the user switched the experimental transport toggle
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java5
3 files changed, 16 insertions, 3 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
index 52030ce3..ad95c823 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
@@ -55,6 +55,7 @@ public class GatewaySelector {
return offsets.isEmpty() ? null : offsets.firstEntry().getValue().iterator().next();
}
+ // calculateOffsets randomizes the order of Gateways with the same distance, e.g. from the same location
private TreeMap<Integer, Set<Gateway>> calculateOffsets() {
TreeMap<Integer, Set<Gateway>> offsets = new TreeMap<Integer, Set<Gateway>>();
int localOffset = getCurrentTimezone();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index 28766998..d114665b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -17,6 +17,7 @@
package se.leap.bitmaskclient.eip;
import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4;
+import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4_HOP;
import static de.blinkt.openvpn.core.connection.Connection.TransportType.OPENVPN;
import static de.blinkt.openvpn.core.connection.Connection.TransportType.PT;
import static se.leap.bitmaskclient.base.models.Constants.GATEWAYS;
@@ -121,6 +122,8 @@ public class GatewaysManager {
private ArrayList<Location> locations = new ArrayList<>();
private TransportType selectedTransport;
+ GatewaySelector gatewaySelector;
+
public GatewaysManager(Context context) {
this.context = context;
configureFromCurrentProvider();
@@ -147,7 +150,7 @@ public class GatewaysManager {
}
public GatewayOptions select(int nClosest, String city) {
- TransportType[] transportTypes = getUseBridges(context) ? new TransportType[]{OBFS4} : new TransportType[]{OPENVPN};
+ TransportType[] transportTypes = getUseBridges(context) ? new TransportType[]{OBFS4, OBFS4_HOP} : new TransportType[]{OPENVPN};
if (presortedList.size() > 0) {
return getGatewayFromPresortedList(nClosest, transportTypes, city);
}
@@ -276,7 +279,9 @@ public class GatewaysManager {
private GatewayOptions getGatewayFromTimezoneCalculation(int nClosest, TransportType[] transportTypes, @Nullable String city) {
List<Gateway> list = new ArrayList<>(gateways.values());
- GatewaySelector gatewaySelector = new GatewaySelector(list);
+ if (gatewaySelector == null) {
+ gatewaySelector = new GatewaySelector(list);
+ }
Gateway gateway;
int found = 0;
int i = 0;
@@ -341,7 +346,9 @@ public class GatewaysManager {
private int getPositionFromTimezoneCalculatedList(VpnProfile profile) {
TransportType transportType = profile.getTransportType();
- GatewaySelector gatewaySelector = new GatewaySelector(new ArrayList<>(gateways.values()));
+ if (gatewaySelector == null) {
+ gatewaySelector = new GatewaySelector(new ArrayList<>(gateways.values()));
+ }
Gateway gateway;
int nClosest = 0;
int i = 0;
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 90ffb6b0..2c22d4f7 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
@@ -140,7 +140,12 @@ public class VpnConfigGenerator {
}
if (apiVersion >= 3) {
for (TransportType transportType : transports.keySet()) {
+ Transport transport = transports.get(transportType);
if (transportType.isPluggableTransport()) {
+ Transport.Options transportOptions = transport.getOptions();
+ if (!experimentalTransports && transportOptions != null && transportOptions.isExperimental()) {
+ continue;
+ }
try {
profiles.put(transportType, createProfile(transportType));
} catch (ConfigParser.ConfigParseError | NumberFormatException | JSONException | IOException e) {