diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-05-06 11:00:13 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-05-06 11:00:13 +0200 |
| commit | 95b77406102a0691e8f0d73e056c9a16b01f589d (patch) | |
| tree | e44cf7849a78673b9d2a82650952c1efa03d32dc | |
| parent | ffd6f7bcf54a6d0e24233e602ace35090f805e52 (diff) | |
| parent | 009e99038dfb4d56d3e28e24cb96981c9a74c32b (diff) | |
| download | mullvadvpn-95b77406102a0691e8f0d73e056c9a16b01f589d.tar.xz mullvadvpn-95b77406102a0691e8f0d73e056c9a16b01f589d.zip | |
Merge branch 'fix-lints-on-android-des-1715'
| -rw-r--r-- | mullvad-api/src/device.rs | 8 | ||||
| -rw-r--r-- | mullvad-api/src/lib.rs | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/device/service.rs | 89 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 11 | ||||
| -rw-r--r-- | mullvad-jni/src/lib.rs | 2 | ||||
| -rw-r--r-- | mullvad-problem-report/src/lib.rs | 4 |
6 files changed, 77 insertions, 41 deletions
diff --git a/mullvad-api/src/device.rs b/mullvad-api/src/device.rs index 770c86a642..fbcb9e899e 100644 --- a/mullvad-api/src/device.rs +++ b/mullvad-api/src/device.rs @@ -135,7 +135,7 @@ impl DevicesProxy { &self, account: AccountNumber, id: DeviceId, - ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> { + ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> + use<> { let service = self.handle.service.clone(); let factory = self.handle.factory.clone(); @@ -151,7 +151,7 @@ impl DevicesProxy { pub fn list_response( &self, account: AccountNumber, - ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> { + ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> + use<> { let service = self.handle.service.clone(); let factory = self.handle.factory.clone(); @@ -169,7 +169,7 @@ impl DevicesProxy { account: AccountNumber, id: DeviceId, pubkey: wireguard::PublicKey, - ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> { + ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> + use<> { #[derive(serde::Serialize)] struct RotateDevicePubkey { pubkey: wireguard::PublicKey, @@ -195,7 +195,7 @@ impl DevicesProxy { &self, account: AccountNumber, pubkey: wireguard::PublicKey, - ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> { + ) -> impl Future<Output = Result<rest::Response<Incoming>, rest::Error>> + use<> { #[derive(serde::Serialize)] struct DeviceSubmission { pubkey: wireguard::PublicKey, diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index 2d068fdf24..fb44b5ba89 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -603,7 +603,7 @@ impl AccountsProxy { pub fn init_play_purchase( &mut self, account: AccountNumber, - ) -> impl Future<Output = Result<PlayPurchasePaymentToken, rest::Error>> { + ) -> impl Future<Output = Result<PlayPurchasePaymentToken, rest::Error>> + use<> { #[derive(serde::Deserialize)] struct PlayPurchaseInitResponse { obfuscated_id: String, @@ -630,7 +630,7 @@ impl AccountsProxy { &mut self, account: AccountNumber, play_purchase: PlayPurchase, - ) -> impl Future<Output = Result<(), rest::Error>> { + ) -> impl Future<Output = Result<(), rest::Error>> + use<> { let service = self.handle.service.clone(); let factory = self.handle.factory.clone(); diff --git a/mullvad-daemon/src/device/service.rs b/mullvad-daemon/src/device/service.rs index 3ebecf0483..ff719339ca 100644 --- a/mullvad-daemon/src/device/service.rs +++ b/mullvad-daemon/src/device/service.rs @@ -52,8 +52,14 @@ impl DeviceService { let api_handle = self.api_availability.clone(); let number_copy = account_number.clone(); async move { + let factory = move || { + let number = number_copy.clone(); + let pubkey = pubkey.clone(); + + proxy.create(number, pubkey) + }; let (device, addresses) = retry_future( - move || proxy.create(number_copy.clone(), pubkey.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) @@ -84,13 +90,17 @@ impl DeviceService { let proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); let number_copy = account_number.clone(); - let (device, addresses) = retry_future( - move || api_handle.when_online(proxy.create(number_copy.clone(), pubkey.clone())), - should_retry_backoff, - RETRY_BACKOFF_STRATEGY, - ) - .await - .map_err(map_rest_error)?; + let factory = move || { + let number = number_copy.clone(); + let pubkey = pubkey.clone(); + let task = proxy.create(number, pubkey); + + api_handle.when_online(task) + }; + let (device, addresses) = + retry_future(factory, should_retry_backoff, RETRY_BACKOFF_STRATEGY) + .await + .map_err(map_rest_error)?; Ok(PrivateAccountAndDevice { account_number, @@ -163,8 +173,15 @@ impl DeviceService { let proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); let pubkey = private_key.public_key(); + let factory = move || { + let number = number.clone(); + let device = device.clone(); + let pubkey = pubkey.clone(); + + proxy.replace_wg_key(number, device, pubkey) + }; let addresses = retry_future( - move || proxy.replace_wg_key(number.clone(), device.clone(), pubkey.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) @@ -193,11 +210,8 @@ impl DeviceService { let addresses = retry_future( move || { - api_handle.when_bg_resumes(proxy.replace_wg_key( - number.clone(), - device.clone(), - pubkey.clone(), - )) + let task = proxy.replace_wg_key(number.clone(), device.clone(), pubkey.clone()); + api_handle.when_bg_resumes(task) }, should_retry_backoff, rotate_retry_strategy, @@ -215,8 +229,12 @@ impl DeviceService { pub async fn list_devices(&self, number: AccountNumber) -> Result<Vec<Device>, Error> { let proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); + let factory = move || { + let number = number.clone(); + proxy.list(number) + }; retry_future( - move || proxy.list(number.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) @@ -231,20 +249,30 @@ impl DeviceService { let proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); - retry_future( - move || api_handle.when_online(proxy.list(number.clone())), - should_retry_backoff, - RETRY_BACKOFF_STRATEGY, - ) - .await - .map_err(map_rest_error) + let factory = move || { + let number = number.clone(); + let task = proxy.list(number); + + api_handle.when_online(task) + }; + retry_future(factory, should_retry_backoff, RETRY_BACKOFF_STRATEGY) + .await + .map_err(map_rest_error) } pub async fn get(&self, number: AccountNumber, device: DeviceId) -> Result<Device, Error> { let proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); + let number = number.clone(); + let device = device.clone(); + let factory = move || { + let number = number.clone(); + let device = device.clone(); + + proxy.get(number, device) + }; retry_future( - move || proxy.get(number.clone(), device.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) @@ -332,8 +360,13 @@ impl AccountService { ) -> Result<PlayPurchasePaymentToken, Error> { let mut proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); + let factory = move || { + let account_number = account_number.clone(); + + proxy.init_play_purchase(account_number) + }; let result = retry_future( - move || proxy.init_play_purchase(account_number.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) @@ -353,8 +386,14 @@ impl AccountService { ) -> Result<(), Error> { let mut proxy = self.proxy.clone(); let api_handle = self.api_availability.clone(); + let factory = move || { + let account_number = account_number.clone(); + let play_purchase = play_purchase.clone(); + + proxy.verify_play_purchase(account_number, play_purchase) + }; let result = retry_future( - move || proxy.verify_play_purchase(account_number.clone(), play_purchase.clone()), + factory, move |result| should_retry(result, &api_handle), RETRY_ACTION_STRATEGY, ) diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index f90cdfa00e..e165f7e6eb 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -585,7 +585,6 @@ where { pub fn to_unbounded_sender<T>(&self) -> mpsc::UnboundedSender<T> where - InternalDaemonEvent: From<E>, T: Send + 'static, E: From<T>, { @@ -593,12 +592,10 @@ where let sender = self.sender.clone(); tokio::spawn(async move { while let Some(msg) = rx.next().await { - if let Some(tx) = sender.upgrade() { - let e: E = E::from(msg); - if tx.send(e.into()).is_err() { - return; - } - } else { + let Some(tx) = sender.upgrade() else { + return; + }; + if tx.send(InternalDaemonEvent::from(E::from(msg))).is_err() { return; }; } diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 389323ce38..eee54cd622 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -54,7 +54,7 @@ pub enum Error { /// Throw a Java exception and return if `result` is an error macro_rules! ok_or_throw { - ($env:expr, $result:expr) => {{ + ($env:expr_2021, $result:expr_2021) => {{ match $result { Ok(val) => val, Err(err) => { diff --git a/mullvad-problem-report/src/lib.rs b/mullvad-problem-report/src/lib.rs index b2a4e22166..415d0d617a 100644 --- a/mullvad-problem-report/src/lib.rs +++ b/mullvad-problem-report/src/lib.rs @@ -35,8 +35,8 @@ const MAX_SEND_ATTEMPTS: usize = 3; /// Custom macro to write a line to an output formatter that uses platform-specific newline /// character sequences. macro_rules! write_line { - ($fmt:expr $(,)*) => { write!($fmt, "{}", LINE_SEPARATOR) }; - ($fmt:expr, $pattern:expr $(, $arg:expr)* $(,)*) => { + ($fmt:expr_2021 $(,)*) => { write!($fmt, "{}", LINE_SEPARATOR) }; + ($fmt:expr_2021, $pattern:expr_2021 $(, $arg:expr_2021)* $(,)*) => { write!($fmt, $pattern, $( $arg ),*) .and_then(|_| write!($fmt, "{}", LINE_SEPARATOR)) }; |
