summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts3
-rw-r--r--gui/src/main/linux-desktop-entry.ts6
-rw-r--r--gui/src/main/linux-split-tunneling.ts23
-rw-r--r--gui/src/renderer/app.tsx6
-rw-r--r--gui/src/renderer/components/LinuxSplitTunnelingSettings.tsx6
5 files changed, 33 insertions, 11 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 53a572ede1..190f575e94 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -1132,8 +1132,7 @@ class ApplicationMain {
});
IpcMainEventChannel.splitTunneling.handleLaunchApplication((application) => {
if (linuxSplitTunneling) {
- linuxSplitTunneling.launchApplication(application);
- return Promise.resolve();
+ return linuxSplitTunneling.launchApplication(application);
} else {
throw Error('linuxSplitTunneling called without being imported');
}
diff --git a/gui/src/main/linux-desktop-entry.ts b/gui/src/main/linux-desktop-entry.ts
index 03ee359b3a..291079aea8 100644
--- a/gui/src/main/linux-desktop-entry.ts
+++ b/gui/src/main/linux-desktop-entry.ts
@@ -39,7 +39,7 @@ const LIST_KEYS = ['onlyShowIn', 'notShowIn'];
// Parses a desktop entry at a specific path. Implemented in accordance with the freedesktop.org's
// Desktop Entry Specification:
// https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
-export async function readDesktopEntry(entryPath: string, locale: string): Promise<DesktopEntry> {
+export async function readDesktopEntry(entryPath: string, locale?: string): Promise<DesktopEntry> {
// First the lines corresponding to desktop entry group is extracted from the file
const contents = (await fs.promises.readFile(entryPath)).toString().split('\n');
// The group start is indicated by `[Desktop Entry]`
@@ -56,7 +56,7 @@ export async function readDesktopEntry(entryPath: string, locale: string): Promi
function parseDesktopEntry(
absolutepath: string,
desktopEntry: string[],
- locale: string,
+ locale?: string,
): DesktopEntry {
const parsed: Partial<DesktopEntry> = desktopEntry.reduce(
(entry, line) => parseDesktopEntryLine(entry, line, locale),
@@ -75,7 +75,7 @@ function parseDesktopEntry(
function parseDesktopEntryLine(
entry: Partial<DesktopEntry>,
line: string,
- locale: string,
+ locale?: string,
): Partial<DesktopEntry> {
// Comments start with `#` and keys and values are seperated by a `=`
if (!line.startsWith('#') && line.includes('=')) {
diff --git a/gui/src/main/linux-split-tunneling.ts b/gui/src/main/linux-split-tunneling.ts
index c739ed585e..acaa674746 100644
--- a/gui/src/main/linux-split-tunneling.ts
+++ b/gui/src/main/linux-split-tunneling.ts
@@ -25,9 +25,26 @@ const PROBLEMATIC_APPLICATIONS = {
launchingElsewhere: ['gnome-terminal'],
};
-export function launchApplication(app: ILinuxSplitTunnelingApplication | string) {
- const excludeArguments = typeof app === 'string' ? [app] : formatExec(app.exec);
- child_process.spawn('mullvad-exclude', excludeArguments, { detached: true });
+export async function launchApplication(
+ app: ILinuxSplitTunnelingApplication | string,
+): Promise<void> {
+ let excludeArguments: string[] | undefined;
+ if (typeof app === 'object') {
+ excludeArguments = formatExec(app.exec);
+ } else if (path.extname(app) === '.desktop') {
+ const entry = await readDesktopEntry(app);
+ if (entry.exec !== undefined) {
+ excludeArguments = formatExec(entry.exec);
+ }
+ } else {
+ excludeArguments = [app];
+ }
+
+ if (excludeArguments !== undefined && excludeArguments.length > 0) {
+ child_process.spawn('mullvad-exclude', excludeArguments, { detached: true });
+ } else {
+ throw new Error('Invalid application');
+ }
}
// Removes placeholder arguments and separates command into list of strings
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 9ba1e61252..739ac48ffe 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -419,8 +419,10 @@ export default class AppRenderer {
return IpcRendererEventChannel.splitTunneling.getApplications();
}
- public launchExcludedApplication(application: ILinuxSplitTunnelingApplication | string) {
- consumePromise(IpcRendererEventChannel.splitTunneling.launchApplication(application));
+ public launchExcludedApplication(
+ application: ILinuxSplitTunnelingApplication | string,
+ ): Promise<void> {
+ return IpcRendererEventChannel.splitTunneling.launchApplication(application);
}
public collectProblemReport(toRedact: string[]): Promise<string> {
diff --git a/gui/src/renderer/components/LinuxSplitTunnelingSettings.tsx b/gui/src/renderer/components/LinuxSplitTunnelingSettings.tsx
index 3c07e7eca0..58ef92d084 100644
--- a/gui/src/renderer/components/LinuxSplitTunnelingSettings.tsx
+++ b/gui/src/renderer/components/LinuxSplitTunnelingSettings.tsx
@@ -119,7 +119,11 @@ export default function LinuxSplitTunnelingSettings() {
setBrowsing(false);
if (file.filePaths[0]) {
- launchExcludedApplication(file.filePaths[0]);
+ try {
+ await launchExcludedApplication(file.filePaths[0]);
+ } catch (e) {
+ // TODO: Show user that app couldn't be launched
+ }
}
}, []);