Skip to content

fix: feature gating for error conversions and dead deps#95

Merged
jkcoxson merged 1 commit into
jkcoxson:masterfrom
maxslarsson:fix/feature-gating-cleanup
May 7, 2026
Merged

fix: feature gating for error conversions and dead deps#95
jkcoxson merged 1 commit into
jkcoxson:masterfrom
maxslarsson:fix/feature-gating-cleanup

Conversation

@maxslarsson
Copy link
Copy Markdown
Contributor

From<serde_json::Error> for IdeviceError was gated behind #[cfg(feature = "core_device_proxy")], but multiple features (wda, remote_pairing, tunneld) also pull in serde_json and need that conversion. Compiling remote_pairing without core_device_proxy would fail. The same bug existed for reqwestmobileactivationd depends on it but wasn't listed in the Reqwest error variant gate.

Additionally, two optional dependencies (json and byteorder) were declared and activated by features but never actually imported anywhere in the source code. And remote_pairing used RemoteXpcClient from the xpc module without declaring xpc as a dependency.

Changes

Internal feature flags (Cargo.toml)

  • Added _serde_json = ["dep:serde_json"] — all features needing serde_json depend on this instead of dep:serde_json directly
  • Added _reqwest = ["dep:reqwest"] — same pattern for reqwest
  • This way, the error From impl gate (#[cfg(feature = "_serde_json")]) never drifts from which features actually bring in the dep

Dead dependency removal (Cargo.toml)

  • Removed json (v0.12) — never imported in source, leftover from before serde_json migration
  • Removed byteorder (v1.5) — never imported in source, was listed in core_device_proxy and dvt for no reason

Missing dependency (Cargo.toml)

  • Added xpc to remote_pairing feature — remote_pairing/socket.rs imports RemoteXpcClient and xpc::XPCObject

Error variant gates (lib.rs)

  • Json variant: #[cfg(feature = "core_device_proxy")] -> #[cfg(feature = "_serde_json")]
  • Reqwest variant: #[cfg(any(feature = "tss", feature = "tunneld"))] -> #[cfg(feature = "_reqwest")]
  • Updated matching arms in code() method accordingly

Workaround removal (tunnel.rs, remote_pairing/tunnel.rs)

  • Removed .map_err(|e| IdeviceError::InternalError(e.to_string())) on serde_json calls — now that the From impl is available, plain ? works

- Add internal _serde_json and _reqwest features to gate From impls
- Remove unused json and byteorder optional dependencies
- Add missing xpc dependency to remote_pairing feature
- Simplify map_err workarounds in tunnel code to use ? directly
@jkcoxson jkcoxson merged commit 1d04b09 into jkcoxson:master May 7, 2026
3 checks passed
maxslarsson added a commit to maxslarsson/idevice that referenced this pull request May 7, 2026
- Add internal _serde_json and _reqwest features to gate From impls
- Remove unused json and byteorder optional dependencies
- Add missing xpc dependency to remote_pairing feature
- Simplify map_err workarounds in tunnel code to use ? directly
jkcoxson pushed a commit that referenced this pull request May 8, 2026
…gClient (#96)

* refactor: remove pairing_file field and state param from RemotePairingClient

Move pairing_file from a struct field (&'a mut borrow) to a parameter
on connect() and its callees. This removes the lifetime parameter from
the struct and scopes the mutable borrow to the function call.

Also remove the unused state: S generic from connect/pair/request_pair_consent,
since every caller passed 0u8 and ignored it. Callers can capture state
via move closures instead.

* fix: feature gating for error conversions and dead deps (#95)

- Add internal _serde_json and _reqwest features to gate From impls
- Remove unused json and byteorder optional dependencies
- Add missing xpc dependency to remote_pairing feature
- Simplify map_err workarounds in tunnel code to use ? directly

* fix: make openssl PairingFile escrow_bag field Optional (#97)

The openssl variant of PairingFile had escrow_bag as Vec<u8> while
RawPairingFile has it as Option<Data> (it's None on Apple Watch).
This caused compile errors in the From/TryFrom impls when building
with the openssl feature. The rustls variant already had the correct
Option<Vec<u8>> type.

* fix: improve openssl crypto backend (#98)

* fix: make openssl crypto path a first-class backend

Un-gate `ca.rs` and `pair()` from rustls — they only use pure Rust
crates (rsa, x509-cert, sha2) so pairing now works with openssl.
Always detect legacy devices instead of only with openssl feature.
Add openssl feature to FFI crate. Clean up SNI string and gate
rustls-only PEM helpers to fix dead code warnings.

* refactor: return legacy flag from start_session, remove duplicate detection

`LockdownClient::start_session` already queries ProductVersion to
detect legacy devices. Four callers were making the same query
beforehand. Now `start_session` returns the legacy bool so callers
reuse it instead of round-tripping to the device twice.

* Remove rt-multi-thread dependency from AFC file descriptor drop (#93)

AFC's close-on-drop used block_in_place + block_on to synchronously send
a FileClose packet, requiring tokio's rt-multi-thread feature. This is
heavyweight for a best-effort cleanup that already did nothing on wasm
and single-threaded runtimes.

Replace with a simple no-op drop that warns (debug_assert + println) if
.close().await wasn't called. The device reclaims FDs when the AFC
session ends regardless. Also fix the afc tool to explicitly close file
descriptors after use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants