summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java28
2 files changed, 20 insertions, 12 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
index 589fa751..f3eea415 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
@@ -157,6 +157,10 @@ public class Gateway {
return vpnProfiles.get(transportType);
}
+ public boolean suppoortsTransport(Connection.TransportType transportType) {
+ return vpnProfiles.get(transportType) != null;
+ }
+
public int getTimezone() {
return timezone;
}
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 f3773758..0515a35e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -84,7 +84,7 @@ public class GatewaysManager {
int found = 0;
int i = 0;
while ((gateway = gatewaySelector.select(i)) != null) {
- if (gateway.getProfile(transportType) != null) {
+ if (gateway.suppoortsTransport(transportType)) {
if (found == nClosest) {
return gateway;
}
@@ -98,7 +98,7 @@ public class GatewaysManager {
private Gateway getGatewayFromPresortedList(int nClosest, Connection.TransportType transportType) {
int found = 0;
for (Gateway gateway : presortedList) {
- if (gateway.getProfile(transportType) != null) {
+ if (gateway.suppoortsTransport(transportType)) {
if (found == nClosest) {
return gateway;
}
@@ -123,14 +123,14 @@ public class GatewaysManager {
private int getPositionFromPresortedList(VpnProfile profile) {
Connection.TransportType transportType = profile.mUsePluggableTransports ? OBFS4 : OPENVPN;
- Gateway gateway;
int nClosest = 0;
- while ((nClosest < presortedList.size())) {
- gateway = presortedList.get(nClosest);
- if (profile.equals(gateway.getProfile(transportType))) {
- return nClosest;
+ for (Gateway gateway : presortedList) {
+ if (gateway.suppoortsTransport(transportType)) {
+ if (profile.equals(gateway.getProfile(transportType))) {
+ return nClosest;
+ }
+ nClosest++;
}
- nClosest++;
}
return -1;
}
@@ -140,11 +140,15 @@ public class GatewaysManager {
GatewaySelector gatewaySelector = new GatewaySelector(new ArrayList<>(gateways.values()));
Gateway gateway;
int nClosest = 0;
- while ((gateway = gatewaySelector.select(nClosest)) != null) {
- if (profile.equals(gateway.getProfile(transportType))) {
- return nClosest;
+ int i = 0;
+ while ((gateway = gatewaySelector.select(i)) != null) {
+ if (gateway.suppoortsTransport(transportType)) {
+ if (profile.equals(gateway.getProfile(transportType))) {
+ return nClosest;
+ }
+ nClosest++;
}
- nClosest++;
+ i++;
}
return -1;
}