mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Fix cargo clippy warnings
This commit is contained in:
@@ -329,13 +329,13 @@ pub unsafe extern "C" fn app_service_launch_app(
|
||||
if !argv.is_null() && argc > 0 {
|
||||
let argv_slice = unsafe { std::slice::from_raw_parts(argv, argc) };
|
||||
for &arg in argv_slice {
|
||||
if !arg.is_null() {
|
||||
if let Ok(arg_str) = unsafe { CStr::from_ptr(arg) }.to_str() {
|
||||
if !arg.is_null()
|
||||
&& let Ok(arg_str) = unsafe { CStr::from_ptr(arg) }.to_str()
|
||||
{
|
||||
args.push(arg_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let client = unsafe { &mut (*handle).0 };
|
||||
let res = RUNTIME.block_on(async move {
|
||||
|
||||
@@ -105,14 +105,14 @@ pub unsafe extern "C" fn process_control_launch_app(
|
||||
for &env_var in env_vars_slice {
|
||||
if !env_var.is_null() {
|
||||
let env_var = unsafe { CStr::from_ptr(env_var) };
|
||||
if let Ok(env_var) = env_var.to_str() {
|
||||
if let Some((key, value)) = env_var.split_once('=') {
|
||||
if let Ok(env_var) = env_var.to_str()
|
||||
&& let Some((key, value)) = env_var.split_once('=')
|
||||
{
|
||||
env_dict.insert(key.to_string(), Value::String(value.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut args_dict = Dictionary::new();
|
||||
if !arguments.is_null() {
|
||||
|
||||
@@ -25,7 +25,7 @@ pub use services::*;
|
||||
#[cfg(feature = "xpc")]
|
||||
pub use xpc::RemoteXpcClient;
|
||||
|
||||
use log::{debug, error, trace, warn};
|
||||
use log::{debug, error, trace};
|
||||
use provider::{IdeviceProvider, RsdProvider};
|
||||
use rustls::{crypto::CryptoProvider, pki_types::ServerName};
|
||||
use std::{
|
||||
@@ -443,7 +443,7 @@ impl Idevice {
|
||||
// My sanity while debugging the workspace crates are more important.
|
||||
|
||||
debug!("Using ring crypto backend, because both were passed");
|
||||
warn!("Both ring && aws-lc are selected as idevice crypto backends!");
|
||||
log::warn!("Both ring && aws-lc are selected as idevice crypto backends!");
|
||||
rustls::crypto::ring::default_provider()
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ use log::warn;
|
||||
use opcode::{AfcFopenMode, AfcOpcode};
|
||||
use packet::{AfcPacket, AfcPacketHeader};
|
||||
|
||||
use crate::{obf, Idevice, IdeviceError, IdeviceService};
|
||||
use crate::{Idevice, IdeviceError, IdeviceService, obf};
|
||||
|
||||
pub mod errors;
|
||||
pub mod file;
|
||||
@@ -376,11 +376,11 @@ impl AfcClient {
|
||||
///
|
||||
/// # Returns
|
||||
/// A `FileDescriptor` struct for the opened file
|
||||
pub async fn open(
|
||||
&mut self,
|
||||
pub async fn open<'f>(
|
||||
&'f mut self,
|
||||
path: impl Into<String>,
|
||||
mode: AfcFopenMode,
|
||||
) -> Result<FileDescriptor, IdeviceError> {
|
||||
) -> Result<FileDescriptor<'f>, IdeviceError> {
|
||||
let path = path.into();
|
||||
let mut header_payload = (mode as u64).to_le_bytes().to_vec();
|
||||
header_payload.extend(path.as_bytes());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use log::warn;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{obf, IdeviceError, ReadWrite, RsdService};
|
||||
use crate::{IdeviceError, ReadWrite, RsdService, obf};
|
||||
|
||||
use super::CoreDeviceServiceClient;
|
||||
|
||||
@@ -128,7 +128,7 @@ pub struct IconUuid {
|
||||
pub classes: Vec<String>,
|
||||
}
|
||||
|
||||
impl<'a, R: ReadWrite + 'a> AppServiceClient<R> {
|
||||
impl<R: ReadWrite> AppServiceClient<R> {
|
||||
pub async fn new(stream: R) -> Result<Self, IdeviceError> {
|
||||
Ok(Self {
|
||||
inner: CoreDeviceServiceClient::new(stream).await?,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
use log::warn;
|
||||
|
||||
use crate::{
|
||||
xpc::{self, XPCObject},
|
||||
IdeviceError, ReadWrite, RemoteXpcClient,
|
||||
xpc::{self, XPCObject},
|
||||
};
|
||||
|
||||
mod app_service;
|
||||
@@ -17,7 +17,7 @@ pub struct CoreDeviceServiceClient<R: ReadWrite> {
|
||||
inner: RemoteXpcClient<R>,
|
||||
}
|
||||
|
||||
impl<'a, R: ReadWrite + 'a> CoreDeviceServiceClient<R> {
|
||||
impl<R: ReadWrite> CoreDeviceServiceClient<R> {
|
||||
pub async fn new(inner: R) -> Result<Self, IdeviceError> {
|
||||
let mut client = RemoteXpcClient::new(inner).await?;
|
||||
client.do_handshake().await?;
|
||||
|
||||
@@ -55,8 +55,8 @@ use log::{debug, warn};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
use crate::{
|
||||
dvt::message::{Aux, AuxValue, Message, MessageHeader, PayloadHeader},
|
||||
IdeviceError, ReadWrite,
|
||||
dvt::message::{Aux, AuxValue, Message, MessageHeader, PayloadHeader},
|
||||
};
|
||||
|
||||
/// Message type identifier for instruments protocol
|
||||
@@ -112,7 +112,7 @@ impl<R: ReadWrite> RemoteServerClient<R> {
|
||||
}
|
||||
|
||||
/// Returns a handle to the root channel (channel 0)
|
||||
pub fn root_channel(&mut self) -> Channel<R> {
|
||||
pub fn root_channel<'c>(&'c mut self) -> Channel<'c, R> {
|
||||
Channel {
|
||||
client: self,
|
||||
channel: 0,
|
||||
@@ -131,10 +131,10 @@ impl<R: ReadWrite> RemoteServerClient<R> {
|
||||
/// # Errors
|
||||
/// * `IdeviceError::UnexpectedResponse` if server responds with unexpected data
|
||||
/// * Other IO or serialization errors
|
||||
pub async fn make_channel(
|
||||
&mut self,
|
||||
pub async fn make_channel<'c>(
|
||||
&'c mut self,
|
||||
identifier: impl Into<String>,
|
||||
) -> Result<Channel<R>, IdeviceError> {
|
||||
) -> Result<Channel<'c, R>, IdeviceError> {
|
||||
let code = self.new_channel;
|
||||
self.new_channel += 1;
|
||||
|
||||
@@ -164,7 +164,7 @@ impl<R: ReadWrite> RemoteServerClient<R> {
|
||||
self.build_channel(code)
|
||||
}
|
||||
|
||||
fn build_channel(&mut self, code: u32) -> Result<Channel<R>, IdeviceError> {
|
||||
fn build_channel<'c>(&'c mut self, code: u32) -> Result<Channel<'c, R>, IdeviceError> {
|
||||
Ok(Channel {
|
||||
client: self,
|
||||
channel: code,
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::collections::HashMap;
|
||||
use log::warn;
|
||||
use plist::Dictionary;
|
||||
|
||||
use crate::{obf, Idevice, IdeviceError, IdeviceService};
|
||||
use crate::{Idevice, IdeviceError, IdeviceService, obf};
|
||||
|
||||
/// Client for interacting with the iOS installation proxy service
|
||||
///
|
||||
@@ -376,12 +376,12 @@ impl InstallationProxyClient {
|
||||
break;
|
||||
}
|
||||
|
||||
if let Some(status) = res.get("Status").and_then(|x| x.as_string()) {
|
||||
if status == "Complete" {
|
||||
if let Some(status) = res.get("Status").and_then(|x| x.as_string())
|
||||
&& status == "Complete"
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(values)
|
||||
}
|
||||
|
||||
@@ -424,12 +424,12 @@ impl InstallationProxyClient {
|
||||
callback((c, state.clone())).await;
|
||||
}
|
||||
|
||||
if let Some(c) = res.remove("Status").and_then(|x| x.into_string()) {
|
||||
if c == "Complete" {
|
||||
if let Some(c) = res.remove("Status").and_then(|x| x.into_string())
|
||||
&& c == "Complete"
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use log::debug;
|
||||
|
||||
use crate::{obf, Idevice, IdeviceError, IdeviceService};
|
||||
use crate::{Idevice, IdeviceError, IdeviceService, obf};
|
||||
use sha2::{Digest, Sha384};
|
||||
|
||||
#[cfg(feature = "tss")]
|
||||
@@ -710,11 +710,10 @@ impl ImageMounter {
|
||||
.and_then(|l| l.as_dictionary())
|
||||
.and_then(|l| l.get("Info"))
|
||||
.and_then(|i| i.as_dictionary())
|
||||
&& let Some(plist::Value::Array(rules)) = info.get("RestoreRequestRules")
|
||||
{
|
||||
if let Some(plist::Value::Array(rules)) = info.get("RestoreRequestRules") {
|
||||
crate::tss::apply_restore_request_rules(&mut tss_entry, ¶meters, rules);
|
||||
}
|
||||
}
|
||||
|
||||
if manifest_item.get("Digest").is_none() {
|
||||
tss_entry.insert("Digest".into(), plist::Value::Data(vec![]));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use log::{debug, warn};
|
||||
use plist::Value;
|
||||
|
||||
use crate::{util::plist_to_xml_bytes, IdeviceError};
|
||||
use crate::{IdeviceError, util::plist_to_xml_bytes};
|
||||
|
||||
/// TSS client version string sent in requests
|
||||
const TSS_CLIENT_VERSION_STRING: &str = "libauthinstall-1033.0.2";
|
||||
@@ -172,16 +172,16 @@ pub fn apply_restore_request_rules(
|
||||
|
||||
for (key, value) in actions {
|
||||
// Skip special values (255 typically means "ignore")
|
||||
if let Some(i) = value.as_unsigned_integer() {
|
||||
if i == 255 {
|
||||
if let Some(i) = value.as_unsigned_integer()
|
||||
&& i == 255
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(i) = value.as_signed_integer() {
|
||||
if i == 255 {
|
||||
if let Some(i) = value.as_signed_integer()
|
||||
&& i == 255
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
input.remove(key); // Explicitly remove before inserting
|
||||
input.insert(key.to_owned(), value.to_owned());
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct Http2Client<R: ReadWrite> {
|
||||
cache: HashMap<u32, VecDeque<Vec<u8>>>,
|
||||
}
|
||||
|
||||
impl<'a, R: ReadWrite + 'a> Http2Client<R> {
|
||||
impl<R: ReadWrite> Http2Client<R> {
|
||||
/// Writes the magic and inits the caches
|
||||
pub async fn new(mut inner: R) -> Result<Self, IdeviceError> {
|
||||
inner.write_all(HTTP2_MAGIC).await?;
|
||||
|
||||
@@ -17,15 +17,14 @@ const REPLY_CHANNEL: u32 = 3;
|
||||
pub struct RemoteXpcClient<R: ReadWrite> {
|
||||
h2_client: http2::Http2Client<R>,
|
||||
root_id: u64,
|
||||
reply_id: u64,
|
||||
// reply_id: u64 // maybe not used?
|
||||
}
|
||||
|
||||
impl<'a, R: ReadWrite + 'a> RemoteXpcClient<R> {
|
||||
impl<R: ReadWrite> RemoteXpcClient<R> {
|
||||
pub async fn new(socket: R) -> Result<Self, IdeviceError> {
|
||||
Ok(Self {
|
||||
h2_client: http2::Http2Client::new(socket).await?,
|
||||
root_id: 1,
|
||||
reply_id: 1,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,12 +85,12 @@ impl<'a, R: ReadWrite + 'a> RemoteXpcClient<R> {
|
||||
|
||||
match msg.message {
|
||||
Some(msg) => {
|
||||
if let Some(d) = msg.as_dictionary() {
|
||||
if d.is_empty() {
|
||||
if let Some(d) = msg.as_dictionary()
|
||||
&& d.is_empty()
|
||||
{
|
||||
msg_buffer.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break Ok(msg.to_plist());
|
||||
}
|
||||
None => {
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "idevice-tools"
|
||||
description = "Rust binary tools to interact with services on iOS devices."
|
||||
authors = ["Jackson Coxson"]
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
documentation = "https://docs.rs/idevice"
|
||||
repository = "https://github.com/jkcoxson/idevice"
|
||||
|
||||
@@ -38,14 +38,16 @@ pub async fn get_provider(
|
||||
}
|
||||
};
|
||||
Box::new(dev.to_provider(UsbmuxdAddr::from_env_var().unwrap(), label))
|
||||
} else if host.is_some() && pairing_file.is_some() {
|
||||
let host = match IpAddr::from_str(host.unwrap()) {
|
||||
} else if let Some(host) = host
|
||||
&& let Some(pairing_file) = pairing_file
|
||||
{
|
||||
let host = match IpAddr::from_str(host) {
|
||||
Ok(h) => h,
|
||||
Err(e) => {
|
||||
return Err(format!("Invalid host: {e:?}"));
|
||||
}
|
||||
};
|
||||
let pairing_file = match PairingFile::read_from_file(pairing_file.unwrap()) {
|
||||
let pairing_file = match PairingFile::read_from_file(pairing_file) {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
return Err(format!("Unable to read pairing file: {e:?}"));
|
||||
|
||||
Reference in New Issue
Block a user