diff options
| author | Jonathan <jonathan@mullvad.net> | 2023-06-29 15:14:40 +0200 |
|---|---|---|
| committer | Jonathan <jonathan@mullvad.net> | 2023-06-29 15:14:40 +0200 |
| commit | d3805f501cea6aa352de2c160f3a2f7bc8b93821 (patch) | |
| tree | ba94b7e0829f2fd57a9974b4590af59e9937e5be /gui | |
| parent | 9e7bb470758385159ade1e22d5093b535a5e667c (diff) | |
| parent | 5f61ba4058337e6985cee99661a59a98ebff6dd0 (diff) | |
| download | mullvadvpn-d3805f501cea6aa352de2c160f3a2f7bc8b93821.tar.xz mullvadvpn-d3805f501cea6aa352de2c160f3a2f7bc8b93821.zip | |
Merge branch 'custom-lists'
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index f3b744e522..f4d47c7916 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -1228,15 +1228,23 @@ function convertFromConnectionConfig( } } -function convertFromLocation(location: grpcTypes.RelayLocation.AsObject): RelayLocation { - if (location.hostname) { - return { hostname: [location.country, location.city, location.hostname] }; +function convertFromLocation(location: grpcTypes.LocationConstraint.AsObject): RelayLocation { + // FIXME: This is a hack that assumes that the LocationConstraint is not a custom list. + // If it is we just set the country to "any" even if that isn't correct. + if (location.location == undefined) { + return { country: 'any' }; } - if (location.city) { - return { city: [location.country, location.city] }; + const loc = location.location; + + if (loc.hostname) { + return { hostname: [loc.country, loc.city, loc.hostname] }; + } + + if (loc.city) { + return { city: [loc.country, loc.city] }; } - return { country: location.country }; + return { country: loc.country }; } function convertFromTunnelOptions(tunnelOptions: grpcTypes.TunnelOptions.AsObject): ITunnelOptions { @@ -1455,24 +1463,24 @@ function convertToNormalBridgeSettings( function convertToLocation( constraint: RelayLocation | undefined, -): grpcTypes.RelayLocation | undefined { +): grpcTypes.LocationConstraint | undefined { + const locationConstraint = new grpcTypes.LocationConstraint(); const location = new grpcTypes.RelayLocation(); if (constraint && 'hostname' in constraint) { const [countryCode, cityCode, hostname] = constraint.hostname; location.setCountry(countryCode); location.setCity(cityCode); location.setHostname(hostname); - return location; } else if (constraint && 'city' in constraint) { location.setCountry(constraint.city[0]); location.setCity(constraint.city[1]); - return location; } else if (constraint && 'country' in constraint) { location.setCountry(constraint.country); - return location; } else { return undefined; } + locationConstraint.setLocation(location); + return locationConstraint; } function convertToTunnelTypeConstraint( |
