summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-07-02 16:15:24 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-07-02 16:15:24 +0200
commit0e68d9c85578e7d50b9bfeee7cbf14622bda8a3f (patch)
treef1b41a73c8a8210c003ea9b1154b7ff7fa315381 /gui/src/shared
parentf77cde89c6b8d3d580ee773628f89211a24852c5 (diff)
parent812a23b48b39b0da4f6c2ae5b4e0f856ff3b2df4 (diff)
downloadmullvadvpn-0e68d9c85578e7d50b9bfeee7cbf14622bda8a3f.tar.xz
mullvadvpn-0e68d9c85578e7d50b9bfeee7cbf14622bda8a3f.zip
Merge branch 'split-tunnel-frontend-ipc'
Diffstat (limited to 'gui/src/shared')
-rw-r--r--gui/src/shared/daemon-rpc-types.ts13
-rw-r--r--gui/src/shared/ipc-schema.ts18
-rw-r--r--gui/src/shared/notifications/block-when-disconnected.ts11
-rw-r--r--gui/src/shared/notifications/error.ts58
4 files changed, 77 insertions, 23 deletions
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index b0319369cf..4c806b11b8 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -34,7 +34,12 @@ export type TunnelParameterError =
export type ErrorStateCause =
| {
- reason: 'ipv6_unavailable' | 'set_dns_error' | 'start_tunnel_error' | 'is_offline';
+ reason:
+ | 'ipv6_unavailable'
+ | 'set_dns_error'
+ | 'start_tunnel_error'
+ | 'is_offline'
+ | 'split_tunnel_error';
}
| { reason: 'set_firewall_policy_error'; details: FirewallPolicyError }
| { reason: 'tunnel_parameter_error'; details: TunnelParameterError }
@@ -311,6 +316,7 @@ export interface ISettings {
tunnelOptions: ITunnelOptions;
bridgeSettings: BridgeSettings;
bridgeState: BridgeState;
+ splitTunnel: SplitTunnelSettings;
}
export type KeygenEvent = INewWireguardKey | KeygenFailure;
@@ -327,6 +333,11 @@ export interface IWireguardPublicKey {
export type BridgeState = 'auto' | 'on' | 'off';
+export type SplitTunnelSettings = {
+ enableExclusions: boolean;
+ appsList: string[];
+};
+
export interface IBridgeConstraints {
location: Constraint<RelayLocation>;
}
diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts
index 01c5c53a95..5789bcc149 100644
--- a/gui/src/shared/ipc-schema.ts
+++ b/gui/src/shared/ipc-schema.ts
@@ -1,5 +1,5 @@
import { GetTextTranslations } from 'gettext-parser';
-import { ILinuxSplitTunnelingApplication } from './application-types';
+import { IApplication, ILinuxSplitTunnelingApplication } from './application-types';
import {
AccountToken,
BridgeSettings,
@@ -56,6 +56,7 @@ export interface IAppStateSnapshot {
translations: ITranslations;
platform: NodeJS.Platform;
runningInDevelopment: boolean;
+ windowsSplitTunnelingApplications?: IApplication[];
}
// The different types of requests are:
@@ -178,10 +179,6 @@ export const ipcSchema = {
generateKey: invoke<void, KeygenEvent>(),
verifyKey: invoke<void, boolean>(),
},
- splitTunneling: {
- getApplications: invoke<void, ILinuxSplitTunnelingApplication[]>(),
- launchApplication: invoke<ILinuxSplitTunnelingApplication | string, LaunchApplicationResult>(),
- },
problemReport: {
collectLogs: invoke<string | undefined, string>(),
sendReport: invoke<{ email: string; message: string; savedReportId: string }, void>(),
@@ -190,4 +187,15 @@ export const ipcSchema = {
logging: {
log: send<ILogEntry>(),
},
+ linuxSplitTunneling: {
+ getApplications: invoke<void, ILinuxSplitTunnelingApplication[]>(),
+ launchApplication: invoke<ILinuxSplitTunnelingApplication | string, LaunchApplicationResult>(),
+ },
+ windowsSplitTunneling: {
+ '': notifyRenderer<IApplication[]>(),
+ setState: invoke<boolean, void>(),
+ getApplications: invoke<boolean, { fromCache: boolean; applications: IApplication[] }>(),
+ addApplication: invoke<IApplication | string, void>(),
+ removeApplication: invoke<IApplication | string, void>(),
+ },
};
diff --git a/gui/src/shared/notifications/block-when-disconnected.ts b/gui/src/shared/notifications/block-when-disconnected.ts
index fb19655993..6dcc3cc749 100644
--- a/gui/src/shared/notifications/block-when-disconnected.ts
+++ b/gui/src/shared/notifications/block-when-disconnected.ts
@@ -5,6 +5,7 @@ import { InAppNotification, InAppNotificationProvider } from './notification';
interface BlockWhenDisconnectedNotificationContext {
tunnelState: TunnelState;
blockWhenDisconnected: boolean;
+ hasExcludedApps: boolean;
}
export class BlockWhenDisconnectedNotificationProvider implements InAppNotificationProvider {
@@ -19,10 +20,18 @@ export class BlockWhenDisconnectedNotificationProvider implements InAppNotificat
}
public getInAppNotification(): InAppNotification {
+ let subtitle = messages.pgettext('in-app-notifications', '"Always require VPN" is enabled.');
+ if (this.context.hasExcludedApps) {
+ subtitle = `${subtitle} ${messages.pgettext(
+ 'notifications',
+ 'The apps excluded with split tunneling might not work properly right now.',
+ )}`;
+ }
+
return {
indicator: 'warning',
title: messages.pgettext('in-app-notifications', 'BLOCKING INTERNET'),
- subtitle: messages.pgettext('in-app-notifications', '"Always require VPN" is enabled.'),
+ subtitle,
};
}
}
diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts
index c5f15482dc..97e5e2ce93 100644
--- a/gui/src/shared/notifications/error.ts
+++ b/gui/src/shared/notifications/error.ts
@@ -11,6 +11,7 @@ import {
interface ErrorNotificationContext {
tunnelState: TunnelState;
accountExpiry?: string;
+ hasExcludedApps: boolean;
}
export class ErrorNotificationProvider
@@ -20,25 +21,45 @@ export class ErrorNotificationProvider
public mayDisplay = () => this.context.tunnelState.state === 'error';
public getSystemNotification() {
- return this.context.tunnelState.state === 'error'
- ? {
- message: getMessage(this.context.tunnelState.details, this.context.accountExpiry),
- critical: !!this.context.tunnelState.details.blockFailure,
- }
- : undefined;
+ if (this.context.tunnelState.state === 'error') {
+ let message = getMessage(this.context.tunnelState.details, this.context.accountExpiry);
+ if (!this.context.tunnelState.details.blockFailure && this.context.hasExcludedApps) {
+ message = `${message} ${messages.pgettext(
+ 'notifications',
+ 'The apps excluded with split tunneling might not work properly right now.',
+ )}`;
+ }
+
+ return {
+ message,
+ critical: !!this.context.tunnelState.details.blockFailure,
+ };
+ } else {
+ return undefined;
+ }
}
public getInAppNotification(): InAppNotification | undefined {
- return this.context.tunnelState.state === 'error'
- ? {
- indicator:
- this.context.tunnelState.details.cause.reason === 'is_offline' ? 'warning' : 'error',
- title: !this.context.tunnelState.details.blockFailure
- ? messages.pgettext('in-app-notifications', 'BLOCKING INTERNET')
- : messages.pgettext('in-app-notifications', 'NETWORK TRAFFIC MIGHT BE LEAKING'),
- subtitle: getMessage(this.context.tunnelState.details, this.context.accountExpiry),
- }
- : undefined;
+ if (this.context.tunnelState.state === 'error') {
+ let subtitle = getMessage(this.context.tunnelState.details, this.context.accountExpiry);
+ if (!this.context.tunnelState.details.blockFailure && this.context.hasExcludedApps) {
+ subtitle = `${subtitle} ${messages.pgettext(
+ 'notifications',
+ 'The apps excluded with split tunneling might not work properly right now.',
+ )}`;
+ }
+
+ return {
+ indicator:
+ this.context.tunnelState.details.cause.reason === 'is_offline' ? 'warning' : 'error',
+ title: !this.context.tunnelState.details.blockFailure
+ ? messages.pgettext('in-app-notifications', 'BLOCKING INTERNET')
+ : messages.pgettext('in-app-notifications', 'NETWORK TRAFFIC MIGHT BE LEAKING'),
+ subtitle,
+ };
+ } else {
+ return undefined;
+ }
}
}
@@ -117,6 +138,11 @@ function getMessage(errorDetails: IErrorState, accountExpiry?: string): string {
'notifications',
"Your device is offline. Try connecting when it's back online.",
);
+ case 'split_tunnel_error':
+ return messages.pgettext(
+ 'notifications',
+ 'Unable to communicate with Mullvad kernel driver. Try reconnecting or contact support.',
+ );
}
}
}