diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-07-27 19:13:43 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-08-04 10:52:43 +0200 |
| commit | 19bb453f237a6a0c467710b1b5ff3f7081cb7c8f (patch) | |
| tree | 0b9bc034f4b047ede6ecbd0c8d36059a2ea9755b /gui/src | |
| parent | ce266572221e7a1c5dc7e90646dc3f7708f1c6f9 (diff) | |
| download | mullvadvpn-19bb453f237a6a0c467710b1b5ff3f7081cb7c8f.tar.xz mullvadvpn-19bb453f237a6a0c467710b1b5ff3f7081cb7c8f.zip | |
Display reason for being in a non-blocking error state
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/shared/notifications/error.ts | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts index 748e8130a7..9ab008aa70 100644 --- a/gui/src/shared/notifications/error.ts +++ b/gui/src/shared/notifications/error.ts @@ -1,7 +1,12 @@ import { sprintf } from 'sprintf-js'; import { hasExpired } from '../account-expiry'; import { AuthFailureKind, parseAuthFailure } from '../auth-failure'; -import { IErrorState, TunnelState, TunnelParameterError } from '../daemon-rpc-types'; +import { + IErrorState, + TunnelState, + TunnelParameterError, + FirewallPolicyError, +} from '../daemon-rpc-types'; import { messages } from '../gettext'; import { InAppNotification, @@ -76,6 +81,17 @@ 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( 'in-app-notifications', 'Failed to block all network traffic. Please troubleshoot or report the problem to us.', @@ -91,30 +107,7 @@ function getInAppNotificationSubtitle(tunnelState: { state: 'error'; details: IE 'Could not configure IPv6, please enable it on your system or disable it in the app', ); case 'set_firewall_policy_error': { - let extraMessage = null; - switch (process.platform) { - case 'linux': - extraMessage = messages.pgettext('in-app-notifications', 'Your kernel may be outdated'); - break; - case 'win32': - switch (blockReason.details.reason) { - case 'locked': - if (blockReason.details.details) { - // TODO: Check if this message is ok - extraMessage = `${messages.pgettext( - 'in-app-notifications', - 'An application prevented the policy from being set', - )}: ${blockReason.details.details.name}`; - } else { - extraMessage = messages.pgettext( - 'in-app-notifications', - 'This might be caused by third party security software', - ); - } - break; - } - break; - } + const extraMessage = getPolicyMessage(blockReason.details); return `${messages.pgettext( 'in-app-notifications', 'Failed to apply firewall rules. The device might currently be unsecured', @@ -140,6 +133,34 @@ function getInAppNotificationSubtitle(tunnelState: { state: 'error'; details: IE } } +function getPolicyMessage(err: FirewallPolicyError): string | null { + let extraMessage = null; + switch (process.platform) { + case 'linux': + extraMessage = messages.pgettext('in-app-notifications', 'Your kernel may be outdated'); + break; + case 'win32': + switch (err.reason) { + case 'locked': + if (err.details) { + // TODO: Check if this message is ok + extraMessage = `${messages.pgettext( + 'in-app-notifications', + 'An application prevented the policy from being set', + )}: ${err.details.name}`; + } else { + extraMessage = messages.pgettext( + 'in-app-notifications', + 'This might be caused by third party security software', + ); + } + break; + } + break; + } + return extraMessage; +} + function getTunnelParameterMessage(err: TunnelParameterError): string { switch (err) { /// TODO: once bridge constraints can be set, add a more descriptive error message |
