diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-11-30 10:37:14 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-11-30 10:37:14 +0100 |
| commit | 4bf5b1c5df0776d18e7a31f40c0d840e508b4b22 (patch) | |
| tree | 86b0897032d465ec70b878ee336443171455cd4f /gui/src/main | |
| parent | d424bdbedeb1c8e44b693eac02d169e11b7ac92a (diff) | |
| parent | 4fe3a01bc392ee1392e23f424987a01733a9a57e (diff) | |
| download | mullvadvpn-4bf5b1c5df0776d18e7a31f40c0d840e508b4b22.tar.xz mullvadvpn-4bf5b1c5df0776d18e7a31f40c0d840e508b4b22.zip | |
Merge branch 'improve-tunnel-state-error-handling'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 115 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 1 | ||||
| -rw-r--r-- | gui/src/main/notification-controller.ts | 3 | ||||
| -rw-r--r-- | gui/src/main/user-interface.ts | 2 |
4 files changed, 77 insertions, 44 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index a6136bc6f3..9898a1d2c2 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -10,6 +10,7 @@ import { promisify } from 'util'; import { AccountToken, AfterDisconnect, + AuthFailedError, BridgeSettings, BridgeState, ConnectionConfig, @@ -18,15 +19,16 @@ import { DeviceEvent, DeviceState, EndpointObfuscationType, + ErrorState, ErrorStateCause, FirewallPolicyError, + FirewallPolicyErrorType, IAccountData, IAppVersionInfo, IBridgeConstraints, IDevice, IDeviceRemoval, IDnsOptions, - IErrorState, ILocation, IObfuscationEndpoint, IOpenVpnConstraints, @@ -875,71 +877,104 @@ function convertFromTunnelState(tunnelState: grpcTypes.TunnelState): TunnelState } } -function convertFromTunnelStateError(state: grpcTypes.ErrorState.AsObject): IErrorState { - return { - ...state, - cause: convertFromTunnelStateErrorCause(state.cause, state), - blockFailure: state.blockingError - ? convertFromFirewallPolicyError(state.blockingError) - : undefined, +function convertFromTunnelStateError(state: grpcTypes.ErrorState.AsObject): ErrorState { + const baseError = { + blockingError: state.blockingError && convertFromBlockingError(state.blockingError), }; -} -function convertFromTunnelStateErrorCause( - cause: grpcTypes.ErrorState.Cause, - state: grpcTypes.ErrorState.AsObject, -): ErrorStateCause { - switch (cause) { + switch (state.cause) { + case grpcTypes.ErrorState.Cause.AUTH_FAILED: + return { + ...baseError, + cause: ErrorStateCause.authFailed, + authFailedError: convertFromAuthFailedError(state.authFailedError), + }; + case grpcTypes.ErrorState.Cause.TUNNEL_PARAMETER_ERROR: + return { + ...baseError, + cause: ErrorStateCause.tunnelParameterError, + parameterError: convertFromParameterError(state.parameterError), + }; + case grpcTypes.ErrorState.Cause.SET_FIREWALL_POLICY_ERROR: + return { + ...baseError, + cause: ErrorStateCause.setFirewallPolicyError, + policyError: convertFromBlockingError(state.policyError!), + }; + case grpcTypes.ErrorState.Cause.IS_OFFLINE: - return { reason: 'is_offline' }; + return { + ...baseError, + cause: ErrorStateCause.isOffline, + }; case grpcTypes.ErrorState.Cause.SET_DNS_ERROR: - return { reason: 'set_dns_error' }; + return { + ...baseError, + cause: ErrorStateCause.setDnsError, + }; case grpcTypes.ErrorState.Cause.IPV6_UNAVAILABLE: - return { reason: 'ipv6_unavailable' }; - case grpcTypes.ErrorState.Cause.START_TUNNEL_ERROR: - return { reason: 'start_tunnel_error' }; - case grpcTypes.ErrorState.Cause.SET_FIREWALL_POLICY_ERROR: return { - reason: 'set_firewall_policy_error', - details: convertFromFirewallPolicyError(state.policyError!), + ...baseError, + cause: ErrorStateCause.ipv6Unavailable, }; - case grpcTypes.ErrorState.Cause.AUTH_FAILED: - return { reason: 'auth_failed', details: state.authFailReason }; - case grpcTypes.ErrorState.Cause.TUNNEL_PARAMETER_ERROR: { - const parameterErrorMap: Record< - grpcTypes.ErrorState.GenerationError, - TunnelParameterError - > = { - [grpcTypes.ErrorState.GenerationError.NO_MATCHING_RELAY]: 'no_matching_relay', - [grpcTypes.ErrorState.GenerationError.NO_MATCHING_BRIDGE_RELAY]: 'no_matching_bridge_relay', - [grpcTypes.ErrorState.GenerationError.NO_WIREGUARD_KEY]: 'no_wireguard_key', - [grpcTypes.ErrorState.GenerationError.CUSTOM_TUNNEL_HOST_RESOLUTION_ERROR]: - 'custom_tunnel_host_resultion_error', + case grpcTypes.ErrorState.Cause.START_TUNNEL_ERROR: + return { + ...baseError, + cause: ErrorStateCause.startTunnelError, }; - return { reason: 'tunnel_parameter_error', details: parameterErrorMap[state.parameterError] }; - } case grpcTypes.ErrorState.Cause.SPLIT_TUNNEL_ERROR: - return { reason: 'split_tunnel_error' }; + return { + ...baseError, + cause: ErrorStateCause.splitTunnelError, + }; case grpcTypes.ErrorState.Cause.VPN_PERMISSION_DENIED: // VPN_PERMISSION_DENIED is only ever created on Android throw invalidErrorStateCause; } } -function convertFromFirewallPolicyError( +function convertFromBlockingError( error: grpcTypes.ErrorState.FirewallPolicyError.AsObject, ): FirewallPolicyError { switch (error.type) { case grpcTypes.ErrorState.FirewallPolicyError.ErrorType.GENERIC: - return { reason: 'generic' }; + return { type: FirewallPolicyErrorType.generic }; case grpcTypes.ErrorState.FirewallPolicyError.ErrorType.LOCKED: { const pid = error.lockPid; const name = error.lockName; - return { reason: 'locked', details: pid && name ? { pid, name } : undefined }; + return { type: FirewallPolicyErrorType.locked, pid, name }; } } } +function convertFromAuthFailedError(error: grpcTypes.ErrorState.AuthFailedError): AuthFailedError { + switch (error) { + case grpcTypes.ErrorState.AuthFailedError.UNKNOWN: + return AuthFailedError.unknown; + case grpcTypes.ErrorState.AuthFailedError.INVALID_ACCOUNT: + return AuthFailedError.invalidAccount; + case grpcTypes.ErrorState.AuthFailedError.EXPIRED_ACCOUNT: + return AuthFailedError.expiredAccount; + case grpcTypes.ErrorState.AuthFailedError.TOO_MANY_CONNECTIONS: + return AuthFailedError.tooManyConnections; + } +} + +function convertFromParameterError( + error: grpcTypes.ErrorState.GenerationError, +): TunnelParameterError { + switch (error) { + case grpcTypes.ErrorState.GenerationError.NO_MATCHING_RELAY: + return TunnelParameterError.noMatchingRelay; + case grpcTypes.ErrorState.GenerationError.NO_MATCHING_BRIDGE_RELAY: + return TunnelParameterError.noMatchingBridgeRelay; + case grpcTypes.ErrorState.GenerationError.NO_WIREGUARD_KEY: + return TunnelParameterError.noWireguardKey; + case grpcTypes.ErrorState.GenerationError.CUSTOM_TUNNEL_HOST_RESOLUTION_ERROR: + return TunnelParameterError.customTunnelHostResolutionError; + } +} + function convertFromTunnelStateRelayInfo( state: grpcTypes.TunnelStateRelayInfo.AsObject, ): ITunnelStateRelayInfo | undefined { diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 320185abd8..06796a7be1 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -934,7 +934,6 @@ class ApplicationMain this.settings.splitTunnel.enableExclusions && this.settings.splitTunnel.appsList.length > 0, this.userInterface?.isWindowVisible() ?? false, this.settings.gui.enableSystemNotifications, - this.account.accountData?.expiry, ); IpcMainEventChannel.tunnel.notify?.(tunnelState); diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index 06a05366a7..3ea65fa5a0 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -56,14 +56,13 @@ export default class NotificationController { hasExcludedApps: boolean, isWindowVisible: boolean, areSystemNotificationsEnabled: boolean, - accountExpiry?: string, ) { const notificationProviders: SystemNotificationProvider[] = [ new ConnectingNotificationProvider({ tunnelState, reconnecting: this.reconnecting }), new ConnectedNotificationProvider(tunnelState), new ReconnectingNotificationProvider(tunnelState), new DisconnectedNotificationProvider({ tunnelState, blockWhenDisconnected }), - new ErrorNotificationProvider({ tunnelState, accountExpiry, hasExcludedApps }), + new ErrorNotificationProvider({ tunnelState, hasExcludedApps }), ]; const notificationProvider = notificationProviders.find((notification) => diff --git a/gui/src/main/user-interface.ts b/gui/src/main/user-interface.ts index 2c1ac03f27..9870c89702 100644 --- a/gui/src/main/user-interface.ts +++ b/gui/src/main/user-interface.ts @@ -653,7 +653,7 @@ export default class UserInterface implements WindowControllerDelegate { return 'securing'; case 'error': - if (!tunnelState.details.blockFailure) { + if (!tunnelState.details.blockingError) { return 'securing'; } else { return 'unsecured'; |
