diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2019-09-02 15:27:57 +0100 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2019-09-05 10:46:54 +0100 |
| commit | 8f47cab67f7f92b1b246d5b993f3d2d846dd4219 (patch) | |
| tree | b40fc803aa34b99a8b8769f14a4c384a064e3fb3 /gui/src/main | |
| parent | 96d52dfc0a69928c274531d65f9ddf1965ad5026 (diff) | |
| download | mullvadvpn-8f47cab67f7f92b1b246d5b993f3d2d846dd4219.tar.xz mullvadvpn-8f47cab67f7f92b1b246d5b993f3d2d846dd4219.zip | |
Add button to regenerate key
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 15 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 0a55833731..2d4141304e 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -8,6 +8,7 @@ import { ILocation, IRelayList, ISettings, + IWireguardPublicKey, KeygenEvent, RelaySettingsUpdate, TunnelState, @@ -337,10 +338,18 @@ const settingsSchema = partialObject({ tunnel_options: tunnelOptionsSchema, }); +const wireguardPublicKey = object({ + key: string, + created: string, +}); + const keygenEventSchema = oneOf( enumeration('too_many_keys', 'generation_failure'), object({ - new_key: string, + new_key: object({ + key: string, + created: string, + }), }), ); @@ -567,10 +576,10 @@ export class DaemonRpc { } } - public async getWireguardKey(): Promise<string | undefined> { + public async getWireguardKey(): Promise<IWireguardPublicKey | undefined> { const response = await this.transport.send('get_wireguard_key'); try { - return validate(maybe(string), response) || undefined; + return validate(maybe(wireguardPublicKey), response) || undefined; } catch (error) { throw new ResponseParseError('Invalid response from get_wireguard_key'); } diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index efe76bdfab..a0694e814c 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -14,6 +14,7 @@ import { IRelayList, IRelayListHostname, ISettings, + IWireguardPublicKey, KeygenEvent, RelaySettings, RelaySettingsUpdate, @@ -143,7 +144,7 @@ class ApplicationMain { // The UI locale which is set once from onReady handler private locale = 'en'; - private wireguardPublicKey?: string; + private wireguardPublicKey?: IWireguardPublicKey; private accountDataCache = new AccountDataCache( (accountToken) => { @@ -560,7 +561,7 @@ class ApplicationMain { } } - private setWireguardKey(wireguardKey?: string) { + private setWireguardKey(wireguardKey?: IWireguardPublicKey) { this.wireguardPublicKey = wireguardKey; if (this.windowController) { IpcMainEventChannel.wireguardKeys.notify(this.windowController.webContents, wireguardKey); |
