diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-11-09 10:30:18 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-11-10 21:11:06 +0100 |
| commit | b2075de931dc3cea7e59e8d5e0328333af6e5b42 (patch) | |
| tree | 0b227b61e4ca92f6978705f5f4e90e2e56720b5d /gui/src/shared | |
| parent | 0e3aae1adcc24ff6bd003480bbb22a608d1e3c7c (diff) | |
| download | mullvadvpn-b2075de931dc3cea7e59e8d5e0328333af6e5b42.tar.xz mullvadvpn-b2075de931dc3cea7e59e8d5e0328333af6e5b42.zip | |
Add notification when there's no valid WireGuard key
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/notifications/no-valid-key.ts | 37 | ||||
| -rw-r--r-- | gui/src/shared/notifications/notification.ts | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/gui/src/shared/notifications/no-valid-key.ts b/gui/src/shared/notifications/no-valid-key.ts new file mode 100644 index 0000000000..d1b90095e2 --- /dev/null +++ b/gui/src/shared/notifications/no-valid-key.ts @@ -0,0 +1,37 @@ +import { WgKeyState } from '../../renderer/redux/settings/reducers'; +import { messages } from '../../shared/gettext'; +import { LiftedConstraint, TunnelProtocol } from '../daemon-rpc-types'; +import { InAppNotification, InAppNotificationProvider } from './notification'; + +interface NoValidKeyNotificationContext { + tunnelProtocol?: LiftedConstraint<TunnelProtocol>; + wireGuardKey: WgKeyState; +} + +export class NoValidKeyNotificationProvider implements InAppNotificationProvider { + public constructor(private context: NoValidKeyNotificationContext) {} + + public mayDisplay() { + const usingWireGuard = + this.context.tunnelProtocol === 'wireguard' || + (this.context.tunnelProtocol === 'any' && process.platform !== 'win32'); + const keyInvalid = + this.context.wireGuardKey.type === 'key-not-set' || + this.context.wireGuardKey.type === 'too-many-keys' || + this.context.wireGuardKey.type === 'generation-failure' || + (this.context.wireGuardKey.type === 'key-set' && + this.context.wireGuardKey.key.valid === false) || + (this.context.wireGuardKey.type === 'key-set' && + this.context.wireGuardKey.key.replacementFailure === 'too_many_keys'); + + return usingWireGuard && keyInvalid; + } + + public getInAppNotification(): InAppNotification { + return { + indicator: 'warning', + title: messages.pgettext('in-app-notifications', 'VALID WIREGUARD KEY IS MISSING'), + subtitle: messages.pgettext('in-app-notifications', 'Manage keys under Advanced settings.'), + }; + } +} diff --git a/gui/src/shared/notifications/notification.ts b/gui/src/shared/notifications/notification.ts index adbf3ae746..4bfd90463f 100644 --- a/gui/src/shared/notifications/notification.ts +++ b/gui/src/shared/notifications/notification.ts @@ -41,6 +41,7 @@ export * from './connected'; export * from './connecting'; export * from './disconnected'; export * from './error'; +export * from './no-valid-key'; export * from './inconsistent-version'; export * from './reconnecting'; export * from './unsupported-version'; |
