Skip to content

Commit

Permalink
WIP: Add macOS split tunneling
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed May 13, 2024
1 parent c828a96 commit 0140349
Show file tree
Hide file tree
Showing 8 changed files with 832 additions and 512 deletions.
92 changes: 84 additions & 8 deletions gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-redux": "^7.2.9",
"react-router": "^5.3.4",
"redux": "^4.2.0",
"simple-plist": "^1.3.1",
"sprintf-js": "^1.1.2",
"styled-components": "^6.1.0"
},
Expand Down
37 changes: 28 additions & 9 deletions gui/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import util from 'util';

import config from '../config.json';
import { hasExpired } from '../shared/account-expiry';
import { IWindowsApplication } from '../shared/application-types';
import {
IMacOsSplitTunnelingAppListRetriever,
IWindowsApplication,
IWindowsSplitTunnelingAppListRetriever,
} from '../shared/application-types';
import {
AccessMethodSetting,
DaemonEvent,
Expand Down Expand Up @@ -48,6 +52,7 @@ import {
IpcInput,
OLD_LOG_FILES,
} from './logging';
import MacOsSplitTunnelingAppListRetriever from './macos-split-tunneling';
import NotificationController, {
NotificationControllerDelegate,
NotificationSender,
Expand All @@ -62,12 +67,21 @@ import TunnelStateHandler, {
} from './tunnel-state';
import UserInterface, { UserInterfaceDelegate } from './user-interface';
import Version, { GUI_VERSION } from './version';
import WindowsSplitTunnelingAppListRetriever from './windows-split-tunneling';

const execAsync = util.promisify(exec);

// Only import split tunneling library on correct OS.
const linuxSplitTunneling = process.platform === 'linux' && require('./linux-split-tunneling');
const windowsSplitTunneling = process.platform === 'win32' && require('./windows-split-tunneling');
const windowsSplitTunneling:
| IWindowsSplitTunnelingAppListRetriever
| IMacOsSplitTunnelingAppListRetriever
| undefined =
process.platform === 'win32'
? new WindowsSplitTunnelingAppListRetriever()
: process.platform === 'darwin'
? new MacOsSplitTunnelingAppListRetriever()
: undefined;

const ALLOWED_PERMISSIONS = ['clipboard-sanitized-write'];

Expand Down Expand Up @@ -734,9 +748,7 @@ class ApplicationMain
}

private async updateSplitTunnelingApplications(appList: string[]): Promise<void> {
const { applications } = await windowsSplitTunneling.getApplications({
applicationPaths: appList,
});
const { applications } = await windowsSplitTunneling!.getMetadataForApplications(appList);
this.windowsSplitTunnelingApplications = applications;

IpcMainEventChannel.windowsSplitTunneling.notify?.(applications);
Expand Down Expand Up @@ -790,7 +802,7 @@ class ApplicationMain
return linuxSplitTunneling.getApplications(this.locale);
});
IpcMainEventChannel.windowsSplitTunneling.handleGetApplications((updateCaches: boolean) => {
return windowsSplitTunneling.getApplications({ updateCaches });
return windowsSplitTunneling!.getApplications(updateCaches);
});
IpcMainEventChannel.linuxSplitTunneling.handleLaunchApplication((application) => {
return linuxSplitTunneling.launchApplication(application);
Expand All @@ -804,8 +816,14 @@ class ApplicationMain
// that we want to add to the list of additional applications.
if (typeof application === 'string') {
this.settings.gui.addBrowsedForSplitTunnelingApplications(application);
const applicationPath = await windowsSplitTunneling.addApplicationPathToCache(application);
await this.daemonRpc.addSplitTunnelingApplication(applicationPath);
if (windowsSplitTunneling instanceof WindowsSplitTunnelingAppListRetriever) {
const applicationPath = await windowsSplitTunneling.addApplicationPathToCache(
application,
);
await this.daemonRpc.addSplitTunnelingApplication(applicationPath);
} else {
await this.daemonRpc.addSplitTunnelingApplication(application);
}
} else {
await this.daemonRpc.addSplitTunnelingApplication(application.absolutepath);
}
Expand All @@ -818,7 +836,8 @@ class ApplicationMain
IpcMainEventChannel.windowsSplitTunneling.handleForgetManuallyAddedApplication(
(application) => {
this.settings.gui.deleteBrowsedForSplitTunnelingApplications(application.absolutepath);
return windowsSplitTunneling.removeApplicationFromCache(application);
windowsSplitTunneling!.removeApplicationFromCache(application);
return Promise.resolve();
},
);

Expand Down
Loading

0 comments on commit 0140349

Please sign in to comment.