diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 55 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 12 | ||||
| -rw-r--r-- | gui/src/main/notification-controller.ts | 21 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 8 | ||||
| -rw-r--r-- | gui/src/renderer/components/Connect.tsx | 14 | ||||
| -rw-r--r-- | gui/src/renderer/components/NotificationArea.tsx | 31 | ||||
| -rw-r--r-- | gui/src/renderer/components/TunnelControl.tsx | 15 | ||||
| -rw-r--r-- | gui/src/renderer/redux/connection/actions.ts | 12 | ||||
| -rw-r--r-- | gui/src/renderer/redux/connection/reducers.ts | 7 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 9 |
10 files changed, 91 insertions, 93 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 5fcc9171e0..78748b70ab 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -251,32 +251,35 @@ const tunnelStateSchema = oneOf( }), }), object({ - state: enumeration('blocked'), - details: oneOf( - object({ - reason: enumeration( - 'ipv6_unavailable', - 'set_firewall_policy_error', - 'set_dns_error', - 'start_tunnel_error', - 'is_offline', - 'tap_adapter_problem', - ), - }), - object({ - 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', - ), - }), - ), + state: enumeration('error'), + details: object({ + is_blocking: boolean, + cause: oneOf( + object({ + reason: enumeration( + 'ipv6_unavailable', + 'set_firewall_policy_error', + 'set_dns_error', + 'start_tunnel_error', + 'is_offline', + 'tap_adapter_problem', + ), + }), + object({ + 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({ state: enumeration('connected', 'connecting', 'disconnected'), diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index cba1caac5a..0ef641ec15 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -851,14 +851,12 @@ class ApplicationMain { case 'connecting': return 'securing'; - case 'blocked': - switch (tunnelState.details.reason) { - case 'set_firewall_policy_error': - return 'unsecured'; - default: - return 'securing'; + case 'error': + if (tunnelState.details.isBlocking) { + return 'securing'; + } else { + return 'unsecured'; } - case 'disconnecting': return 'securing'; diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index 515918f50c..99af3bcf45 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -75,18 +75,15 @@ export default class NotificationController { case 'disconnected': this.showTunnelStateNotification(messages.pgettext('notifications', 'Unsecured')); break; - case 'blocked': - switch (tunnelState.details.reason) { - case 'set_firewall_policy_error': - this.showTunnelStateNotification( - messages.pgettext('notifications', 'Critical failure - Unsecured'), - ); - break; - default: - this.showTunnelStateNotification( - messages.pgettext('notifications', 'Blocked all connections'), - ); - break; + case 'error': + if (tunnelState.details.isBlocking) { + this.showTunnelStateNotification( + messages.pgettext('notifications', 'Blocked all connections'), + ); + } else { + this.showTunnelStateNotification( + messages.pgettext('notifications', 'Critical failure - Unsecured'), + ); } break; case 'disconnecting': diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index ae906868a2..b3a1b257bd 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -264,7 +264,7 @@ export default class AppRenderer { const state = this.tunnelState.state; // connect only if tunnel is disconnected or blocked. - if (state === 'disconnecting' || state === 'disconnected' || state === 'blocked') { + if (state === 'disconnecting' || state === 'disconnected' || state === 'error') { // switch to the connecting state ahead of time to make the app look more responsive this.reduxActions.connection.connecting(); @@ -549,7 +549,7 @@ export default class AppRenderer { actions.connection.disconnected(); break; - case 'blocked': + case 'error': actions.connection.blocked(tunnelState.details); break; } @@ -597,8 +597,8 @@ export default class AppRenderer { actions.updateBlockState(true); break; - case 'blocked': - actions.updateBlockState(tunnelState.details.reason !== 'set_firewall_policy_error'); + case 'error': + actions.updateBlockState(tunnelState.details.isBlocking); break; } } diff --git a/gui/src/renderer/components/Connect.tsx b/gui/src/renderer/components/Connect.tsx index e8d5c0e096..7f73fb7ea0 100644 --- a/gui/src/renderer/components/Connect.tsx +++ b/gui/src/renderer/components/Connect.tsx @@ -117,9 +117,9 @@ export default class Connect extends Component<IProps, IState> { // Blocked with auth failure / expired account if ( - tunnelState.state === 'blocked' && - tunnelState.details.reason === 'auth_failed' && - parseAuthFailure(tunnelState.details.details).kind === AuthFailureKind.expiredAccount + tunnelState.state === 'error' && + tunnelState.details.cause.reason === 'auth_failed' && + parseAuthFailure(tunnelState.details.cause.reason).kind === AuthFailureKind.expiredAccount ) { return true; } @@ -200,8 +200,8 @@ export default class Connect extends Component<IProps, IState> { case 'connecting': case 'connected': return HeaderBarStyle.success; - case 'blocked': - switch (status.details.reason) { + case 'error': + switch (status.details.cause.reason) { case 'set_firewall_policy_error': return HeaderBarStyle.error; default: @@ -259,8 +259,8 @@ export default class Connect extends Component<IProps, IState> { case 'connecting': case 'connected': return MarkerStyle.secure; - case 'blocked': - switch (status.details.reason) { + case 'error': + switch (status.details.cause.reason) { case 'set_firewall_policy_error': return MarkerStyle.unsecure; default: diff --git a/gui/src/renderer/components/NotificationArea.tsx b/gui/src/renderer/components/NotificationArea.tsx index 1d65306ef9..c459695a30 100644 --- a/gui/src/renderer/components/NotificationArea.tsx +++ b/gui/src/renderer/components/NotificationArea.tsx @@ -13,7 +13,7 @@ import { NotificationTitle, } from './NotificationBanner'; -import { BlockReason, TunnelParameterError, TunnelState } from '../../shared/daemon-rpc-types'; +import { ErrorStateCause, 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'; @@ -63,7 +63,7 @@ function getTunnelParameterMessage(err: TunnelParameterError): string { } } -function getBlockReasonMessage(blockReason: BlockReason): string { +function getErrorCauseMessage(blockReason: ErrorStateCause): string { switch (blockReason.reason) { case 'auth_failed': return parseAuthFailure(blockReason.details).message; @@ -124,20 +124,19 @@ export default class NotificationArea extends Component<IProps, State> { reason: '', }; - case 'blocked': - switch (tunnelState.details.reason) { - case 'set_firewall_policy_error': - return { - visible: true, - type: 'failure-unsecured', - reason: getBlockReasonMessage(tunnelState.details), - }; - default: - return { - visible: true, - type: 'blocking', - reason: getBlockReasonMessage(tunnelState.details), - }; + case 'error': + if (tunnelState.details.isBlocking) { + return { + visible: true, + type: 'blocking', + reason: getErrorCauseMessage(tunnelState.details.cause), + }; + } else { + return { + visible: true, + type: 'failure-unsecured', + reason: getErrorCauseMessage(tunnelState.details.cause), + }; } case 'disconnecting': diff --git a/gui/src/renderer/components/TunnelControl.tsx b/gui/src/renderer/components/TunnelControl.tsx index 4acc2bd1ef..700603bd2e 100644 --- a/gui/src/renderer/components/TunnelControl.tsx +++ b/gui/src/renderer/components/TunnelControl.tsx @@ -115,21 +115,14 @@ export default class TunnelControl extends Component<ITunnelControlProps> { let state = this.props.tunnelState.state; switch (this.props.tunnelState.state) { - case 'blocked': - switch (this.props.tunnelState.details.reason) { - case 'set_firewall_policy_error': - state = 'disconnected'; - break; - default: - state = 'blocked'; - break; - } + case 'error': + state = this.props.tunnelState.details.isBlocking ? 'error' : 'disconnected'; break; case 'disconnecting': switch (this.props.tunnelState.details) { case 'block': - state = 'blocked'; + state = 'error'; break; case 'reconnect': state = 'connecting'; @@ -177,7 +170,7 @@ export default class TunnelControl extends Component<ITunnelControlProps> { </Wrapper> ); - case 'blocked': + case 'error': return ( <Wrapper> <Body> diff --git a/gui/src/renderer/redux/connection/actions.ts b/gui/src/renderer/redux/connection/actions.ts index 8f5b2e62bb..95d2332ed3 100644 --- a/gui/src/renderer/redux/connection/actions.ts +++ b/gui/src/renderer/redux/connection/actions.ts @@ -1,6 +1,6 @@ import { AfterDisconnect, - BlockReason, + IErrorState, ILocation, ITunnelStateRelayInfo, } from '../../../shared/daemon-rpc-types'; @@ -25,8 +25,8 @@ interface IDisconnectingAction { } interface IBlockedAction { - type: 'BLOCKED'; - reason: BlockReason; + type: 'TUNNEL_ERROR'; + errorState: IErrorState; } interface INewLocationAction { @@ -75,10 +75,10 @@ function disconnecting(afterDisconnect: AfterDisconnect): IDisconnectingAction { }; } -function blocked(reason: BlockReason): IBlockedAction { +function blocked(errorState: IErrorState): IBlockedAction { return { - type: 'BLOCKED', - reason, + type: 'TUNNEL_ERROR', + errorState, }; } diff --git a/gui/src/renderer/redux/connection/reducers.ts b/gui/src/renderer/redux/connection/reducers.ts index 4772df8fc5..e7f2f0c2cf 100644 --- a/gui/src/renderer/redux/connection/reducers.ts +++ b/gui/src/renderer/redux/connection/reducers.ts @@ -62,10 +62,13 @@ export default function( status: { state: 'disconnecting', details: action.afterDisconnect }, }; - case 'BLOCKED': + case 'TUNNEL_ERROR': return { ...state, - status: { state: 'blocked', details: action.reason }, + status: { + state: 'error', + details: action.errorState, + }, }; default: diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 7ce5e93111..404762d962 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -21,7 +21,7 @@ export type TunnelParameterError = | 'no_wireguard_key' | 'custom_tunnel_host_resultion_error'; -export type BlockReason = +export type ErrorStateCause = | { reason: | 'ipv6_unavailable' @@ -99,7 +99,12 @@ export type TunnelState = | { state: 'connecting'; details?: ITunnelStateRelayInfo } | { state: 'connected'; details: ITunnelStateRelayInfo } | { state: 'disconnecting'; details: AfterDisconnect } - | { state: 'blocked'; details: BlockReason }; + | { state: 'error'; details: IErrorState }; + +export interface IErrorState { + isBlocking: boolean; + cause: ErrorStateCause; +} export type RelayLocation = | { hostname: [string, string, string] } |
