summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/src/main/daemon-rpc.ts29
-rw-r--r--gui/src/main/relay-list.ts36
-rw-r--r--gui/src/renderer/app.tsx3
-rw-r--r--gui/src/renderer/redux/settings/actions.ts23
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts9
-rw-r--r--gui/src/shared/daemon-rpc-types.ts12
-rw-r--r--gui/src/shared/ipc-schema.ts2
-rw-r--r--gui/test/e2e/setup/main.ts12
8 files changed, 105 insertions, 21 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(
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 1c222c9299..6bc2c61ff3 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -849,6 +849,9 @@ export default class AppRenderer {
this.reduxActions.settings.updateRelayLocations(relays);
this.reduxActions.settings.updateBridgeLocations(bridges);
+ this.reduxActions.settings.updateWireguardEndpointData(
+ this.relayListPair.wireguardEndpointData,
+ );
}
private setCurrentVersion(versionInfo: ICurrentAppVersionInfo) {
diff --git a/gui/src/renderer/redux/settings/actions.ts b/gui/src/renderer/redux/settings/actions.ts
index 8126f30205..c6e5aed985 100644
--- a/gui/src/renderer/redux/settings/actions.ts
+++ b/gui/src/renderer/redux/settings/actions.ts
@@ -1,5 +1,10 @@
import { IWindowsApplication } from '../../../shared/application-types';
-import { BridgeState, IDnsOptions, ObfuscationSettings } from '../../../shared/daemon-rpc-types';
+import {
+ BridgeState,
+ IDnsOptions,
+ IWireguardEndpointData,
+ ObfuscationSettings,
+} from '../../../shared/daemon-rpc-types';
import { IGuiSettingsState } from '../../../shared/gui-settings-state';
import { BridgeSettingsRedux, IRelayLocationRedux, RelaySettingsRedux } from './reducers';
@@ -23,6 +28,11 @@ export interface IUpdateBridgeLocationsAction {
bridgeLocations: IRelayLocationRedux[];
}
+export interface IUpdateWireguardEndpointData {
+ type: 'UPDATE_WIREGUARD_ENDPOINT_DATA';
+ wireguardEndpointData: IWireguardEndpointData;
+}
+
export interface IUpdateAllowLanAction {
type: 'UPDATE_ALLOW_LAN';
allowLan: boolean;
@@ -93,6 +103,7 @@ export type SettingsAction =
| IUpdateRelayAction
| IUpdateRelayLocationsAction
| IUpdateBridgeLocationsAction
+ | IUpdateWireguardEndpointData
| IUpdateAllowLanAction
| IUpdateEnableIpv6Action
| IUpdateBlockWhenDisconnectedAction
@@ -137,6 +148,15 @@ function updateBridgeLocations(
};
}
+function updateWireguardEndpointData(
+ wireguardEndpointData: IWireguardEndpointData,
+): IUpdateWireguardEndpointData {
+ return {
+ type: 'UPDATE_WIREGUARD_ENDPOINT_DATA',
+ wireguardEndpointData,
+ };
+}
+
function updateAllowLan(allowLan: boolean): IUpdateAllowLanAction {
return {
type: 'UPDATE_ALLOW_LAN',
@@ -239,6 +259,7 @@ export default {
updateRelay,
updateRelayLocations,
updateBridgeLocations,
+ updateWireguardEndpointData,
updateAllowLan,
updateEnableIpv6,
updateBlockWhenDisconnected,
diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts
index ee9d81e37f..e4437563ec 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -3,6 +3,7 @@ import {
BridgeState,
IDnsOptions,
IpVersion,
+ IWireguardEndpointData,
LiftedConstraint,
ObfuscationSettings,
ObfuscationType,
@@ -82,6 +83,7 @@ export interface ISettingsReduxState {
relaySettings: RelaySettingsRedux;
relayLocations: IRelayLocationRedux[];
bridgeLocations: IRelayLocationRedux[];
+ wireguardEndpointData: IWireguardEndpointData;
allowLan: boolean;
enableIpv6: boolean;
bridgeSettings: BridgeSettingsRedux;
@@ -127,6 +129,7 @@ const initialState: ISettingsReduxState = {
},
relayLocations: [],
bridgeLocations: [],
+ wireguardEndpointData: { portRanges: [], udp2tcpPorts: [] },
allowLan: false,
enableIpv6: true,
bridgeSettings: {
@@ -191,6 +194,12 @@ export default function (
bridgeLocations: action.bridgeLocations,
};
+ case 'UPDATE_WIREGUARD_ENDPOINT_DATA':
+ return {
+ ...state,
+ wireguardEndpointData: action.wireguardEndpointData,
+ };
+
case 'UPDATE_ALLOW_LAN':
return {
...state,
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index 5893e4def6..6b75ee7d3c 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -119,7 +119,7 @@ export interface IProxyEndpoint {
export type DaemonEvent =
| { tunnelState: TunnelState }
| { settings: ISettings }
- | { relayList: IRelayList }
+ | { relayList: IRelayListWithEndpointData }
| { appVersionInfo: IAppVersionInfo }
| { device: DeviceEvent }
| { deviceRemoval: Array<IDevice> };
@@ -224,10 +224,20 @@ export type RelaySettingsUpdate =
customTunnelEndpoint: IRelaySettingsCustom;
};
+export interface IRelayListWithEndpointData {
+ relayList: IRelayList;
+ wireguardEndpointData: IWireguardEndpointData;
+}
+
export interface IRelayList {
countries: IRelayListCountry[];
}
+export interface IWireguardEndpointData {
+ portRanges: [number, number][];
+ udp2tcpPorts: number[];
+}
+
export interface IRelayListCountry {
name: string;
code: string;
diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts
index 33ac82180e..85c7f2cabc 100644
--- a/gui/src/shared/ipc-schema.ts
+++ b/gui/src/shared/ipc-schema.ts
@@ -15,6 +15,7 @@ import {
ILocation,
IRelayList,
ISettings,
+ IWireguardEndpointData,
ObfuscationSettings,
RelaySettingsUpdate,
TunnelState,
@@ -45,6 +46,7 @@ export interface ITranslations {
export interface IRelayListPair {
relays: IRelayList;
bridges: IRelayList;
+ wireguardEndpointData: IWireguardEndpointData;
}
export type LaunchApplicationResult = { success: true } | { error: string };
diff --git a/gui/test/e2e/setup/main.ts b/gui/test/e2e/setup/main.ts
index f65169ee44..f89e4a3835 100644
--- a/gui/test/e2e/setup/main.ts
+++ b/gui/test/e2e/setup/main.ts
@@ -10,6 +10,7 @@ import {
IAppVersionInfo,
ILocation,
IRelayList,
+ IWireguardEndpointData,
} from '../../../src/shared/daemon-rpc-types';
import { messages, relayLocations } from '../../../src/shared/gettext';
import { IGuiSettingsState } from '../../../src/shared/gui-settings-state';
@@ -101,6 +102,11 @@ class ApplicationMain {
],
};
+ private wireguardEndpointData: IWireguardEndpointData = {
+ portRanges: [],
+ udp2tcpPorts: [],
+ };
+
public constructor() {
app.enableSandbox();
app.on('ready', this.onReady);
@@ -153,7 +159,11 @@ class ApplicationMain {
settings: this.settings,
isPerformingPostUpgrade: false,
deviceState: this.deviceState,
- relayListPair: { relays: this.relayList, bridges: this.relayList },
+ relayListPair: {
+ relays: this.relayList,
+ bridges: this.relayList,
+ wireguardEndpointData: this.wireguardEndpointData,
+ },
currentVersion: this.currentVersion,
upgradeVersion: this.upgradeVersion,
guiSettings: this.guiSettings,