summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-07-02 19:58:39 +0100
committerEmīls Piņķis <emils@mullvad.net>2019-07-05 16:49:28 +0100
commit0ca18fa4ae332ea119c76bed871e8372414d60c5 (patch)
tree77729ca77aed9247f345e912c1492767b3000092
parentdc5289a729dde3ece89c38e794f81a279b7546ad (diff)
downloadmullvadvpn-0ca18fa4ae332ea119c76bed871e8372414d60c5.tar.xz
mullvadvpn-0ca18fa4ae332ea119c76bed871e8372414d60c5.zip
Add wireguard key RPCs for GUI
-rw-r--r--gui/src/shared/ipc-event-channel.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index 207e509779..73457c3f9d 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -12,6 +12,7 @@ import {
ILocation,
IRelayList,
ISettings,
+ KeygenEvent,
RelaySettingsUpdate,
TunnelState,
} from './daemon-rpc-types';
@@ -28,6 +29,7 @@ export interface IAppStateSnapshot {
currentVersion: ICurrentAppVersionInfo;
upgradeVersion: IAppUpgradeInfo;
guiSettings: IGuiSettingsState;
+ wireguardPublicKey?: string;
}
interface ISender<T> {
@@ -112,6 +114,18 @@ interface IAutoStartHandlers extends ISender<boolean> {
handleSet(fn: (value: boolean) => Promise<void>): void;
}
+interface IWireguardKeyMethods extends IReceiver<string> {
+ listenKeygenEvents(fn: (event: KeygenEvent) => void): void;
+ generateKey(): Promise<KeygenEvent>;
+ verifyKey(): Promise<boolean>;
+}
+
+interface IWireguardKeyHandlers extends ISender<string | undefined> {
+ notifyKeygenEvent(webContents: WebContents, event: KeygenEvent): void;
+ handleGenerateKey(fn: () => Promise<KeygenEvent>): void;
+ handleVerifyKey(fn: () => Promise<boolean>): void;
+}
+
/// Events names
const DAEMON_CONNECTED = 'daemon-connected';
@@ -152,6 +166,11 @@ const GET_ACCOUNT_DATA = 'get-account-data';
const AUTO_START_CHANGED = 'auto-start-changed';
const SET_AUTO_START = 'set-auto-start';
+const WIREGUARD_KEY_SET = 'wireguard-key-change-event';
+const WIREGUARD_KEYGEN_EVENT = 'wireguard-keygen-event';
+const GENERATE_WIREGUARD_KEY = 'generate-wireguard-key';
+const VERIFY_WIREGUARD_KEY = 'verify-wireguard-key';
+
/// Typed IPC event channel
///
/// Static methods are meant to be provide the way to send the events from a renderer process, while
@@ -228,6 +247,13 @@ export class IpcRendererEventChannel {
listen: listen(ACCOUNT_HISTORY_CHANGED),
removeItem: requestSender(REMOVE_ACCOUNT_HISTORY_ITEM),
};
+
+ public static wireguardKeys: IWireguardKeyMethods = {
+ listen: listen(WIREGUARD_KEY_SET),
+ listenKeygenEvents: listen(WIREGUARD_KEYGEN_EVENT),
+ generateKey: requestSender(GENERATE_WIREGUARD_KEY),
+ verifyKey: requestSender(VERIFY_WIREGUARD_KEY),
+ };
}
export class IpcMainEventChannel {
@@ -302,6 +328,13 @@ export class IpcMainEventChannel {
notify: sender<AccountToken[]>(ACCOUNT_HISTORY_CHANGED),
handleRemoveItem: requestHandler(REMOVE_ACCOUNT_HISTORY_ITEM),
};
+
+ public static wireguardKeys: IWireguardKeyHandlers = {
+ notify: sender<string | undefined>(WIREGUARD_KEY_SET),
+ notifyKeygenEvent: sender<KeygenEvent>(WIREGUARD_KEYGEN_EVENT),
+ handleGenerateKey: requestHandler(GENERATE_WIREGUARD_KEY),
+ handleVerifyKey: requestHandler(VERIFY_WIREGUARD_KEY),
+ };
}
function listen<T>(event: string): (fn: (value: T) => void) => void {