summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-01-17 16:52:21 +0100
committerAndrej Mihajlov <and@mullvad.net>2019-01-17 16:52:21 +0100
commitf0d82589347e0bbbfd87a47cafe76da93f0635ff (patch)
treeeed29c28b23e208f1e63a213bdce76755da9aecd
parentae4ed32adc625ddb54e62bd9f1d13cec46389564 (diff)
parent10c40f236045ff3f4dbb000ac29e90828ef12627 (diff)
downloadmullvadvpn-f0d82589347e0bbbfd87a47cafe76da93f0635ff.tar.xz
mullvadvpn-f0d82589347e0bbbfd87a47cafe76da93f0635ff.zip
Merge branch 'auto-connect-once'
-rw-r--r--gui/packages/desktop/src/renderer/app.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js
index 7235a6a836..ec2edd2571 100644
--- a/gui/packages/desktop/src/renderer/app.js
+++ b/gui/packages/desktop/src/renderer/app.js
@@ -61,6 +61,7 @@ export default class AppRenderer {
_tunnelState: TunnelStateTransition;
_settings: Settings;
_connectedToDaemon = false;
+ _autoConnected = false;
constructor() {
const store = configureStore(null, this._memoryHistory);
@@ -385,6 +386,7 @@ export default class AppRenderer {
// set the appropriate start view
await this._setStartView();
+
// try to autoconnect the tunnel
await this._autoConnect();
}
@@ -451,20 +453,23 @@ export default class AppRenderer {
}
async _autoConnect() {
- const accountToken = this._settings.accountToken;
-
- if (accountToken) {
- if (process.env.NODE_ENV === 'development') {
- log.debug('Skip autoconnect in development');
- } else if (!this._getAutoConnect()) {
- log.debug('Skip autoconnect because GUI setting is disabled');
- } else {
+ if (process.env.NODE_ENV === 'development') {
+ log.debug('Skip autoconnect in development');
+ } else if (this._autoConnected) {
+ log.debug('Skip autoconnect because it was done before');
+ } else if (this._settings.accountToken) {
+ if (this._getAutoConnect()) {
try {
log.debug('Autoconnect the tunnel');
+
await this.connectTunnel();
+
+ this._autoConnected = true;
} catch (error) {
log.error(`Failed to autoconnect the tunnel: ${error.message}`);
}
+ } else {
+ log.debug('Skip autoconnect because GUI setting is disabled');
}
} else {
log.debug('Skip autoconnect because account token is not set');