From c80512f37fccf11d6a52cc59ae046070c384c88f Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Mon, 11 Aug 2025 13:56:09 -0600 Subject: [PATCH] Unify IdeviceService creation behavior with trait --- .github/workflows/ci.yml | 6 +-- idevice/src/lib.rs | 24 +++++++++-- idevice/src/services/afc/mod.rs | 27 +------------ idevice/src/services/amfi.rs | 39 ++---------------- idevice/src/services/core_device_proxy.rs | 31 +------------- idevice/src/services/crashreportcopymobile.rs | 39 +----------------- idevice/src/services/diagnostics_relay.rs | 39 ++---------------- idevice/src/services/heartbeat.rs | 40 ++----------------- idevice/src/services/house_arrest.rs | 39 ++---------------- idevice/src/services/installation_proxy.rs | 36 +---------------- idevice/src/services/lockdown.rs | 4 ++ idevice/src/services/misagent.rs | 36 +---------------- idevice/src/services/mobile_image_mounter.rs | 39 ++---------------- idevice/src/services/os_trace_relay.rs | 37 +---------------- idevice/src/services/springboardservices.rs | 39 ++---------------- idevice/src/services/syslog_relay.rs | 39 ++---------------- 16 files changed, 59 insertions(+), 455 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 564a62c..88ecc35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,6 @@ jobs: run: | brew install just - - name: Install libplist - run: | - brew install libplist - - name: Cache Cargo uses: actions/cache@v4 with: @@ -73,7 +69,7 @@ jobs: - name: Install build dependencies run: | - sudo apt-get update && sudo apt-get install -y build-essential cmake libplist + sudo apt-get update && sudo apt-get install -y build-essential cmake - name: Install just run: | diff --git a/idevice/src/lib.rs b/idevice/src/lib.rs index b7bbe13..e1d64f8 100644 --- a/idevice/src/lib.rs +++ b/idevice/src/lib.rs @@ -37,6 +37,8 @@ use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; pub use util::{pretty_print_dictionary, pretty_print_plist}; +use crate::services::lockdown::LockdownClient; + /// A trait combining all required characteristics for a device communication socket /// /// This serves as a convenience trait for any type that can be used as an asynchronous @@ -61,9 +63,25 @@ pub trait IdeviceService: Sized { /// /// # Arguments /// * `provider` - The device provider that can supply connections - fn connect( - provider: &dyn IdeviceProvider, - ) -> impl std::future::Future> + Send; + async fn connect(provider: &dyn IdeviceProvider) -> Result { + let mut lockdown = LockdownClient::connect(provider).await?; + lockdown + .start_session(&provider.get_pairing_file().await?) + .await?; + + let (port, ssl) = lockdown.start_service(Self::service_name()).await?; + + let mut idevice = provider.connect(port).await?; + if ssl { + idevice + .start_session(&provider.get_pairing_file().await?) + .await?; + } + + Self::from_stream(idevice).await + } + + async fn from_stream(idevice: Idevice) -> Result; } #[cfg(feature = "rsd")] diff --git a/idevice/src/services/afc/mod.rs b/idevice/src/services/afc/mod.rs index c84a692..634e379 100644 --- a/idevice/src/services/afc/mod.rs +++ b/idevice/src/services/afc/mod.rs @@ -11,7 +11,7 @@ use log::warn; use opcode::{AfcFopenMode, AfcOpcode}; use packet::{AfcPacket, AfcPacketHeader}; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; pub mod errors; pub mod file; @@ -65,30 +65,7 @@ impl IdeviceService for AfcClient { obf!("com.apple.afc") } - /// Connects to the AFC service on the device - /// - /// # Arguments - /// * `provider` - The iDevice provider to use for the connection - /// - /// # Returns - /// A new `AfcClient` instance on success - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - + async fn from_stream(idevice: Idevice) -> Result { Ok(Self { idevice, package_number: 0, diff --git a/idevice/src/services/amfi.rs b/idevice/src/services/amfi.rs index 41c92bd..c317127 100644 --- a/idevice/src/services/amfi.rs +++ b/idevice/src/services/amfi.rs @@ -2,7 +2,7 @@ use plist::Dictionary; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the AMFI service on the device pub struct AmfiClient { @@ -16,41 +16,8 @@ impl IdeviceService for AmfiClient { obf!("com.apple.amfi.lockdown") } - /// Establishes a connection to the amfi service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `AmfiClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the amfi service port - /// 4. Establishes connection to the amfi port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/core_device_proxy.rs b/idevice/src/services/core_device_proxy.rs index 6c714e3..6aafed3 100644 --- a/idevice/src/services/core_device_proxy.rs +++ b/idevice/src/services/core_device_proxy.rs @@ -13,7 +13,7 @@ //! # Features //! - `tunnel_tcp_stack`: Enables software TCP/IP tunnel creation using a virtual adapter. See the tcp moduel. -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; use byteorder::{BigEndian, WriteBytesExt}; use serde::{Deserialize, Serialize}; @@ -97,34 +97,7 @@ impl IdeviceService for CoreDeviceProxy { obf!("com.apple.internal.devicecompute.CoreDeviceProxy") } - /// Connects to the CoreDeviceProxy service - /// - /// # Arguments - /// - /// * `provider` - An implementation of `IdeviceProvider` that supplies - /// pairing data and socket connections. - /// - /// # Returns - /// - /// * `Ok(CoreDeviceProxy)` if connection and handshake succeed. - /// * `Err(IdeviceError)` if any step fails. - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - + async fn from_stream(idevice: Idevice) -> Result { Self::new(idevice).await } } diff --git a/idevice/src/services/crashreportcopymobile.rs b/idevice/src/services/crashreportcopymobile.rs index afc2b1f..7b426d4 100644 --- a/idevice/src/services/crashreportcopymobile.rs +++ b/idevice/src/services/crashreportcopymobile.rs @@ -26,43 +26,8 @@ impl IdeviceService for CrashReportCopyMobileClient { obf!("com.apple.crashreportcopymobile") } - /// Connects to the CrashReportCopyMobile service on the device. - /// - /// # Arguments - /// * `provider` - The provider used to access the device and pairing info. - /// - /// # Returns - /// A connected `CrashReportCopyMobileClient`. - /// - /// # Errors - /// Returns `IdeviceError` if the connection fails at any stage. - /// - /// # Process - /// 1. Connects to the lockdownd service. - /// 2. Starts a lockdown session. - /// 3. Requests the CrashReportCopyMobile service. - /// 4. Establishes a connection to the service. - /// 5. Performs SSL handshake if required. - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { - afc_client: AfcClient::new(idevice), - }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/diagnostics_relay.rs b/idevice/src/services/diagnostics_relay.rs index bb5a545..7811b85 100644 --- a/idevice/src/services/diagnostics_relay.rs +++ b/idevice/src/services/diagnostics_relay.rs @@ -1,6 +1,6 @@ //! Diagnostics Relay -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the Diagnostics Relay pub struct DiagnosticsRelayClient { @@ -14,41 +14,8 @@ impl IdeviceService for DiagnosticsRelayClient { obf!("com.apple.mobile.diagnostics_relay") } - /// Establishes a connection to the service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `DiagnosticsRelayClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the service port - /// 4. Establishes connection to the port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/heartbeat.rs b/idevice/src/services/heartbeat.rs index cf8d144..a57690d 100644 --- a/idevice/src/services/heartbeat.rs +++ b/idevice/src/services/heartbeat.rs @@ -3,7 +3,7 @@ //! iOS automatically closes service connections if there is no heartbeat client connected and //! responding. -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the iOS device heartbeat service /// @@ -22,42 +22,8 @@ impl IdeviceService for HeartbeatClient { fn service_name() -> std::borrow::Cow<'static, str> { obf!("com.apple.mobile.heartbeat") } - - /// Establishes a connection to the heartbeat service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `HeartbeatClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the heartbeat service port - /// 4. Establishes connection to the heartbeat port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/house_arrest.rs b/idevice/src/services/house_arrest.rs index 2a4c619..f4de8ab 100644 --- a/idevice/src/services/house_arrest.rs +++ b/idevice/src/services/house_arrest.rs @@ -6,7 +6,7 @@ use plist::{Dictionary, Value}; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; use super::afc::AfcClient; @@ -25,41 +25,8 @@ impl IdeviceService for HouseArrestClient { obf!("com.apple.mobile.house_arrest") } - /// Establishes a connection to the HouseArrest service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `HouseArrestClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connect to the lockdownd service - /// 2. Start a lockdown session - /// 3. Request the HouseArrest service - /// 4. Connect to the returned service port - /// 5. Start TLS if required by the service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/installation_proxy.rs b/idevice/src/services/installation_proxy.rs index 3b4014f..b7111f2 100644 --- a/idevice/src/services/installation_proxy.rs +++ b/idevice/src/services/installation_proxy.rs @@ -8,7 +8,7 @@ use std::collections::HashMap; use log::warn; use plist::Dictionary; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the iOS installation proxy service /// @@ -25,39 +25,7 @@ impl IdeviceService for InstallationProxyClient { obf!("com.apple.mobile.installation_proxy") } - /// Establishes a connection to the installation proxy service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `InstallationProxyClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the installation proxy service port - /// 4. Establishes connection to the service port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - + async fn from_stream(idevice: Idevice) -> Result { Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/lockdown.rs b/idevice/src/services/lockdown.rs index 2c1627d..cbbd2a9 100644 --- a/idevice/src/services/lockdown.rs +++ b/idevice/src/services/lockdown.rs @@ -42,6 +42,10 @@ impl IdeviceService for LockdownClient { let idevice = provider.connect(Self::LOCKDOWND_PORT).await?; Ok(Self::new(idevice)) } + + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) + } } /// Internal structure for lockdown protocol requests diff --git a/idevice/src/services/misagent.rs b/idevice/src/services/misagent.rs index 4f2f03d..a3e3787 100644 --- a/idevice/src/services/misagent.rs +++ b/idevice/src/services/misagent.rs @@ -6,7 +6,7 @@ use log::warn; use plist::Dictionary; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService, RsdService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService, RsdService}; /// Client for interacting with the iOS misagent service /// @@ -37,39 +37,7 @@ impl IdeviceService for MisagentClient { obf!("com.apple.misagent") } - /// Establishes a connection to the misagent service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `MisagentClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the misagent service port - /// 4. Establishes connection to the service port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - + async fn from_stream(idevice: Idevice) -> Result { Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/mobile_image_mounter.rs b/idevice/src/services/mobile_image_mounter.rs index 2472719..8ec22d3 100644 --- a/idevice/src/services/mobile_image_mounter.rs +++ b/idevice/src/services/mobile_image_mounter.rs @@ -9,7 +9,7 @@ use log::debug; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; use sha2::{Digest, Sha384}; #[cfg(feature = "tss")] @@ -33,41 +33,8 @@ impl IdeviceService for ImageMounter { obf!("com.apple.mobile.mobile_image_mounter") } - /// Establishes a connection to the image mounter service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `ImageMounter` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the image mounter service port - /// 4. Establishes connection to the service port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/os_trace_relay.rs b/idevice/src/services/os_trace_relay.rs index 8ff203d..0a6d4eb 100644 --- a/idevice/src/services/os_trace_relay.rs +++ b/idevice/src/services/os_trace_relay.rs @@ -7,7 +7,7 @@ use chrono::{DateTime, NaiveDateTime}; use plist::Dictionary; use tokio::io::AsyncWriteExt; -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the iOS device OsTraceRelay service pub struct OsTraceRelayClient { @@ -21,40 +21,7 @@ impl IdeviceService for OsTraceRelayClient { obf!("com.apple.os_trace_relay") } - /// Establishes a connection to the OsTraceRelay service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `OsTraceRelayClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the OsTraceRelay service port - /// 4. Establishes connection to the OsTraceRelay port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - + async fn from_stream(idevice: Idevice) -> Result { Ok(Self { idevice }) } } diff --git a/idevice/src/services/springboardservices.rs b/idevice/src/services/springboardservices.rs index a2da261..99a8564 100644 --- a/idevice/src/services/springboardservices.rs +++ b/idevice/src/services/springboardservices.rs @@ -3,7 +3,7 @@ //! Provides functionality for interacting with the SpringBoard services on iOS devices, //! which manages home screen and app icon related operations. -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the iOS SpringBoard services /// @@ -20,41 +20,8 @@ impl IdeviceService for SpringBoardServicesClient { obf!("com.apple.springboardservices") } - /// Establishes a connection to the SpringBoard services - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `SpringBoardServicesClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the SpringBoard services port - /// 4. Establishes connection to the service port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } } diff --git a/idevice/src/services/syslog_relay.rs b/idevice/src/services/syslog_relay.rs index 3553757..cf1069a 100644 --- a/idevice/src/services/syslog_relay.rs +++ b/idevice/src/services/syslog_relay.rs @@ -1,6 +1,6 @@ //! iOS Device SyslogRelay Service Abstraction -use crate::{lockdown::LockdownClient, obf, Idevice, IdeviceError, IdeviceService}; +use crate::{obf, Idevice, IdeviceError, IdeviceService}; /// Client for interacting with the iOS device SyslogRelay service pub struct SyslogRelayClient { @@ -14,41 +14,8 @@ impl IdeviceService for SyslogRelayClient { obf!("com.apple.syslog_relay") } - /// Establishes a connection to the SyslogRelay service - /// - /// # Arguments - /// * `provider` - Device connection provider - /// - /// # Returns - /// A connected `SyslogRelayClient` instance - /// - /// # Errors - /// Returns `IdeviceError` if any step of the connection process fails - /// - /// # Process - /// 1. Connects to lockdownd service - /// 2. Starts a lockdown session - /// 3. Requests the SyslogRelay service port - /// 4. Establishes connection to the SyslogRelay port - /// 5. Optionally starts TLS if required by service - async fn connect( - provider: &dyn crate::provider::IdeviceProvider, - ) -> Result { - let mut lockdown = LockdownClient::connect(provider).await?; - lockdown - .start_session(&provider.get_pairing_file().await?) - .await?; - - let (port, ssl) = lockdown.start_service(Self::service_name()).await?; - - let mut idevice = provider.connect(port).await?; - if ssl { - idevice - .start_session(&provider.get_pairing_file().await?) - .await?; - } - - Ok(Self { idevice }) + async fn from_stream(idevice: Idevice) -> Result { + Ok(Self::new(idevice)) } }