summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-06-26 14:01:15 +0300
committerAndrej Mihajlov <and@codeispoetry.ru>2017-06-26 14:01:15 +0300
commitab9d8b2471dbcd54bb882b3b6722626f81b71053 (patch)
tree05b88ff17af4a3e318c26d2903f869a4baff58c1 /app/lib
parentdbafeda02cc3b490fb704ab7ba7b23a6cd5d9abe (diff)
parent9c878320781750d28a3958163974336cf28a0325 (diff)
downloadmullvadvpn-ab9d8b2471dbcd54bb882b3b6722626f81b71053.tar.xz
mullvadvpn-ab9d8b2471dbcd54bb882b3b6722626f81b71053.zip
Merge branch 'feature/flow-typed/connect-component'
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index a3574557a4..bf3a1382f1 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -7,6 +7,16 @@ import { IpcFacade, RealIpc } from './ipc-facade';
export type EventType = 'connect' | 'connecting' | 'disconnect' | 'login' | 'logging' | 'logout' | 'updatedIp' | 'updatedLocation' | 'updatedReachability';
export type ErrorType = 'NO_CREDIT' | 'NO_INTERNET' | 'INVALID_ACCOUNT';
+export type ServerInfo = {
+ address: string,
+ name: string,
+ city: string,
+ country: string,
+ location: [number, number]
+};
+
+export type ServerInfoList = { [string]: ServerInfo };
+
export class BackendError extends Error {
type: ErrorType;
title: string;
@@ -93,15 +103,15 @@ export class Backend {
});
}
- serverInfo(key: string) {
- switch(key) {
+ serverInfo(identifier: string): ?ServerInfo {
+ switch(identifier) {
case 'fastest': return this.fastestServer();
case 'nearest': return this.nearestServer();
- default: return servers[key];
+ default: return (servers: ServerInfoList)[identifier];
}
}
- fastestServer() {
+ fastestServer(): ServerInfo {
return {
address: 'uk.mullvad.net',
name: 'Fastest',
@@ -111,7 +121,7 @@ export class Backend {
};
}
- nearestServer() {
+ nearestServer(): ServerInfo {
return {
address: 'es.mullvad.net',
name: 'Nearest',