diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2017-11-20 15:36:44 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2017-11-23 12:41:13 +0100 |
| commit | e32bdb95e3762f1ac48892062a5cdb022d07e5b4 (patch) | |
| tree | 12060ad987919800679d507fb8543e3ccaef2c20 /app/lib | |
| parent | 18b070df8a556fa00debdc14f101a1d8a92e6838 (diff) | |
| download | mullvadvpn-e32bdb95e3762f1ac48892062a5cdb022d07e5b4.tar.xz mullvadvpn-e32bdb95e3762f1ac48892062a5cdb022d07e5b4.zip | |
Fix Backend.connect() logic
Diffstat (limited to 'app/lib')
| -rw-r--r-- | app/lib/backend.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index c3f5cf6a64..f2e1546f94 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -264,22 +264,26 @@ export class Backend { } connect(host: string): Promise<void> { + const newRelaySettings = { + custom_tunnel_endpoint: { + host: host, + tunnel: { + openvpn: { + // TODO: protocol and port are temporarily hardcoded + protocol: 'udp', + port: 1300, + } + }, + }, + }; - let setHostPromise = () => Promise.resolve(); - if (host) { - this._store.dispatch(connectionActions.connectingTo(host || 'unknown')); - setHostPromise = () => this._ipc.updateRelaySettings({ - host: { only: host }, - tunnel: { openvpn: { - }}, - }); - } + this._store.dispatch(connectionActions.connectingTo(host)); return this._ensureAuthenticated() - .then( setHostPromise ) - .then( () => this._ipc.connect() ) - .catch(e => { - log.info('Failed connecting to the relay set in the backend, ', e.message); + .then(this._ipc.updateRelaySettings(newRelaySettings)) + .then(this._ipc.connect()) + .catch((e) => { + log.error('Backend.connect failed because: ', e.message); this._store.dispatch(connectionActions.disconnected()); }); } |
