summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2021-11-12 02:13:55 +0000
committercyberta <cyberta@riseup.net>2021-11-12 02:13:55 +0000
commit099b257cd715bd24ef48f4b7d260c6ec9a80eb9a (patch)
treebb324429afeae21c58695c8cda9b519e098f2bc1 /app/src
parentc5d722f555b952407dade3abb1ffd537e6747317 (diff)
parent19fea58c706fac4d5b066d0cdf47fa450f132da0 (diff)
Merge branch 'fix_reconnect' into 'master'
retry all remotes defined in one VpnProfile before switching gateways See merge request leap/bitmask_android!141
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);
}