diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-12-06 08:55:59 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-01-03 13:48:03 +0100 |
| commit | b896f49438af2f482774a80f14b111c7c896f7be (patch) | |
| tree | 06986f74633f9a131684fc5c02a31dbb9fe8de21 /gui/src/renderer | |
| parent | 71404a0670fde113c76089a137716874174b58c0 (diff) | |
| download | mullvadvpn-b896f49438af2f482774a80f14b111c7c896f7be.tar.xz mullvadvpn-b896f49438af2f482774a80f14b111c7c896f7be.zip | |
Add entry location to relay-settings-builder
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/lib/constraint-updater.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gui/src/renderer/lib/constraint-updater.ts b/gui/src/renderer/lib/constraint-updater.ts new file mode 100644 index 0000000000..ce9f49f376 --- /dev/null +++ b/gui/src/renderer/lib/constraint-updater.ts @@ -0,0 +1,36 @@ +import { RelaySettingsRedux } from '../redux/settings/reducers'; +import RelaySettingsBuilder from '../../shared/relay-settings-builder'; + +export function createWireguardRelayUpdater( + relaySettings: RelaySettingsRedux, +): ReturnType<typeof RelaySettingsBuilder['normal']> { + if ('normal' in relaySettings) { + const constraints = relaySettings.normal.wireguard; + + const relayUpdate = RelaySettingsBuilder.normal().tunnel.wireguard((wireguard) => { + if (constraints.port === 'any') { + wireguard.port.any(); + } else { + wireguard.port.exact(constraints.port); + } + + if (constraints.ipVersion === 'any') { + wireguard.ipVersion.any(); + } else { + wireguard.ipVersion.exact(constraints.ipVersion); + } + + wireguard.useMultihop(constraints.useMultihop); + + if (constraints.entryLocation === 'any') { + wireguard.entryLocation.any(); + } else if (constraints.entryLocation !== undefined) { + wireguard.entryLocation.exact(constraints.entryLocation); + } + }); + + return relayUpdate; + } else { + return RelaySettingsBuilder.normal(); + } +} |
