Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
libusbmuxd reads USBMUXD_SOCKET_ADDRESS so the idevice_* tools can drive a
device attached to another machine. dl_connect() does not go through
libusbmuxd -- the comment above it explains that usbmuxd_subscribe() is
threaded and does blocking reads, while this listener wants a select()-able
fd -- so it opens the usbmuxd socket itself, and in doing so it always used
the local Unix socket.
The result is a confusing split: on a host configured for a remote usbmuxd,
idevice_id -l lists the device while ios_webkit_debug_proxy reports
"No device found, is it plugged in?".
Read the variable in dl_connect(), mirroring libusbmuxd's
connect_usbmuxd_socket() so the two agree on what an address means:
- "UNIX:/path" connects to that Unix socket (exact case, as upstream).
- "host:port" connects over TCP; the port must be an entire, valid
number in 1..65535.
- A bracketed IPv6 literal such as "[::1]:27015" has its brackets
stripped before it reaches getaddrinfo(), which does not accept them.
- Anything unusable -- no port, a trailing colon, a non-numeric or
out-of-range port -- falls back to the local socket rather than
failing, again as upstream does.
Addresses are resolved with getaddrinfo()/AF_UNSPEC, so IPv6 remotes work.
A resolver failure now reports gai_strerror(); the Unix-socket path is
unchanged when the variable is unset.
Folkman
force-pushed
the
usbmuxd-socket-address
branch
from
September 20, 2026 02:02
cbbdf87 to
c24327e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
libusbmuxd reads
USBMUXD_SOCKET_ADDRESSso theidevice_*tools can drive a device attached to a different machine.dl_connect()doesn't go through libusbmuxd — the comment above it explains thatusbmuxd_subscribe()is threaded and does blocking reads while this listener wants aselect()-able fd — so it opens the usbmuxd socket itself, and always used the local Unix socket.On a host configured for a remote usbmuxd, that produces a confusing split:
Same machine, same library, same phone. This comes up whenever the device is attached to a Windows or macOS box and the proxy runs on a Linux host (or in a VM/container) reaching
usbmuxdover TCP.The change
dl_connect()now reads the variable, mirroring libusbmuxd'sconnect_usbmuxd_socket()so the two agree on what an address means:USBMUXD_SOCKET_ADDRESSUNIX:/pathhost:port[::1]:27015getaddrinfo()host:,host:abc,host:99999Deliberately matching libusbmuxd rather than being more permissive: a bare
hostwith no port does not default to 27015, and a malformed address falls back rather than failing, because that is what every other libimobiledevice tool does with the same string.UNIX:is matched case-sensitively for the same reason.On provenance: the behaviour is matched to libusbmuxd's
connect_usbmuxd_socket()(LGPL-2.1) so the two agree on what an address means, but the implementation here was written independently against this BSD-licensed file — no code was copied from it. The differences are visible in the approach: this version parses in place without allocating, and callsgetaddrinfo()directly rather than going through asocket_connect()helper.Addresses resolve through
getaddrinfo()withAF_UNSPEC, so IPv6 remotes work. A resolver failure now reportsgai_strerror()instead of a bare message.Testing
Built with the project's own
-Wall -Werror, no new warnings.Verified against a real device (iPhone SE, iOS 15.8.8) attached to a Windows host running usbmuxd, with the proxy on Linux:
<host>:27015— device found, proxy serves tabs on 9222.[::1]:27015— before this change,cannot resolve "[::1]:27015"; after, it reachesconnect()(Connection refused, nothing listening there), confirming the brackets are stripped.<host>/<host>:/<host>:abc/<host>:99999/UNIX:/var/run/usbmuxd/ lowercaseunix:.../ unset — all fall back to the local socket.Written with Claude Code.