summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-09-27 11:37:32 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-09-27 11:37:32 +0200
commit8c4d03d4f31069ba9648ffb22c056185d9706167 (patch)
tree5d61a310d8f70cbb4ccb5708395cc0e254ff81a9 /gui/src/main
parentde9bf32918295037d1616d256afedf52ab7d4b6d (diff)
parentdcdd4b44efb5f77148d262f4c573dd6aca0a5e03 (diff)
downloadmullvadvpn-8c4d03d4f31069ba9648ffb22c056185d9706167.tar.xz
mullvadvpn-8c4d03d4f31069ba9648ffb22c056185d9706167.zip
Merge branch 'add-custom-port-option'
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/daemon-rpc.ts29
-rw-r--r--gui/src/main/relay-list.ts36
2 files changed, 47 insertions, 18 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 950cf1a4a3..a6136bc6f3 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -31,14 +31,15 @@ import {
IObfuscationEndpoint,
IOpenVpnConstraints,
IProxyEndpoint,
- IRelayList,
IRelayListCity,
IRelayListCountry,
IRelayListHostname,
+ IRelayListWithEndpointData,
ISettings,
ITunnelOptions,
ITunnelStateRelayInfo,
IWireguardConstraints,
+ IWireguardEndpointData,
LoggedInDeviceState,
LoggedOutDeviceState,
ObfuscationSettings,
@@ -258,7 +259,7 @@ export class DaemonRpc {
}
}
- public async getRelayLocations(): Promise<IRelayList> {
+ public async getRelayLocations(): Promise<IRelayListWithEndpointData> {
if (this.isConnected) {
const response = await this.callEmpty<grpcTypes.RelayList>(this.client.getRelayLocations);
return convertFromRelayList(response);
@@ -757,13 +758,25 @@ function liftConstraint<T>(constraint: Constraint<T> | undefined): T | undefined
return undefined;
}
-function convertFromRelayList(relayList: grpcTypes.RelayList): IRelayList {
+function convertFromRelayList(relayList: grpcTypes.RelayList): IRelayListWithEndpointData {
return {
- countries: relayList
- .getCountriesList()
- .map((country: grpcTypes.RelayListCountry) =>
- convertFromRelayListCountry(country.toObject()),
- ),
+ relayList: {
+ countries: relayList
+ .getCountriesList()
+ .map((country: grpcTypes.RelayListCountry) =>
+ convertFromRelayListCountry(country.toObject()),
+ ),
+ },
+ wireguardEndpointData: convertWireguardEndpointData(relayList.getWireguard()!),
+ };
+}
+
+function convertWireguardEndpointData(
+ data: grpcTypes.WireguardEndpointData,
+): IWireguardEndpointData {
+ return {
+ portRanges: data.getPortRangesList().map((range) => [range.getFirst(), range.getLast()]),
+ udp2tcpPorts: data.getUdp2tcpPortsList(),
};
}
diff --git a/gui/src/main/relay-list.ts b/gui/src/main/relay-list.ts
index b43548e6a1..c7b4a1fff1 100644
--- a/gui/src/main/relay-list.ts
+++ b/gui/src/main/relay-list.ts
@@ -1,12 +1,26 @@
-import { BridgeState, IRelayList, liftConstraint, RelaySettings } from '../shared/daemon-rpc-types';
+import {
+ BridgeState,
+ IRelayList,
+ IRelayListWithEndpointData,
+ liftConstraint,
+ RelaySettings,
+} from '../shared/daemon-rpc-types';
import { IRelayListPair } from '../shared/ipc-schema';
import { IpcMainEventChannel } from './ipc-event-channel';
export default class RelayList {
- private relays: IRelayList = { countries: [] };
+ private relays: IRelayListWithEndpointData = {
+ relayList: {
+ countries: [],
+ },
+ wireguardEndpointData: {
+ portRanges: [],
+ udp2tcpPorts: [],
+ },
+ };
public setRelays(
- newRelayList: IRelayList,
+ newRelayList: IRelayListWithEndpointData,
relaySettings: RelaySettings,
bridgeState: BridgeState,
) {
@@ -25,14 +39,18 @@ export default class RelayList {
}
private processRelays(
- relayList: IRelayList,
+ relayList: IRelayListWithEndpointData,
relaySettings: RelaySettings,
bridgeState: BridgeState,
): IRelayListPair {
- const filteredRelays = this.processRelaysForPresentation(relayList, relaySettings);
- const filteredBridges = this.processBridgesForPresentation(relayList, bridgeState);
+ const filteredRelays = this.processRelaysForPresentation(relayList.relayList, relaySettings);
+ const filteredBridges = this.processBridgesForPresentation(relayList.relayList, bridgeState);
- return { relays: filteredRelays, bridges: filteredBridges };
+ return {
+ relays: filteredRelays,
+ bridges: filteredBridges,
+ wireguardEndpointData: relayList.wireguardEndpointData,
+ };
}
private processRelaysForPresentation(
@@ -75,9 +93,7 @@ export default class RelayList {
}))
.filter((country) => country.cities.length > 0);
- return {
- countries: filteredCountries,
- };
+ return { countries: filteredCountries };
}
private processBridgesForPresentation(