summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-11-09 22:13:13 +0100
committercyBerta <cyberta@riseup.net>2021-11-12 01:56:55 +0100
commit19fea58c706fac4d5b066d0cdf47fa450f132da0 (patch)
treebb324429afeae21c58695c8cda9b519e098f2bc1 /app/src
parentc5d722f555b952407dade3abb1ffd537e6747317 (diff)
retry all remotes defined in one VpnProfile before switching gateways
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
index 023a1ce1..4e5016f0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
@@ -89,6 +89,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
private Context context;
private VpnProfile setupVpnProfile;
private String observedProfileFromVpnStatus;
+ AtomicInteger reconnectTry = new AtomicInteger();
AtomicBoolean changingGateway = new AtomicBoolean(false);
AtomicInteger setupNClosestGateway = new AtomicInteger();
private Vector<EipSetupListener> listeners = new Vector<>();
@@ -331,9 +332,12 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
if (ConnectionStatus.LEVEL_STOPPING == level) {
finishGatewaySetup(false);
} else if ("CONNECTRETRY".equals(state) && LEVEL_CONNECTING_NO_SERVER_REPLY_YET.equals(level)) {
- Log.e(TAG, "Timeout reached! Try next gateway!");
- VpnStatus.logError("Timeout reached! Try next gateway!");
- selectNextGateway();
+ // mConnections.length is the amount of remotes defined in the current profile
+ if (reconnectTry.addAndGet(1) == setupVpnProfile.mConnections.length) {
+ Log.e(TAG, "Timeout reached! Try next gateway!");
+ VpnStatus.logError("Timeout reached! Try next gateway!");
+ selectNextGateway();
+ }
} else if ("NOPROCESS".equals(state) && LEVEL_NOTCONNECTED == level) {
//??
} else if ("CONNECTED".equals(state)) {
@@ -359,6 +363,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
private void selectNextGateway() {
changingGateway.set(true);
+ reconnectTry.set(0);
EipCommand.startVPN(context.getApplicationContext(), false, setupNClosestGateway.get() + 1);
}
@@ -368,6 +373,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
setupNClosestGateway.set(0);
observedProfileFromVpnStatus = null;
this.changingGateway.set(changingGateway);
+ this.reconnectTry.set(0);
if (TorStatusObservable.getStatus() != OFF) {
TorServiceCommand.stopTorServiceAsync(context);
}