diff options
| author | Jonathan <jonathan@mullvad.net> | 2023-12-05 10:03:08 +0100 |
|---|---|---|
| committer | Jonathan <jonathan@mullvad.net> | 2024-01-03 14:38:41 +0100 |
| commit | 4fdc34acbba60d5092e45ce3e513d30ec996c317 (patch) | |
| tree | 80d3a23c1a96bd3d80e05ac66b530e39c252d48a /gui/src/renderer | |
| parent | c510df96772b1e4ab7998e739ced42806c78e931 (diff) | |
| download | mullvadvpn-4fdc34acbba60d5092e45ce3e513d30ec996c317.tar.xz mullvadvpn-4fdc34acbba60d5092e45ce3e513d30ec996c317.zip | |
Allow app to use custom socks5 and shadwosocks proxies
This PR has a couple of different purposes
- Allow users to use socks5 local proxies with the CLI without
having to be root nor use split-tunneling. This only works for
OpenVPN.
- Unify the types used by different proxy parts of the codebase,
such as the Access Methods as well as some already existing
OpenVPN proxy code.
This PR changes the firewall on all desktop platforms as well as changes
the routing table slightly on MacOS and Windows.
On Linux the firewall code is modified to apply the appropriate firewall
marks to all packages that go to a remote endpoint corresponding to the
remote part of a local socks5 proxy. The firewall marks will allow the
routing to be done without having to modify the routing table.
On MacOS and Windows the routing table is modified to allow packages to
go to that same endpoint to pass outside the VPN tunnel, it will
additionally punch a hole in the firewall.
The PR also migrates the settings file from version 7 to version 8 in order
to properly and neatly unify Proxy related types.
Finally it provides some slight extensions to the gRPC interface in
order to allow for control over the custom proxy settings.
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/app.tsx | 18 | ||||
| -rw-r--r-- | gui/src/renderer/components/select-location/select-location-hooks.ts | 14 | ||||
| -rw-r--r-- | gui/src/renderer/lib/utilityHooks.ts | 2 | ||||
| -rw-r--r-- | gui/src/renderer/redux/settings/reducers.ts | 15 |
4 files changed, 26 insertions, 23 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index b5eacf17b3..3806c12413 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -624,17 +624,13 @@ export default class AppRenderer { private setBridgeSettings(bridgeSettings: BridgeSettings) { const actions = this.reduxActions; - if ('normal' in bridgeSettings) { - actions.settings.updateBridgeSettings({ - normal: { - location: liftConstraint(bridgeSettings.normal.location), - }, - }); - } else if ('custom' in bridgeSettings) { - actions.settings.updateBridgeSettings({ - custom: bridgeSettings.custom, - }); - } + actions.settings.updateBridgeSettings({ + type: bridgeSettings.type, + normal: { + location: liftConstraint(bridgeSettings.normal.location), + }, + custom: bridgeSettings.custom, + }); } private onDaemonConnected() { diff --git a/gui/src/renderer/components/select-location/select-location-hooks.ts b/gui/src/renderer/components/select-location/select-location-hooks.ts index 48d81e594c..b795f4a74f 100644 --- a/gui/src/renderer/components/select-location/select-location-hooks.ts +++ b/gui/src/renderer/components/select-location/select-location-hooks.ts @@ -11,6 +11,7 @@ import log from '../../../shared/logging'; import { useAppContext } from '../../context'; import { useRelaySettingsModifier } from '../../lib/constraint-updater'; import { useHistory } from '../../lib/history'; +import { useSelector } from '../../redux/store'; import { LocationType, SpecialBridgeLocationType } from './select-location-types'; import { useSelectLocationContext } from './SelectLocationContainer'; @@ -88,6 +89,7 @@ function useOnSelectLocation() { export function useOnSelectBridgeLocation() { const { updateBridgeSettings } = useAppContext(); const { setLocationType } = useSelectLocationContext(); + const bridgeSettings = useSelector((state) => state.settings.bridgeSettings); const setLocation = useCallback(async (bridgeUpdate: BridgeSettings) => { if (bridgeUpdate) { @@ -101,10 +103,14 @@ export function useOnSelectBridgeLocation() { } }, []); - const onSelectRelay = useCallback((location: RelayLocation) => { - const bridgeUpdate = new BridgeSettingsBuilder().location.fromRaw(location).build(); - return setLocation(bridgeUpdate); - }, []); + const onSelectRelay = useCallback( + (location: RelayLocation) => { + const bridgeUpdate = new BridgeSettingsBuilder().location.fromRaw(location).build(); + bridgeUpdate.custom = bridgeSettings.custom; + return setLocation(bridgeUpdate); + }, + [bridgeSettings], + ); const onSelectSpecial = useCallback((location: SpecialBridgeLocationType) => { switch (location) { diff --git a/gui/src/renderer/lib/utilityHooks.ts b/gui/src/renderer/lib/utilityHooks.ts index 49f508a883..8c3925762e 100644 --- a/gui/src/renderer/lib/utilityHooks.ts +++ b/gui/src/renderer/lib/utilityHooks.ts @@ -67,5 +67,5 @@ export function useNormalRelaySettings() { export function useNormalBridgeSettings() { const bridgeSettings = useSelector((state) => state.settings.bridgeSettings); - return 'normal' in bridgeSettings ? bridgeSettings.normal : undefined; + return bridgeSettings.normal; } diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts index b400799095..3d03093e0a 100644 --- a/gui/src/renderer/redux/settings/reducers.ts +++ b/gui/src/renderer/redux/settings/reducers.ts @@ -1,6 +1,7 @@ import { IWindowsApplication } from '../../../shared/application-types'; import { BridgeState, + BridgeType, CustomLists, IDnsOptions, IpVersion, @@ -51,13 +52,11 @@ export type RelaySettingsRedux = }; }; -export type BridgeSettingsRedux = - | { - normal: NormalBridgeSettingsRedux; - } - | { - custom: ProxySettings; - }; +export type BridgeSettingsRedux = { + type: BridgeType; + normal: NormalBridgeSettingsRedux; + custom?: ProxySettings; +}; export interface IRelayLocationRelayRedux { hostname: string; @@ -140,9 +139,11 @@ const initialState: ISettingsReduxState = { allowLan: false, enableIpv6: true, bridgeSettings: { + type: 'normal', normal: { location: 'any', }, + custom: undefined, }, bridgeState: 'auto', blockWhenDisconnected: false, |
