diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-06-17 16:55:21 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-06-24 14:22:23 +0200 |
| commit | 14fcbe159ea35ebd4e4d0adebd182e47631335cb (patch) | |
| tree | acc327998e3fa82c06c61c064bf0b370b6adc18b /mullvad-management-interface | |
| parent | 41a021c7d4efdb74b1c71e7567d22ffc930411c4 (diff) | |
| download | mullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.tar.xz mullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.zip | |
Enable support for creating a custom list with locations
Diffstat (limited to 'mullvad-management-interface')
3 files changed, 24 insertions, 11 deletions
diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index ab9883c1ef..14a11fff4e 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -81,7 +81,7 @@ service ManagementService { rpc GetWireguardKey(google.protobuf.Empty) returns (PublicKey) {} // Custom lists - rpc CreateCustomList(google.protobuf.StringValue) returns (google.protobuf.StringValue) {} + rpc CreateCustomList(NewCustomList) returns (google.protobuf.StringValue) {} rpc DeleteCustomList(google.protobuf.StringValue) returns (google.protobuf.Empty) {} rpc UpdateCustomList(CustomList) returns (google.protobuf.Empty) {} rpc ClearCustomLists(google.protobuf.Empty) returns (google.protobuf.Empty) {} @@ -442,6 +442,11 @@ message CustomList { repeated GeographicLocationConstraint locations = 3; } +message NewCustomList { + string name = 1; + repeated GeographicLocationConstraint locations = 2; +} + message CustomListSettings { repeated CustomList custom_lists = 1; } message Socks5Local { diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs index 73129d6b99..93a31a5042 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -571,18 +571,22 @@ impl MullvadProxyClient { } pub async fn create_custom_list(&mut self, name: String) -> Result<Id> { + let request = types::NewCustomList { + name, + locations: Vec::new(), + }; let id = self .0 - .create_custom_list(name) + .create_custom_list(request) .await .map_err(map_custom_list_error)? .into_inner(); Id::from_str(&id).map_err(|_| Error::CustomListListNotFound) } - pub async fn delete_custom_list(&mut self, id: String) -> Result<()> { + pub async fn delete_custom_list(&mut self, id: Id) -> Result<()> { self.0 - .delete_custom_list(id) + .delete_custom_list(id.to_string()) .await .map_err(map_custom_list_error)?; Ok(()) diff --git a/mullvad-management-interface/src/types/conversions/custom_list.rs b/mullvad-management-interface/src/types/conversions/custom_list.rs index 9d4e9cee78..11f2c4bd76 100644 --- a/mullvad-management-interface/src/types/conversions/custom_list.rs +++ b/mullvad-management-interface/src/types/conversions/custom_list.rs @@ -30,13 +30,14 @@ impl TryFrom<proto::CustomListSettings> for mullvad_types::custom_list::CustomLi impl From<mullvad_types::custom_list::CustomList> for proto::CustomList { fn from(custom_list: mullvad_types::custom_list::CustomList) -> Self { + let id = custom_list.id().to_string(); let locations = custom_list .locations .into_iter() .map(proto::GeographicLocationConstraint::from) .collect(); Self { - id: custom_list.id.to_string(), + id, name: custom_list.name, locations, } @@ -52,11 +53,14 @@ impl TryFrom<proto::CustomList> for mullvad_types::custom_list::CustomList { .into_iter() .map(GeographicLocationConstraint::try_from) .collect::<Result<BTreeSet<_>, Self::Error>>()?; - Ok(Self { - id: Id::from_str(&custom_list.id) - .map_err(|_| FromProtobufTypeError::InvalidArgument("Invalid list ID"))?, - name: custom_list.name, - locations, - }) + + let id = Id::from_str(&custom_list.id) + .map_err(|_| FromProtobufTypeError::InvalidArgument("Invalid list ID"))?; + + let mut inner = Self::with_id(id); + inner.name = custom_list.name; + inner.append(locations); + + Ok(inner) } } |
