diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs index 0a24af751608..fb249f9bd55b 100644 --- a/mullvad-daemon/src/access_method.rs +++ b/mullvad-daemon/src/access_method.rs @@ -106,7 +106,7 @@ where connection_modes.update_access_methods( self.settings .api_access_methods - .api_access_methods + .access_method_settings .iter() .filter(|api_access_method| api_access_method.enabled()) .map(|api_access_method| api_access_method.access_method.clone()) diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 12613d273d56..406e07bf222e 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -645,7 +645,7 @@ where relay_selector.clone(), settings .api_access_methods - .api_access_methods + .access_method_settings .iter() // We only care about the access methods which are set to 'enabled' by the user. .filter(|api_access_method| api_access_method.enabled()) diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index b64625bf4f70..99e2790cd82b 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -622,7 +622,7 @@ impl ManagementService for ManagementServiceImpl { async fn add_api_access_method( &self, - request: Request, + request: Request, ) -> ServiceResult { log::debug!("add_api_access_method"); let request = request.into_inner(); @@ -657,7 +657,7 @@ impl ManagementService for ManagementServiceImpl { async fn update_api_access_method( &self, - request: Request, + request: Request, ) -> ServiceResult<()> { log::debug!("update_api_access_method"); let access_method_update = diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index 25266005db74..e0ef053bd511 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -78,10 +78,10 @@ service ManagementService { rpc RenameCustomList(CustomListRename) returns (google.protobuf.Empty) {} // API Access methods - rpc AddApiAccessMethod(ApiAccessMethodAdd) returns (UUID) {} + rpc AddApiAccessMethod(AccessMethodSettingAdd) returns (UUID) {} rpc RemoveApiAccessMethod(UUID) returns (google.protobuf.Empty) {} rpc SetApiAccessMethod(UUID) returns (google.protobuf.Empty) {} - rpc UpdateApiAccessMethod(ApiAccessMethod) returns (google.protobuf.Empty) {} + rpc UpdateApiAccessMethod(AccessMethodSetting) returns (google.protobuf.Empty) {} // Split tunneling (Linux) rpc GetSplitTunnelProcesses(google.protobuf.Empty) returns (stream google.protobuf.Int32Value) {} @@ -380,25 +380,25 @@ message AccessMethod { } } -message ApiAccessMethod { +message AccessMethodSetting { UUID id = 1; string name = 2; bool enabled = 3; AccessMethod access_method = 4; } -message ApiAccessMethodAdd { +message AccessMethodSettingAdd { string name = 1; bool enabled = 2; AccessMethod access_method = 3; } -message ApiAccessMethodUpdate { +message AccessMethodSettingUpdate { UUID id = 1; - ApiAccessMethod access_method = 2; + AccessMethodSetting access_method_setting = 2; } -message ApiAccessMethodSettings { repeated ApiAccessMethod api_access_methods = 1; } +message ApiAccessMethodSettings { repeated AccessMethodSetting access_method_settings = 1; } message Settings { RelaySettings relay_settings = 1; diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs index 3d011b3b16ec..5770c275aca5 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -171,7 +171,7 @@ impl MullvadProxyClient { .into_inner() .api_access_methods .ok_or(Error::ApiAccessMethodSettingsNotFound)? - .api_access_methods + .access_method_settings .into_iter() .map(|api_access_method| { AccessMethodSetting::try_from(api_access_method).map_err(Error::InvalidResponse) @@ -528,7 +528,7 @@ impl MullvadProxyClient { enabled: bool, access_method: AccessMethod, ) -> Result<()> { - let request = types::ApiAccessMethodAdd { + let request = types::AccessMethodSettingAdd { name, enabled, access_method: Some(types::AccessMethod::from(access_method)), @@ -574,7 +574,7 @@ impl MullvadProxyClient { access_method_update: AccessMethodSetting, ) -> Result<()> { self.0 - .update_api_access_method(types::ApiAccessMethod::from(access_method_update)) + .update_api_access_method(types::AccessMethodSetting::from(access_method_update)) .await .map_err(Error::Rpc) .map(drop) diff --git a/mullvad-management-interface/src/types/conversions/api_access_method.rs b/mullvad-management-interface/src/types/conversions/access_method.rs similarity index 93% rename from mullvad-management-interface/src/types/conversions/api_access_method.rs rename to mullvad-management-interface/src/types/conversions/access_method.rs index e42ea9d0ffbc..8652b065e473 100644 --- a/mullvad-management-interface/src/types/conversions/api_access_method.rs +++ b/mullvad-management-interface/src/types/conversions/access_method.rs @@ -8,8 +8,8 @@ mod settings { impl From<&api_access::Settings> for proto::ApiAccessMethodSettings { fn from(settings: &api_access::Settings) -> Self { Self { - api_access_methods: settings - .api_access_methods + access_method_settings: settings + .access_method_settings .iter() .map(|method| method.clone().into()) .collect(), @@ -28,8 +28,8 @@ mod settings { fn try_from(settings: proto::ApiAccessMethodSettings) -> Result { Ok(Self { - api_access_methods: settings - .api_access_methods + access_method_settings: settings + .access_method_settings .iter() .map(api_access::AccessMethodSetting::try_from) .collect::, _>>()?, @@ -48,10 +48,10 @@ mod data { CustomAccessMethod, Shadowsocks, Socks5, Socks5Local, Socks5Remote, }; - impl TryFrom for AccessMethodSetting { + impl TryFrom for AccessMethodSetting { type Error = FromProtobufTypeError; - fn try_from(value: proto::ApiAccessMethod) -> Result { + fn try_from(value: proto::AccessMethodSetting) -> Result { let id = value .id .ok_or(FromProtobufTypeError::InvalidArgument( @@ -76,12 +76,12 @@ mod data { } } - impl From for proto::ApiAccessMethod { + impl From for proto::AccessMethodSetting { fn from(value: AccessMethodSetting) -> Self { let id = proto::Uuid::from(value.get_id()); let name = value.get_name(); let enabled = value.enabled(); - proto::ApiAccessMethod { + proto::AccessMethodSetting { id: Some(id), name, enabled, @@ -248,10 +248,10 @@ mod data { } } - impl TryFrom<&proto::ApiAccessMethod> for AccessMethodSetting { + impl TryFrom<&proto::AccessMethodSetting> for AccessMethodSetting { type Error = FromProtobufTypeError; - fn try_from(value: &proto::ApiAccessMethod) -> Result { + fn try_from(value: &proto::AccessMethodSetting) -> Result { AccessMethodSetting::try_from(value.clone()) } } diff --git a/mullvad-management-interface/src/types/conversions/mod.rs b/mullvad-management-interface/src/types/conversions/mod.rs index ddfe3f4282ba..dd6fcd450167 100644 --- a/mullvad-management-interface/src/types/conversions/mod.rs +++ b/mullvad-management-interface/src/types/conversions/mod.rs @@ -1,7 +1,7 @@ use std::str::FromStr; +mod access_method; mod account; -mod api_access_method; mod custom_list; mod custom_tunnel; mod device; diff --git a/mullvad-types/src/api_access.rs b/mullvad-types/src/api_access.rs index 8b7c4a30e7a2..5c061999ca46 100644 --- a/mullvad-types/src/api_access.rs +++ b/mullvad-types/src/api_access.rs @@ -6,13 +6,13 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4}; /// Daemon settings for API access methods. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Settings { - pub api_access_methods: Vec, + pub access_method_settings: Vec, } impl Settings { /// Append an [`AccessMethod`] to the end of `api_access_methods`. pub fn append(&mut self, api_access_method: AccessMethodSetting) { - self.api_access_methods.push(api_access_method) + self.access_method_settings.push(api_access_method) } /// Remove an [`ApiAccessMethod`] from `api_access_methods`. @@ -22,7 +22,7 @@ impl Settings { /// Search for a particular [`AccessMethod`] in `api_access_methods`. pub fn find(&self, element: &ApiAccessMethodId) -> Option<&AccessMethodSetting> { - self.api_access_methods + self.access_method_settings .iter() .find(|api_access_method| *element == api_access_method.get_id()) } @@ -33,7 +33,7 @@ impl Settings { /// mutable reference to that inner element is returned. Otherwise, `None` /// is returned. pub fn find_mut(&mut self, element: &ApiAccessMethodId) -> Option<&mut AccessMethodSetting> { - self.api_access_methods + self.access_method_settings .iter_mut() .find(|api_access_method| *element == api_access_method.get_id()) } @@ -43,19 +43,19 @@ impl Settings { where F: FnMut(&AccessMethodSetting) -> bool, { - self.api_access_methods.retain(f) + self.access_method_settings.retain(f) } /// Clone the content of `api_access_methods`. pub fn cloned(&self) -> Vec { - self.api_access_methods.clone() + self.access_method_settings.clone() } } impl Default for Settings { fn default() -> Self { Self { - api_access_methods: vec![BuiltInAccessMethod::Direct, BuiltInAccessMethod::Bridge] + access_method_settings: vec![BuiltInAccessMethod::Direct, BuiltInAccessMethod::Bridge] .into_iter() .map(|built_in| { AccessMethodSetting::new(