summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-07-31 11:51:55 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-08-04 10:52:43 +0200
commit7902e993128796b5f223d6352e7489341b16f606 (patch)
treefc8497091718e9d3a1092367ee243bde0f666c8b /gui/src/shared
parent09e0f680bc43e521b252eb198b3f6548680869ba (diff)
downloadmullvadvpn-7902e993128796b5f223d6352e7489341b16f606.tar.xz
mullvadvpn-7902e993128796b5f223d6352e7489341b16f606.zip
Store the original block reason in the non-blocking error state
Diffstat (limited to 'gui/src/shared')
-rw-r--r--gui/src/shared/daemon-rpc-types.ts2
-rw-r--r--gui/src/shared/notifications/error.ts103
2 files changed, 53 insertions, 52 deletions
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index 2c79bc02a5..1f1779a4b0 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -112,7 +112,7 @@ export type TunnelState =
| { state: 'error'; details: IErrorState };
export interface IErrorState {
- isBlocking: boolean;
+ blockFailure?: FirewallPolicyError;
cause: ErrorStateCause;
}
diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts
index 9ab008aa70..7b438edb54 100644
--- a/gui/src/shared/notifications/error.ts
+++ b/gui/src/shared/notifications/error.ts
@@ -5,6 +5,7 @@ import {
IErrorState,
TunnelState,
TunnelParameterError,
+ ErrorStateCause,
FirewallPolicyError,
} from '../daemon-rpc-types';
import { messages } from '../gettext';
@@ -32,7 +33,7 @@ export class ErrorNotificationProvider
this.context.tunnelState,
this.context.accountExpiry,
),
- critical: !this.context.tunnelState.details.isBlocking,
+ critical: !!this.context.tunnelState.details.blockFailure,
}
: undefined;
}
@@ -41,7 +42,7 @@ export class ErrorNotificationProvider
return this.context.tunnelState.state === 'error'
? {
indicator: 'error',
- title: this.context.tunnelState.details.isBlocking
+ title: !this.context.tunnelState.details.blockFailure
? messages.pgettext('in-app-notifications', 'BLOCKING INTERNET')
: messages.pgettext('in-app-notifications', 'YOU MIGHT BE LEAKING NETWORK TRAFFIC'),
subtitle: getInAppNotificationSubtitle(this.context.tunnelState),
@@ -54,7 +55,7 @@ function getSystemNotificationMessage(
tunnelState: { state: 'error'; details: IErrorState },
accountExpiry?: string,
) {
- if (!tunnelState.details.isBlocking) {
+ if (tunnelState.details.blockFailure) {
return messages.pgettext('notifications', 'Critical error (your attention is required)');
} else if (
(tunnelState.details.cause.reason === 'auth_failed' &&
@@ -80,56 +81,56 @@ function getSystemNotificationMessage(
}
function getInAppNotificationSubtitle(tunnelState: { state: 'error'; details: IErrorState }) {
- if (!tunnelState.details.isBlocking) {
- const errorReason = tunnelState.details.cause;
- switch (errorReason.reason) {
- case 'set_firewall_policy_error': {
- const extraMessage = getPolicyMessage(errorReason.details);
- // TODO: check if message makes sense
- return `${messages.pgettext(
- 'in-app-notifications',
- 'Failed to block all network traffic',
- )}${extraMessage ? '. ' + extraMessage : ''}`;
- }
- }
- return messages.pgettext(
+ let blockFailureMessage = null;
+ if (tunnelState.details.blockFailure) {
+ const extraMessage = getPolicyMessage(tunnelState.details.blockFailure);
+ blockFailureMessage = `${messages.pgettext(
'in-app-notifications',
- 'Failed to block all network traffic. Please troubleshoot or report the problem to us.',
- );
- } else {
- const blockReason = tunnelState.details.cause;
- switch (blockReason.reason) {
- case 'auth_failed':
- return parseAuthFailure(blockReason.details).message;
- case 'ipv6_unavailable':
- return messages.pgettext(
- 'in-app-notifications',
- 'Could not configure IPv6, please enable it on your system or disable it in the app',
- );
- case 'set_firewall_policy_error': {
- const extraMessage = getPolicyMessage(blockReason.details);
- return `${messages.pgettext(
- 'in-app-notifications',
- 'Failed to apply firewall rules. The device might currently be unsecured',
- )}${extraMessage ? '. ' + extraMessage : ''}`;
- }
- case 'set_dns_error':
- 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 'tunnel_parameter_error':
- return getTunnelParameterMessage(blockReason.details);
- case 'is_offline':
- return messages.pgettext(
- 'in-app-notifications',
- 'This device is offline, no tunnels can be established',
- );
- case 'tap_adapter_problem':
- return messages.pgettext(
- 'in-app-notifications',
- "Unable to detect a working TAP adapter on this device. If you've disabled it, enable it again. Otherwise, please reinstall the app",
- );
+ 'Failed to block all network traffic',
+ )}${extraMessage ? '. ' + extraMessage : ''}`;
+ }
+
+ const blockMessage = getBlockMessage(tunnelState.details.cause);
+ return blockFailureMessage
+ ? `${blockFailureMessage}. ${messages.pgettext(
+ 'in-app-notifications',
+ 'Original block reason',
+ )}: ${blockMessage}`
+ : blockMessage;
+}
+
+function getBlockMessage(blockReason: ErrorStateCause): string {
+ switch (blockReason.reason) {
+ case 'auth_failed':
+ return parseAuthFailure(blockReason.details).message;
+ case 'ipv6_unavailable':
+ return messages.pgettext(
+ 'in-app-notifications',
+ 'Could not configure IPv6, please enable it on your system or disable it in the app',
+ );
+ case 'set_firewall_policy_error': {
+ const extraMessage = getPolicyMessage(blockReason.details);
+ return `${messages.pgettext(
+ 'in-app-notifications',
+ 'Failed to apply firewall rules. The device might currently be unsecured',
+ )}${extraMessage ? '. ' + extraMessage : ''}`;
}
+ case 'set_dns_error':
+ 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 'tunnel_parameter_error':
+ return getTunnelParameterMessage(blockReason.details);
+ case 'is_offline':
+ return messages.pgettext(
+ 'in-app-notifications',
+ 'This device is offline, no tunnels can be established',
+ );
+ case 'tap_adapter_problem':
+ return messages.pgettext(
+ 'in-app-notifications',
+ "Unable to detect a working TAP adapter on this device. If you've disabled it, enable it again. Otherwise, please reinstall the app",
+ );
}
}