1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
import { sprintf } from 'sprintf-js';
import { strings } from '../../config.json';
import {
AuthFailedError,
ErrorStateCause,
ErrorStateDetails,
TunnelParameterError,
TunnelState,
} from '../daemon-rpc-types';
import { messages } from '../gettext';
import {
InAppNotification,
InAppNotificationAction,
InAppNotificationProvider,
SystemNotification,
SystemNotificationCategory,
SystemNotificationProvider,
SystemNotificationSeverityType,
} from './notification';
interface ErrorNotificationContext {
tunnelState: TunnelState;
hasExcludedApps: boolean;
showFullDiskAccessSettings?: () => void;
}
export class ErrorNotificationProvider
implements SystemNotificationProvider, InAppNotificationProvider
{
public constructor(private context: ErrorNotificationContext) {}
public mayDisplay = () => this.context.tunnelState.state === 'error';
public getSystemNotification(): SystemNotification | undefined {
if (this.context.tunnelState.state === 'error') {
let message = this.getMessage(this.context.tunnelState.details);
if (!this.context.tunnelState.details.blockingError && this.context.hasExcludedApps) {
message = `${message} ${sprintf(
messages.pgettext(
'notifications',
'The apps excluded with %(splitTunneling)s might not work properly right now.',
),
{ splitTunneling: strings.splitTunneling.toLowerCase() },
)}`;
}
return {
message,
severity:
this.context.tunnelState.details.blockingError === undefined
? SystemNotificationSeverityType.low
: SystemNotificationSeverityType.high,
category: SystemNotificationCategory.tunnelState,
};
} else {
return undefined;
}
}
public getInAppNotification(): InAppNotification | undefined {
if (this.context.tunnelState.state === 'error') {
let subtitle = this.getMessage(this.context.tunnelState.details);
if (!this.context.tunnelState.details.blockingError && this.context.hasExcludedApps) {
subtitle = `${subtitle} ${sprintf(
messages.pgettext(
'notifications',
'The apps excluded with %(splitTunneling)s might not work properly right now.',
),
{ splitTunneling: strings.splitTunneling.toLowerCase() },
)}`;
}
return {
indicator:
this.context.tunnelState.details.cause === ErrorStateCause.isOffline
? 'warning'
: 'error',
title: this.context.tunnelState.details.blockingError
? messages.pgettext('in-app-notifications', 'NETWORK TRAFFIC MIGHT BE LEAKING')
: messages.pgettext('in-app-notifications', 'BLOCKING INTERNET'),
subtitle,
action: this.getActions(this.context.tunnelState.details) ?? undefined,
};
} else {
return undefined;
}
}
private getMessage(errorState: ErrorStateDetails): string {
if (errorState.blockingError) {
if (errorState.cause === ErrorStateCause.setFirewallPolicyError) {
switch (process.platform ?? window.env.platform) {
case 'win32':
return messages.pgettext(
'notifications',
'Unable to block all network traffic. Try temporarily disabling any third-party antivirus or security software or send a problem report.',
);
case 'linux':
return messages.pgettext(
'notifications',
'Unable to block all network traffic. Try updating your kernel or send a problem report.',
);
}
}
return messages.pgettext(
'notifications',
'Unable to block all network traffic. Please troubleshoot or send a problem report.',
);
} else {
switch (errorState.cause) {
case ErrorStateCause.authFailed:
switch (errorState.authFailedError) {
case AuthFailedError.invalidAccount:
return messages.pgettext(
'auth-failure',
'You are logged in with an invalid account number. Please log out and try another one.',
);
case AuthFailedError.expiredAccount:
return messages.pgettext('auth-failure', 'Blocking internet: account is out of time');
case AuthFailedError.tooManyConnections:
return messages.pgettext(
'auth-failure',
'Too many simultaneous connections on this account. Disconnect another device or try connecting again shortly.',
);
case AuthFailedError.unknown:
default:
return messages.pgettext(
'auth-failure',
'Unable to authenticate account. Please send a problem report.',
);
}
case ErrorStateCause.ipv6Unavailable:
return messages.pgettext(
'notifications',
'Could not configure IPv6. Disable it in the app or enable it on your device.',
);
case ErrorStateCause.setFirewallPolicyError:
switch (process.platform ?? window.env.platform) {
case 'win32':
return messages.pgettext(
'notifications',
'Unable to apply firewall rules. Try temporarily disabling any third-party antivirus or security software.',
);
case 'linux':
return messages.pgettext(
'notifications',
'Unable to apply firewall rules. Try updating your kernel.',
);
default:
return messages.pgettext('notifications', 'Unable to apply firewall rules.');
}
case ErrorStateCause.setDnsError:
return messages.pgettext(
'notifications',
'Unable to set system DNS server. Please send a problem report.',
);
case ErrorStateCause.startTunnelError:
return messages.pgettext(
'notifications',
'Unable to start tunnel connection. Please send a problem report.',
);
case ErrorStateCause.createTunnelDeviceError:
if (errorState.osError === 4319) {
return messages.pgettext(
'notifications',
'Unable to start tunnel connection. This could be because of conflicts with VMware, please troubleshoot.',
);
}
return messages.pgettext(
'notifications',
'Unable to start tunnel connection. Please send a problem report.',
);
case ErrorStateCause.tunnelParameterError:
return this.getTunnelParameterMessage(errorState.parameterError);
case ErrorStateCause.isOffline:
return messages.pgettext(
'notifications',
'Your device is offline. The tunnel will automatically connect once your device is back online.',
);
case ErrorStateCause.needFullDiskPermissions:
return messages.pgettext('notifications', 'Failed to enable split tunneling.');
case ErrorStateCause.splitTunnelError:
switch (process.platform ?? window.env.platform) {
case 'darwin':
return messages.pgettext(
'notifications',
'Failed to enable split tunneling. Please try reconnecting or disable split tunneling.',
);
default:
return messages.pgettext(
'notifications',
'Unable to communicate with Mullvad kernel driver. Try reconnecting or send a problem report.',
);
}
}
}
}
private getTunnelParameterMessage(error: TunnelParameterError): string {
switch (error) {
/// TODO: once bridge constraints can be set, add a more descriptive error message
case TunnelParameterError.noMatchingBridgeRelay:
case TunnelParameterError.noMatchingRelay:
return messages.pgettext(
'notifications',
'No servers match your settings, try changing server or other settings.',
);
case TunnelParameterError.noWireguardKey:
return sprintf(
// TRANSLATORS: Available placeholders:
// TRANSLATORS: %(wireguard)s - will be replaced with "WireGuard"
messages.pgettext(
'notifications',
'Valid %(wireguard)s key is missing. Manage keys under Advanced settings.',
),
{ wireguard: strings.wireguard },
);
case TunnelParameterError.customTunnelHostResolutionError:
return messages.pgettext(
'notifications',
'Unable to resolve host of custom tunnel. Try changing your settings.',
);
}
}
private getActions(errorState: ErrorStateDetails): InAppNotificationAction | void {
const platform = process.platform ?? window.env.platform;
if (errorState.cause === ErrorStateCause.setFirewallPolicyError && platform === 'linux') {
return {
type: 'troubleshoot-dialog',
troubleshoot: {
details: messages.pgettext('troubleshoot', 'This might be caused by an outdated kernel.'),
steps: [
messages.pgettext('troubleshoot', 'Update your kernel.'),
messages.pgettext('troubleshoot', 'Make sure you have NF tables support.'),
],
},
};
} else if (errorState.cause === ErrorStateCause.setDnsError) {
const troubleshootSteps = [];
if (platform === 'darwin') {
troubleshootSteps.push(
messages.pgettext(
'troubleshoot',
'Try to turn Wi-Fi Calling off in the FaceTime app settings and restart the Mac.',
),
messages.pgettext(
'troubleshoot',
'Uninstall or disable other DNS, networking and ads/website blocking apps.',
),
);
} else if (platform === 'win32') {
troubleshootSteps.push(
messages.pgettext(
'troubleshoot',
'Uninstall or disable other DNS, networking and ads/website blocking apps.',
),
);
}
return {
type: 'troubleshoot-dialog',
troubleshoot: {
details: messages.pgettext(
'troubleshoot',
'This error can happen when something other than Mullvad is actively updating the DNS.',
),
steps: troubleshootSteps,
},
};
} else if (errorState.cause === ErrorStateCause.needFullDiskPermissions) {
let troubleshootButtons = undefined;
if (this.context.showFullDiskAccessSettings) {
troubleshootButtons = [
{
label: messages.pgettext('troubleshoot', 'Open system settings'),
action: () => this.context.showFullDiskAccessSettings?.(),
},
];
}
return {
type: 'troubleshoot-dialog',
troubleshoot: {
details: messages.pgettext(
'troubleshoot',
'Failed to enable split tunneling. This is because the app is missing system permissions. What you can do:',
),
steps: [
messages.pgettext(
'troubleshoot',
'Enable “Full Disk Access” for “Mullvad VPN” in the macOS system settings.',
),
],
buttons: troubleshootButtons,
},
};
} else if (platform === 'win32' && errorState.cause === ErrorStateCause.splitTunnelError) {
return {
type: 'troubleshoot-dialog',
troubleshoot: {
details: messages.pgettext(
'troubleshoot',
'Unable to communicate with Mullvad kernel driver.',
),
steps: [
messages.pgettext('troubleshoot', 'Try reconnecting.'),
messages.pgettext('troubleshoot', 'Try restarting your device.'),
],
},
};
} else if (
errorState.cause === ErrorStateCause.createTunnelDeviceError &&
errorState.osError === 4319
) {
return {
type: 'troubleshoot-dialog',
troubleshoot: {
details: messages.pgettext(
'troubleshoot',
'Unable to start tunnel connection because of a failure when creating the tunnel device. This is often caused by conflicts with the VMware Bridge Protocol.',
),
steps: [
messages.pgettext('troubleshoot', 'Try to reinstall VMware.'),
messages.pgettext('troubleshoot', 'Try to uninstall VMware.'),
],
},
};
}
}
}
|