diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-05-10 10:22:49 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-05-19 10:04:19 +0200 |
| commit | 920ede43e285a08ce9fd519c3c5719ce2b0e2683 (patch) | |
| tree | c6d7f0740be981f302f2e58de060621cef6b1dfa /gui/src | |
| parent | 6a7d902d8fc1f23bf795b232623f3dd36f8918fb (diff) | |
| download | mullvadvpn-920ede43e285a08ce9fd519c3c5719ce2b0e2683.tar.xz mullvadvpn-920ede43e285a08ce9fd519c3c5719ce2b0e2683.zip | |
Add ipc and state code for ownership
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 33 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 3 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/redux/settings/reducers.ts | 3 | ||||
| -rw-r--r-- | gui/src/shared/bridge-settings-builder.ts | 3 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 8 |
6 files changed, 51 insertions, 1 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index c40e40b864..166a48c9cb 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -44,6 +44,7 @@ import { LoggedInDeviceState, LoggedOutDeviceState, ObfuscationType, + Ownership, ProxySettings, ProxyType, RelayLocation, @@ -326,6 +327,12 @@ export class DaemonRpc { normalUpdate.setProviders(providerUpdate); } + if (settingsUpdate.ownership !== undefined) { + const ownershipUpdate = new grpcTypes.OwnershipUpdate(); + ownershipUpdate.setOwnership(convertToOwnership(settingsUpdate.ownership)); + normalUpdate.setOwnership(ownershipUpdate); + } + grpcRelaySettings.setNormal(normalUpdate); await this.call<grpcTypes.RelaySettingsUpdate, Empty>( this.client.updateRelaySettings, @@ -1014,6 +1021,7 @@ function convertFromRelaySettings( : 'any'; const tunnelProtocol = convertFromTunnelTypeConstraint(normal.getTunnelType()!); const providers = normal.getProvidersList(); + const ownership = convertFromOwnership(normal.getOwnership()); const openvpnConstraints = convertFromOpenVpnConstraints(normal.getOpenvpnConstraints()!); const wireguardConstraints = convertFromWireguardConstraints( normal.getWireguardConstraints()!, @@ -1024,6 +1032,7 @@ function convertFromRelaySettings( location, tunnelProtocol, providers, + ownership, wireguardConstraints, openvpnConstraints, }, @@ -1043,10 +1052,12 @@ function convertFromBridgeSettings( const grpcLocation = normalSettings.location; const location = grpcLocation ? { only: convertFromLocation(grpcLocation) } : 'any'; const providers = normalSettings.providersList; + const ownership = convertFromOwnership(normalSettings.ownership); return { normal: { location, providers, + ownership, }, }; } @@ -1210,6 +1221,28 @@ function convertFromDaemonEvent(data: grpcTypes.DaemonEvent): DaemonEvent { throw new Error(`Unknown daemon event received containing ${keys}`); } +function convertFromOwnership(ownership: grpcTypes.Ownership): Ownership { + switch (ownership) { + case grpcTypes.Ownership.ANY: + return Ownership.any; + case grpcTypes.Ownership.MULLVAD_OWNED: + return Ownership.mullvadOwned; + case grpcTypes.Ownership.RENTED: + return Ownership.rented; + } +} + +function convertToOwnership(ownership: Ownership): grpcTypes.Ownership { + switch (ownership) { + case Ownership.any: + return grpcTypes.Ownership.ANY; + case Ownership.mullvadOwned: + return grpcTypes.Ownership.MULLVAD_OWNED; + case Ownership.rented: + return grpcTypes.Ownership.RENTED; + } +} + function convertFromOpenVpnConstraints( constraints: grpcTypes.OpenvpnConstraints, ): IOpenVpnConstraints { diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 4d0f915bb9..622194fbd7 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -36,6 +36,7 @@ import { IRelayList, ISettings, liftConstraint, + Ownership, RelaySettings, RelaySettingsUpdate, TunnelState, @@ -162,6 +163,7 @@ class ApplicationMain { location: 'any', tunnelProtocol: 'any', providers: [], + ownership: Ownership.any, openvpnConstraints: { port: 'any', protocol: 'any', @@ -178,6 +180,7 @@ class ApplicationMain { normal: { location: 'any', providers: [], + ownership: Ownership.any, }, }, bridgeState: 'auto', diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 23abcd8627..f4e711f3ff 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -636,12 +636,14 @@ export default class AppRenderer { wireguardConstraints, tunnelProtocol, providers, + ownership, } = relaySettings.normal; actions.settings.updateRelay({ normal: { location: liftConstraint(location), providers, + ownership, openvpn: { port: liftConstraint(openvpnConstraints.port), protocol: liftConstraint(openvpnConstraints.protocol), diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts index 1c759e1a52..316a3596ae 100644 --- a/gui/src/renderer/redux/settings/reducers.ts +++ b/gui/src/renderer/redux/settings/reducers.ts @@ -4,6 +4,7 @@ import { IDnsOptions, IpVersion, LiftedConstraint, + Ownership, ProxySettings, RelayLocation, RelayProtocol, @@ -18,6 +19,7 @@ export type RelaySettingsRedux = tunnelProtocol: LiftedConstraint<TunnelProtocol>; location: LiftedConstraint<RelayLocation>; providers: string[]; + ownership: Ownership; openvpn: { port: LiftedConstraint<number>; protocol: LiftedConstraint<RelayProtocol>; @@ -111,6 +113,7 @@ const initialState: ISettingsReduxState = { location: 'any', tunnelProtocol: 'any', providers: [], + ownership: Ownership.any, wireguard: { port: 'any', ipVersion: 'any', useMultihop: false, entryLocation: 'any' }, openvpn: { port: 'any', diff --git a/gui/src/shared/bridge-settings-builder.ts b/gui/src/shared/bridge-settings-builder.ts index fc4eeaa682..858bea055d 100644 --- a/gui/src/shared/bridge-settings-builder.ts +++ b/gui/src/shared/bridge-settings-builder.ts @@ -1,4 +1,4 @@ -import { BridgeSettings, IBridgeConstraints } from './daemon-rpc-types'; +import { BridgeSettings, IBridgeConstraints, Ownership } from './daemon-rpc-types'; import makeLocationBuilder, { ILocationBuilder } from './relay-location-builder'; export default class BridgeSettingsBuilder { @@ -10,6 +10,7 @@ export default class BridgeSettingsBuilder { normal: { location: this.payload.location, providers: this.payload.providers ?? [], + ownership: this.payload.ownership ?? Ownership.any, }, }; } else { diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index aad35a01f4..13f6f7138b 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -82,6 +82,12 @@ export function proxyTypeToString(proxy: ProxyType): string { } } +export enum Ownership { + any, + mullvadOwned, + rented, +} + export interface ITunnelEndpoint { address: string; protocol: RelayProtocol; @@ -159,6 +165,7 @@ interface IRelaySettingsNormal<OpenVpn, Wireguard> { location: Constraint<RelayLocation>; tunnelProtocol: Constraint<TunnelProtocol>; providers: string[]; + ownership: Ownership; openvpnConstraints: OpenVpn; wireguardConstraints: Wireguard; } @@ -380,6 +387,7 @@ export type SplitTunnelSettings = { export interface IBridgeConstraints { location: Constraint<RelayLocation>; providers: string[]; + ownership: Ownership; } export type BridgeSettings = { normal: IBridgeConstraints } | { custom: ProxySettings }; |
