summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-09-12 13:33:46 +0200
committerErik Larkö <erik@mullvad.net>2017-09-12 13:46:04 +0200
commit4ed0102b38aa29bee9b0a876ec48c48d715f644e (patch)
tree4c3334ed98f97b2c83c9b49f448c790810a5f835 /app/lib
parentd541f4ee98182faa6c4e52727c948612b4d7ad53 (diff)
downloadmullvadvpn-4ed0102b38aa29bee9b0a876ec48c48d715f644e.tar.xz
mullvadvpn-4ed0102b38aa29bee9b0a876ec48c48d715f644e.zip
Move the hardcoded relay endpoint data to the Connect component
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js10
-rw-r--r--app/lib/ipc-facade.js16
2 files changed, 14 insertions, 12 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 9d1fb21d35..b17b163a85 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -11,6 +11,7 @@ import { push } from 'react-router-redux';
import type { BackendState } from './ipc-facade';
import type { ConnectionState } from '../redux/connection/reducers';
+import type { RelayEndpoint } from './ipc-facade';
export type EventType = 'connect' | 'connecting' | 'disconnect' | 'login' | 'logging' | 'logout' | 'updatedIp' | 'updatedLocation' | 'updatedReachability';
export type ErrorType = 'NO_CREDIT' | 'NO_INTERNET' | 'INVALID_ACCOUNT';
@@ -227,17 +228,16 @@ export class Backend {
});
}
- connect(addr: string): Promise<void> {
+ connect(relayEndpoint: RelayEndpoint): Promise<void> {
- this._store.dispatch(connectionActions.connectingTo(addr));
+ this._store.dispatch(connectionActions.connectingTo(relayEndpoint));
- // TODO: Don't hardcode these values
- return this._ipc.setCustomRelay(addr, 1300, 'udp')
+ return this._ipc.setCustomRelay(relayEndpoint)
.then( () => {
return this._ipc.connect();
})
.catch(e => {
- log.info('Failed connecting to', addr, e);
+ log.info('Failed connecting to', relayEndpoint.host, '-', e.message);
this._store.dispatch(connectionActions.disconnected());
});
}
diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js
index 0a9ceebf65..736d4fc31c 100644
--- a/app/lib/ipc-facade.js
+++ b/app/lib/ipc-facade.js
@@ -25,13 +25,19 @@ export type BackendState = {
state: SecurityState,
target_state: SecurityState,
};
+export type RelayEndpoint = {
+ host: string,
+ port: number,
+ protocol: 'tcp' | 'udp',
+};
+
export interface IpcFacade {
setConnectionString(string): void,
getAccountData(AccountToken): Promise<AccountData>,
getAccount(): Promise<?AccountToken>,
setAccount(accountToken: AccountToken): Promise<void>,
- setCustomRelay(host: string, port: number, protocol: 'udp' | 'tcp'): Promise<void>,
+ setCustomRelay(RelayEndpoint): Promise<void>,
connect(): Promise<void>,
disconnect(): Promise<void>,
getIp(): Promise<Ip>,
@@ -86,12 +92,8 @@ export class RealIpc implements IpcFacade {
return;
}
- setCustomRelay(host: string, port: number, protocol: 'udp' | 'tcp'): Promise<void> {
- return this._ipc.send('set_custom_relay', {
- host,
- port,
- protocol,
- })
+ setCustomRelay(relayEndpoint: RelayEndpoint): Promise<void> {
+ return this._ipc.send('set_custom_relay', [relayEndpoint])
.then(this._ignoreResponse);
}