diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 32 | ||||
| -rw-r--r-- | mullvad-management-interface/proto/management_interface.proto | 4 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types/conversions/relay_constraints.rs | 8 |
4 files changed, 30 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 10ff6d74fa..973b96b0d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ Line wrap the file at 100 chars. Th - Add settings view button in main view in the desktop app. - Add time left and device name in the header bar in the desktop app. +- Add customizable relay lists to the CLI on desktop. Custom lists can be managed through + `mullvad custom-lists` and can be selected through `mullvad relay set` and `mullvad bridge set`. + #### Android - Add UDP-over-TCP. - Prevent incoming connections from outside the VPN in Android 11+ when Local Network Sharing 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( diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index c77e5d571a..709079bee4 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -289,8 +289,8 @@ message BridgeSettings { message LocationConstraint { oneof type { - string custom = 1; - RelayLocation normal = 2; + string customList = 1; + RelayLocation location = 2; } } diff --git a/mullvad-management-interface/src/types/conversions/relay_constraints.rs b/mullvad-management-interface/src/types/conversions/relay_constraints.rs index 2816be0e9b..8c1f89d368 100644 --- a/mullvad-management-interface/src/types/conversions/relay_constraints.rs +++ b/mullvad-management-interface/src/types/conversions/relay_constraints.rs @@ -484,12 +484,12 @@ impl From<mullvad_types::relay_constraints::LocationConstraint> for proto::Locat use mullvad_types::relay_constraints::LocationConstraint; match location { LocationConstraint::Location { location } => Self { - r#type: Some(proto::location_constraint::Type::Normal( + r#type: Some(proto::location_constraint::Type::Location( proto::RelayLocation::from(location), )), }, LocationConstraint::CustomList { list_id } => Self { - r#type: Some(proto::location_constraint::Type::Custom( + r#type: Some(proto::location_constraint::Type::CustomList( list_id.0.to_string(), )), }, @@ -505,7 +505,7 @@ impl TryFrom<proto::LocationConstraint> fn try_from(location: proto::LocationConstraint) -> Result<Self, Self::Error> { use mullvad_types::relay_constraints::LocationConstraint; match location.r#type { - Some(proto::location_constraint::Type::Normal(location)) => { + Some(proto::location_constraint::Type::Location(location)) => { let location = Constraint::< mullvad_types::relay_constraints::GeographicLocationConstraint, >::from(location); @@ -516,7 +516,7 @@ impl TryFrom<proto::LocationConstraint> } } } - Some(proto::location_constraint::Type::Custom(list_id)) => { + Some(proto::location_constraint::Type::CustomList(list_id)) => { let location = LocationConstraint::CustomList { list_id: Id::try_from(list_id.as_str()).map_err(|_| { FromProtobufTypeError::InvalidArgument("Id could not be parsed to a uuid") |
