pub struct LockdownClient {
pub idevice: Idevice,
pub session_id: Option<String>,
}Expand description
Client for interacting with the iOS lockdown service
This is the primary service for device management and provides:
- Access to device information and settings
- Service discovery and port allocation
- Session management and security
Fields§
§idevice: IdeviceThe underlying device connection with established lockdown service
session_id: Option<String>Implementations§
Source§impl LockdownClient
impl LockdownClient
Sourcepub const LOCKDOWND_PORT: u16 = 62078
pub const LOCKDOWND_PORT: u16 = 62078
The default TCP port for the lockdown service
Sourcepub fn new(idevice: Idevice) -> Self
pub fn new(idevice: Idevice) -> Self
Creates a new lockdown client from an existing device connection
§Arguments
idevice- Pre-established device connection
Sourcepub async fn get_value(
&mut self,
key: Option<&str>,
domain: Option<&str>,
) -> Result<Value, IdeviceError>
pub async fn get_value( &mut self, key: Option<&str>, domain: Option<&str>, ) -> Result<Value, IdeviceError>
Retrieves a specific value from the device
§Arguments
value- The name of the value to retrieve (e.g., “DeviceName”)
§Returns
The requested value as a plist Value
§Errors
Returns IdeviceError if:
- Communication fails
- The requested value doesn’t exist
- The response is malformed
§Example
let device_name = client.get_value("DeviceName").await?;
println!("Device name: {:?}", device_name);Sourcepub async fn set_value(
&mut self,
key: impl Into<String>,
value: Value,
domain: Option<&str>,
) -> Result<(), IdeviceError>
pub async fn set_value( &mut self, key: impl Into<String>, value: Value, domain: Option<&str>, ) -> Result<(), IdeviceError>
Sets a value on the device
§Arguments
key- The key to setvalue- The plist value to setdomain- An optional domain to set by
§Errors
Returns IdeviceError if:
- Communication fails
- The response is malformed
§Example
client.set_value("EnableWifiDebugging", true.into(), Some("com.apple.mobile.wireless_lockdown".to_string())).await?;Sourcepub async fn remove_value(
&mut self,
key: impl Into<String>,
domain: Option<&str>,
) -> Result<(), IdeviceError>
pub async fn remove_value( &mut self, key: impl Into<String>, domain: Option<&str>, ) -> Result<(), IdeviceError>
Removes a value on the device
Sends a lockdown RemoveValue request. Wire format matches Apple’s
AMDeviceRemoveValue: { "Request": "RemoveValue", "Domain"?: domain, "Key": key }.
§Arguments
key- The key to removedomain- An optional domain to remove from
§Errors
Returns IdeviceError if communication fails or the device replies with an Error
Sourcepub async fn unpair(
&mut self,
host_id: impl Into<String>,
) -> Result<(), IdeviceError>
pub async fn unpair( &mut self, host_id: impl Into<String>, ) -> Result<(), IdeviceError>
Unpairs the host from the device
Sends a lockdown Unpair request carrying the host pair-record identity.
Note this only removes the pairing from the device side. The host-side pairing record
(stored by usbmuxd) should be removed separately via
crate::usbmuxd::UsbmuxdConnection::delete_pair_record.
§Arguments
host_id- TheHostIDfrom the pairing record (seecrate::pairing_file::PairingFile::host_id)
§Errors
Returns IdeviceError if communication fails or the device replies with an Error.
Sourcepub async fn start_session(
&mut self,
pairing_file: &PairingFile,
) -> Result<bool, IdeviceError>
pub async fn start_session( &mut self, pairing_file: &PairingFile, ) -> Result<bool, IdeviceError>
Starts a secure TLS session with the device
§Arguments
pairing_file- Contains the device’s identity and certificates
§Returns
Ok(legacy) on successful session establishment, where legacy indicates
whether the device is running iOS < 5 and requires legacy TLS settings
§Errors
Returns IdeviceError if:
- No connection is established
- The session request is denied
- TLS handshake fails
Sourcepub async fn stop_session(&mut self) -> Result<(), IdeviceError>
pub async fn stop_session(&mut self) -> Result<(), IdeviceError>
Stops the secure lockdown session previously started with start_session.
Sends a lockdown StopSession request carrying the SessionID the device returned when the
session was started. Note this does NOT tear down the TLS socket in place, the caller is
expected to drop the connection.
§Errors
Returns IdeviceError if communication fails or the device replies with an Error.
Sourcepub async fn start_service(
&mut self,
identifier: impl Into<String>,
) -> Result<(u16, bool), IdeviceError>
pub async fn start_service( &mut self, identifier: impl Into<String>, ) -> Result<(u16, bool), IdeviceError>
Requests to start a service on the device
§Arguments
identifier- The service identifier (e.g., “com.apple.debugserver”)
§Returns
A tuple containing:
- The port number where the service is available
- A boolean indicating whether SSL should be used
§Errors
Returns IdeviceError if:
- The service cannot be started
- The response is malformed
- The requested service doesn’t exist
Sourcepub async fn start_service_with_escrow(
&mut self,
identifier: impl Into<String>,
escrow_bag: Option<Vec<u8>>,
) -> Result<(u16, bool), IdeviceError>
pub async fn start_service_with_escrow( &mut self, identifier: impl Into<String>, escrow_bag: Option<Vec<u8>>, ) -> Result<(u16, bool), IdeviceError>
Requests to start a service, optionally presenting an escrow keybag so the device unlocks its data protection for the service session.
This mirrors Apple’s AMDeviceSecureStartService with UnlockEscrowBag = true: the
StartService lockdown request gains an EscrowBag key. Without it the device leaves data
protection locked, so a service that must write protection-class files (mobilebackup2
restore of an encrypted backup, house_arrest) fails device-side with
“setting protection class (device locked?)” (MBErrorDomain 208). Non-protected data is
unaffected, which is why a non-encrypted restore succeeds without the escrow bag.
§Arguments
identifier- The service identifier (e.g., “com.apple.mobilebackup2”)escrow_bag- The device’s escrow keybag from the pairing record;Nonebehaves exactly likestart_service.
Sourcepub async fn pair(
&mut self,
host_id: impl Into<String>,
system_buid: impl Into<String>,
host_name: Option<&str>,
) -> Result<PairingFile, IdeviceError>
pub async fn pair( &mut self, host_id: impl Into<String>, system_buid: impl Into<String>, host_name: Option<&str>, ) -> Result<PairingFile, IdeviceError>
Generates a pairing file and sends it to the device for trusting. Note that this does NOT save the file to usbmuxd’s cache. That’s a responsibility of the caller. Note that this function is computationally heavy in a debug build.
§Arguments
host_id- The host ID, in the form of a UUID. Typically generated from the host namesystem_buid- UUID fetched from usbmuxd. Doesn’t appear to affect function.
§Returns
The newly generated pairing record
§Errors
Returns IdeviceError
Sourcepub async fn pair_once(
&mut self,
host_id: impl Into<String>,
system_buid: impl Into<String>,
host_name: Option<&str>,
) -> Result<PairingFile, IdeviceError>
pub async fn pair_once( &mut self, host_id: impl Into<String>, system_buid: impl Into<String>, host_name: Option<&str>, ) -> Result<PairingFile, IdeviceError>
Attempts to pair with the device exactly ONCE, without looping or sleeping.
Unlike LockdownClient::pair, this does NOT block on
IdeviceError::PairingDialogResponsePending: the pending/denied/password-protected
errors are propagated directly to the caller so it can drive its own retry/UI flow (e.g.
showing a “Trust This Computer” prompt). The lockdown “Error” field is mapped to the
corresponding IdeviceError variant by read_plist.
Note that this does NOT save the file to usbmuxd’s cache. That’s a responsibility of the caller.
§Arguments
host_id- The host ID, in the form of a UUID. Typically generated from the host namesystem_buid- UUID fetched from usbmuxd. Doesn’t appear to affect function.
§Returns
The newly generated pairing record on success.
§Errors
Returns IdeviceError, including PairingDialogResponsePending, UserDeniedPairing, and
PasswordProtected surfaced directly from the device.
Sourcepub async fn enter_recovery(&mut self) -> Result<(), IdeviceError>
pub async fn enter_recovery(&mut self) -> Result<(), IdeviceError>
Tell the device to enter recovery mode
Trait Implementations§
Source§impl Debug for LockdownClient
impl Debug for LockdownClient
Source§impl From<Idevice> for LockdownClient
impl From<Idevice> for LockdownClient
Source§impl IdeviceService for LockdownClient
impl IdeviceService for LockdownClient
Source§fn service_name() -> Cow<'static, str>
fn service_name() -> Cow<'static, str>
Returns the lockdown service name as registered with the device
Source§async fn connect(provider: &dyn IdeviceProvider) -> Result<Self, IdeviceError>
async fn connect(provider: &dyn IdeviceProvider) -> Result<Self, IdeviceError>
async fn from_stream(idevice: Idevice) -> Result<Self, IdeviceError>
Source§impl RsdService for LockdownClient
Available on crate feature rsd only.
impl RsdService for LockdownClient
rsd only.