diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2019-08-09 16:29:28 +0100 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2019-08-11 22:09:11 +0100 |
| commit | 05c8b7239dc689583f224a472cbc3213703a8cbf (patch) | |
| tree | 147d30c0f2b9a74fbcc7c970b03dd9bdaa59be14 | |
| parent | ad1bf2df6143031877ab6f02edf9d9b65836d833 (diff) | |
| download | mullvadvpn-05c8b7239dc689583f224a472cbc3213703a8cbf.tar.xz mullvadvpn-05c8b7239dc689583f224a472cbc3213703a8cbf.zip | |
Parse tunnel parameter block reason in GUI
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 10 | ||||
| -rw-r--r-- | gui/src/renderer/components/NotificationArea.tsx | 32 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 8 | ||||
| -rw-r--r-- | gui/test/components/NotificationArea.spec.tsx | 3 |
4 files changed, 44 insertions, 9 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 24671fac23..4e349aae36 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -256,7 +256,6 @@ const tunnelStateSchema = oneOf( 'set_firewall_policy_error', 'set_dns_error', 'start_tunnel_error', - 'no_matching_relay', 'is_offline', 'tap_adapter_problem', ), @@ -265,6 +264,15 @@ const tunnelStateSchema = oneOf( reason: enumeration('auth_failed'), details: maybe(string), }), + object({ + reason: enumeration('tunnel_parameter_error'), + details: enumeration( + 'no_matching_relay', + 'no_matching_bridge_relay', + 'no_wireguard_key', + 'custom_tunnel_host_resultion_error', + ), + }), ), }), object({ diff --git a/gui/src/renderer/components/NotificationArea.tsx b/gui/src/renderer/components/NotificationArea.tsx index fcd0872c2e..78cc013f4d 100644 --- a/gui/src/renderer/components/NotificationArea.tsx +++ b/gui/src/renderer/components/NotificationArea.tsx @@ -14,7 +14,7 @@ import { NotificationTitle, } from './NotificationBanner'; -import { BlockReason, TunnelState } from '../../shared/daemon-rpc-types'; +import { BlockReason, TunnelParameterError, TunnelState } from '../../shared/daemon-rpc-types'; import AccountExpiry from '../lib/account-expiry'; import { parseAuthFailure } from '../lib/auth-failure'; import { IVersionReduxState } from '../redux/version/reducers'; @@ -40,6 +40,29 @@ type State = NotificationAreaPresentation & { visible: boolean; }; +function getTunnelParameterMessage(err: TunnelParameterError): string { + switch (err) { + /// TODO: once bridge constraints can be set, add a more descriptive error message + case 'no_matching_bridge_relay': + case 'no_matching_relay': + return messages.pgettext( + 'in-app-notifications', + 'No relay server matches the current settings. You can try changing the location or the relay settings.', + ); + case 'no_wireguard_key': + return messages.pgettext( + 'in-app-notifications', + 'WireGuard key not set. You can generate one manually in the advanced settings.', + ); + break; + case 'custom_tunnel_host_resultion_error': + return messages.pgettext( + 'in-app-notifications', + 'Failed to resolve host of custom tunnel. Consider changing the settings', + ); + } +} + function getBlockReasonMessage(blockReason: BlockReason): string { switch (blockReason.reason) { case 'auth_failed': @@ -70,11 +93,8 @@ function getBlockReasonMessage(blockReason: BlockReason): string { return messages.pgettext('in-app-notifications', 'Failed to set system DNS server'); case 'start_tunnel_error': return messages.pgettext('in-app-notifications', 'Failed to start tunnel connection'); - case 'no_matching_relay': - return messages.pgettext( - 'in-app-notifications', - 'No relay server matches the current settings. You can try changing the location or the relay settings.', - ); + case 'tunnel_parameter_error': + return getTunnelParameterMessage(blockReason.details); case 'is_offline': return messages.pgettext( 'in-app-notifications', diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 8dc87cc2b1..61a0263031 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -15,6 +15,12 @@ export interface ILocation { bridgeHostname?: string; } +export type TunnelParameterError = + | 'no_matching_relay' + | 'no_matching_bridge_relay' + | 'no_wireguard_key' + | 'custom_tunnel_host_resultion_error'; + export type BlockReason = | { reason: @@ -22,10 +28,10 @@ export type BlockReason = | 'set_firewall_policy_error' | 'set_dns_error' | 'start_tunnel_error' - | 'no_matching_relay' | 'is_offline' | 'tap_adapter_problem'; } + | { reason: 'tunnel_parameter_error'; details: TunnelParameterError } | { reason: 'auth_failed'; details?: string }; export type AfterDisconnect = 'nothing' | 'block' | 'reconnect'; diff --git a/gui/test/components/NotificationArea.spec.tsx b/gui/test/components/NotificationArea.spec.tsx index f2674e848c..a92eced532 100644 --- a/gui/test/components/NotificationArea.spec.tsx +++ b/gui/test/components/NotificationArea.spec.tsx @@ -141,7 +141,8 @@ describe('components/NotificationArea', () => { tunnelState={{ state: 'blocked', details: { - reason: 'no_matching_relay', + reason: 'tunnel_parameter_error', + details: 'no_matching_relay', }, }} version={defaultVersion} |
