Skip to content

Commit

Permalink
lockdown: add create_using_remote()
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Jul 6, 2023
1 parent 81379d8 commit 5a405a3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pymobiledevice3/lockdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,33 @@ def create_using_tcp(hostname: str, identifier: str = None, label: str = DEFAULT
pairing_records_cache_folder=pairing_records_cache_folder, pair_timeout=pair_timeout, autopair=autopair,
port=port, hostname=hostname)
return client


def create_using_remote(hostname: str, identifier: str = None, label: str = DEFAULT_LABEL, autopair: bool = True,
pair_timeout: int = None, local_hostname: str = None, pair_record: Mapping = None,
pairing_records_cache_folder: Path = None,
port: int = SERVICE_PORT) -> TcpLockdownClient:
"""
Create a TcpLockdownClient instance
:param hostname: The target device hostname
:param identifier: Used as an identifier to look for the device pair record
:param label: lockdownd user-agent
:param autopair: Attempt to pair with device (blocking) if not already paired
:param pair_timeout: Timeout for autopair
:param local_hostname: Used as a seed to generate the HostID
:param pair_record: Use this pair record instead of the default behavior (search in host/create our own)
:param pairing_records_cache_folder: Use the following location to search and save pair records
:param port: lockdownd service port
:return: TcpLockdownClient instance
"""
service = ServiceConnection.create_using_tcp(hostname, port)
service.send_plist({'Label': label, 'ProtocolVersion': '2', 'Request': 'RSDCheckin'})
service.recv_plist()
service.recv_plist()

client = TcpLockdownClient.create(
service, identifier=identifier, label=label, local_hostname=local_hostname, pair_record=pair_record,
pairing_records_cache_folder=pairing_records_cache_folder, pair_timeout=pair_timeout, autopair=autopair,
port=port, hostname=hostname)
return client

0 comments on commit 5a405a3

Please sign in to comment.