diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-01-03 14:23:02 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-01-03 14:23:02 +0100 |
| commit | 5e72bac67addd36682443568de651fc05cd6e207 (patch) | |
| tree | 750ac3f0737f4580258c69540e491303ac619461 /gui/src/main | |
| parent | f4cd4fc51955874f7e7ac13636b63ecfa8f9eaf3 (diff) | |
| parent | c7027fac2b5db7a2a19f1f79137b1a2d371335cb (diff) | |
| download | mullvadvpn-5e72bac67addd36682443568de651fc05cd6e207.tar.xz mullvadvpn-5e72bac67addd36682443568de651fc05cd6e207.zip | |
Merge branch 'add-wg-multihop'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 32 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 27 |
2 files changed, 42 insertions, 17 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index a2416e9943..edfc3ec4cd 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -862,6 +862,9 @@ function convertFromTunnelStateRelayInfo( tunnelType: convertFromTunnelType(state.tunnelEndpoint.tunnelType), protocol: convertFromTransportProtocol(state.tunnelEndpoint.protocol), proxy: state.tunnelEndpoint.proxy && convertFromProxyEndpoint(state.tunnelEndpoint.proxy), + entryEndpoint: + state.tunnelEndpoint.entryEndpoint && + convertFromEntryEndpoint(state.tunnelEndpoint.entryEndpoint), }, }; } @@ -890,6 +893,13 @@ function convertFromProxyEndpoint(proxyEndpoint: grpcTypes.ProxyEndpoint.AsObjec }; } +function convertFromEntryEndpoint(entryEndpoint: grpcTypes.Endpoint.AsObject) { + return { + address: entryEndpoint.address, + transportProtocol: convertFromTransportProtocol(entryEndpoint.protocol), + }; +} + function convertFromSettings(settings: grpcTypes.Settings): ISettings | undefined { const settingsObject = settings.toObject(); const bridgeState = convertFromBridgeState(settingsObject.bridgeState!.state!); @@ -1172,7 +1182,12 @@ function convertFromOpenVpnConstraints( function convertFromWireguardConstraints( constraints: grpcTypes.WireguardConstraints, ): IWireguardConstraints { - const result: IWireguardConstraints = { port: 'any', ipVersion: 'any' }; + const result: IWireguardConstraints = { + port: 'any', + ipVersion: 'any', + useMultihop: constraints.getUseMultihop(), + entryLocation: 'any', + }; const port = constraints.getPort()?.getPort(); if (port) { @@ -1189,6 +1204,11 @@ function convertFromWireguardConstraints( break; } + const entryLocation = constraints.getEntryLocation(); + if (entryLocation) { + result.entryLocation = { only: convertFromLocation(entryLocation.toObject()) }; + } + return result; } @@ -1310,6 +1330,16 @@ function convertToWireguardConstraints( wireguardConstraints.setIpVersion(ipVersionConstraints); } + if (constraint.useMultihop) { + wireguardConstraints.setUseMultihop(constraint.useMultihop); + } + + const entryLocation = liftConstraint(constraint.entryLocation); + if (entryLocation) { + const entryLocationConstraint = convertToLocation(entryLocation); + wireguardConstraints.setEntryLocation(entryLocationConstraint); + } + return wireguardConstraints; } return undefined; diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 5bce63cc2d..a2c49bcacc 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -158,6 +158,8 @@ class ApplicationMain { wireguardConstraints: { port: 'any', ipVersion: 'any', + useMultihop: false, + entryLocation: 'any', }, }, }, @@ -905,11 +907,7 @@ class ApplicationMain { ) { this.relays = newRelayList; - const filteredRelays = this.processRelaysForPresentation( - newRelayList, - relaySettings, - bridgeState, - ); + const filteredRelays = this.processRelaysForPresentation(newRelayList, relaySettings); const filteredBridges = this.processBridgesForPresentation(newRelayList, bridgeState); if (this.windowController) { @@ -923,7 +921,6 @@ class ApplicationMain { private processRelaysForPresentation( relayList: IRelayList, relaySettings: RelaySettings, - bridgeState: BridgeState, ): IRelayList { const tunnelProtocol = 'normal' in relaySettings ? liftConstraint(relaySettings.normal.tunnelProtocol) : undefined; @@ -943,14 +940,16 @@ class ApplicationMain { case 'wireguard': return relay.tunnels.wireguard.length > 0; - case 'any': - // TODO: Drop win32 check when Wireguard becomes default on Windows - if (process.platform === 'win32' || bridgeState === 'on') { - return relay.tunnels.openvpn.length > 0; + case 'any': { + const useMultihop = + 'normal' in relaySettings && + relaySettings.normal.wireguardConstraints.useMultihop; + if (useMultihop) { + return relay.tunnels.wireguard.length > 0; } else { return relay.tunnels.openvpn.length > 0 || relay.tunnels.wireguard.length > 0; } - + } default: return false; } @@ -1151,11 +1150,7 @@ class ApplicationMain { tunnelState: this.tunnelState, settings: this.settings, relayListPair: { - relays: this.processRelaysForPresentation( - this.relays, - this.settings.relaySettings, - this.settings.bridgeState, - ), + relays: this.processRelaysForPresentation(this.relays, this.settings.relaySettings), bridges: this.processBridgesForPresentation(this.relays, this.settings.bridgeState), }, currentVersion: this.currentVersion, |
