summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/lib/ipc-facade.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js
index a4cf9bdc9f..2fa4212622 100644
--- a/app/lib/ipc-facade.js
+++ b/app/lib/ipc-facade.js
@@ -108,6 +108,34 @@ const RelaySettingsSchema = oneOf(
})
);
+export type RelayList = {
+ countries: Array<RelayListCountry>,
+};
+
+export type RelayListCountry = {
+ name: string,
+ code: string,
+ cities: Array<RelayListCity>,
+};
+
+export type RelayListCity = {
+ name: string,
+ code: string,
+ position: [Number, Number],
+};
+
+const RelayListSchema = object({
+ countries: arrayOf(object({
+ name: string,
+ code: string,
+ cities: arrayOf(object({
+ name: string,
+ code: string,
+ position: arrayOf(number),
+ })),
+ })),
+});
+
export interface IpcFacade {
setConnectionString(string): void,
@@ -116,6 +144,7 @@ export interface IpcFacade {
setAccount(accountToken: ?AccountToken): Promise<void>,
updateRelaySettings(RelaySettingsUpdate): Promise<void>,
getRelaySettings(): Promise<RelaySettings>,
+ getRelayLocations(): Promise<RelayList>,
connect(): Promise<void>,
disconnect(): Promise<void>,
shutdown(): Promise<void>,
@@ -192,6 +221,16 @@ export class RealIpc implements IpcFacade {
});
}
+ async getRelayLocations(): Promise<RelayList> {
+ const raw = await this._ipc.send('get_relay_locations');
+ try {
+ const validated: any = validate(RelayListSchema, raw);
+ return (validated: RelayList);
+ } catch (e) {
+ throw new InvalidReply(raw, e);
+ }
+ }
+
connect(): Promise<void> {
return this._ipc.send('connect')
.then(this._ignoreResponse);