summaryrefslogtreecommitdiffhomepage
path: root/app/lib/backend.js
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-09-25 16:02:43 +0200
committerErik Larkö <erik@mullvad.net>2017-09-27 07:28:50 +0200
commit7b52a3c5bbedc8071d05eb76f1365331ecb08971 (patch)
tree9a8117bf4fa4d831204438069d653fcbbc74f8b0 /app/lib/backend.js
parent131c4487c1032a85efa37390f7ca72b3e8eb8952 (diff)
downloadmullvadvpn-7b52a3c5bbedc8071d05eb76f1365331ecb08971.tar.xz
mullvadvpn-7b52a3c5bbedc8071d05eb76f1365331ecb08971.zip
Actually implement autoconnect
Diffstat (limited to 'app/lib/backend.js')
-rw-r--r--app/lib/backend.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index d0344880ac..cf8e440bdf 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -228,18 +228,27 @@ export class Backend {
});
}
- connect(relayEndpoint: RelayEndpoint): Promise<void> {
+ connect(aRelayEndpoint?: RelayEndpoint): Promise<void> {
- this._store.dispatch(connectionActions.connectingTo(relayEndpoint));
+ const relayEndpoint = aRelayEndpoint;
+ if (relayEndpoint) {
+ this._store.dispatch(connectionActions.connectingTo(relayEndpoint));
- return this._ipc.setCustomRelay(relayEndpoint)
- .then( () => {
- return this._ipc.connect();
- })
- .catch(e => {
- log.info('Failed connecting to', relayEndpoint.host, '-', e.message);
- this._store.dispatch(connectionActions.disconnected());
- });
+ return this._ipc.setCustomRelay(relayEndpoint)
+ .then( () => {
+ return this._ipc.connect();
+ })
+ .catch(e => {
+ log.info('Failed connecting to', relayEndpoint.host, '-', e.message);
+ this._store.dispatch(connectionActions.disconnected());
+ });
+ } else {
+ return this._ipc.connect()
+ .catch(e => {
+ log.info('Failed connecting to the relay set in the backend, ', e.message);
+ this._store.dispatch(connectionActions.disconnected());
+ });
+ }
}
disconnect(): Promise<void> {