diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index f3b744e522..e2a909b756 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -1228,15 +1228,25 @@ function convertFromConnectionConfig( } } -function convertFromLocation(location: grpcTypes.RelayLocation.AsObject): RelayLocation { - if (location.hostname) { - return { hostname: [location.country, location.city, location.hostname] }; - } - if (location.city) { - return { city: [location.country, location.city] }; +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" }; } + else { + const loc = location.location; + + if (loc.hostname) { + return { hostname: [loc.country, loc.city, loc.hostname] }; + } - return { country: location.country }; + if (loc.city) { + return { city: [loc.country, loc.city] }; + } + + return { country: loc.country }; + } } function convertFromTunnelOptions(tunnelOptions: grpcTypes.TunnelOptions.AsObject): ITunnelOptions { @@ -1455,24 +1465,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( |
