diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-09-26 16:15:29 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-11-30 10:36:19 +0100 |
| commit | 3fd327525882bc6459ed425de67ed687c949ef3f (patch) | |
| tree | 90b137e3a24800ffd2f33d7e89e2b45700c101d8 /gui/src/shared | |
| parent | d424bdbedeb1c8e44b693eac02d169e11b7ac92a (diff) | |
| download | mullvadvpn-3fd327525882bc6459ed425de67ed687c949ef3f.tar.xz mullvadvpn-3fd327525882bc6459ed425de67ed687c949ef3f.zip | |
Add enum for error state cause and update to new values from daemon
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 735bb91224..4a5f27d98e 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -17,34 +17,69 @@ export interface ILocation { provider?: string; } +export enum FirewallPolicyErrorType { + generic, + locked, +} + export type FirewallPolicyError = - | { reason: 'generic' } + | { type: FirewallPolicyErrorType.generic } | { - reason: 'locked'; - details?: { - name: string; - pid: number; - }; + type: FirewallPolicyErrorType.locked; + name: string; + pid: number; }; -export type TunnelParameterError = - | 'no_matching_relay' - | 'no_matching_bridge_relay' - | 'no_wireguard_key' - | 'custom_tunnel_host_resultion_error'; +export enum ErrorStateCause { + authFailed, + ipv6Unavailable, + setFirewallPolicyError, + setDnsError, + startTunnelError, + tunnelParameterError, + isOffline, + splitTunnelError, +} + +export enum AuthFailedError { + unknown, + invalidAccount, + expiredAccount, + tooManyConnections, +} + +export enum TunnelParameterError { + noMatchingRelay, + noMatchingBridgeRelay, + noWireguardKey, + customTunnelHostResolutionError, +} -export type ErrorStateCause = +export type ErrorState = | { - reason: - | 'ipv6_unavailable' - | 'set_dns_error' - | 'start_tunnel_error' - | 'is_offline' - | 'split_tunnel_error'; + cause: + | ErrorStateCause.ipv6Unavailable + | ErrorStateCause.setDnsError + | ErrorStateCause.startTunnelError + | ErrorStateCause.isOffline + | ErrorStateCause.splitTunnelError; + blockingError?: FirewallPolicyError; } - | { reason: 'set_firewall_policy_error'; details: FirewallPolicyError } - | { reason: 'tunnel_parameter_error'; details: TunnelParameterError } - | { reason: 'auth_failed'; details?: string }; + | { + cause: ErrorStateCause.authFailed; + blockingError?: FirewallPolicyError; + authFailedError: AuthFailedError; + } + | { + cause: ErrorStateCause.tunnelParameterError; + blockingError?: FirewallPolicyError; + parameterError: TunnelParameterError; + } + | { + cause: ErrorStateCause.setFirewallPolicyError; + blockingError?: FirewallPolicyError; + policyError: FirewallPolicyError; + }; export type AfterDisconnect = 'nothing' | 'block' | 'reconnect'; @@ -134,12 +169,7 @@ export type TunnelState = | { state: 'connecting'; details?: ITunnelStateRelayInfo } | { state: 'connected'; details: ITunnelStateRelayInfo } | { state: 'disconnecting'; details: AfterDisconnect } - | { state: 'error'; details: IErrorState }; - -export interface IErrorState { - blockFailure?: FirewallPolicyError; - cause: ErrorStateCause; -} + | { state: 'error'; details: ErrorState }; export type RelayLocation = | { hostname: [string, string, string] } |
