Repository navigation
Move usbmux framing and the WebSocket protocol into webmuxd - #3
Merged
Merged
Conversation
Port the host side of usbmuxd to TypeScript: version negotiation, the setup packet, sequence numbers, packet reassembly across USB transfers, control frames, and the minimal TCP usbmux expects (SYN/SYN-ACK/ACK, prompt ACKs, device window flow control, RST on close). MobileDevice gains startMux() and a continuous read loop, sends zero length packets when a write fills whole USB packets, and surfaces open errors. Move RemoteChannel and transport.proto from webmuxd-example. Raw mode stays wire compatible with go-webmuxd and now forwards only complete mux packets; a new mux mode runs usbmux in the browser and relays channel bytes. Upgrade the toolchain (TypeScript 5, Jest 29, ESLint 8) so build, lint and tests run again, add tests and a CI workflow. Closes #1, closes #2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX5EpsMSD7hjw6UNJCo3eg
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.
Requested by Rick · project thread
Before:
webmuxdonly claimed the USB interface and polled the bulk endpoint, so every usbmux packet and TCP ACK made a round trip togo-webmuxd.RemoteChannelandtransport.protolived inwebmuxd-example.yarn build,yarn lintandyarn testall failed on a current Node, and nothing ran CI on pull requests.After: the package speaks usbmux in the browser (
device.startMux()thenmux.connect(62078)), shipsRemoteChanneland the protobuf protocol, and build, lint, typecheck and 43 tests pass in a new CI workflow. This finishes the two roadmap items that belong to this repo, and closes #1 and #2.How:
src/usbmux/is a TypeScript port of the host side of usbmuxd'sdevice.c. It handles version negotiation (v1 and v2), the setup packet, sequence numbers, magic checks and control frames, and reassembles packets that are split across or packed into USB transfers.TcpChanneldoes SYN / SYN-ACK / ACK, ACKs device data straight away, keeps writes inside the device's advertised window, chunks large writes, and closes with RST the way usbmuxd does. go-webmuxd's version was missing the final ACK of the handshake.MobileDevicenow reads in a continuous loop instead of a 1 s interval and clears stalls. It sends a zero length packet when a write fills a whole number of USB packets, andopen()throws instead of swallowing errors. It no longer toucheswindow, so it can be tested in Node.RemoteChannelandtransport.protomoved in fromwebmuxd-example. The URL, reopen flag and WebSocket factory are options. The oldnew RemoteChannel(true)call still works.rawmode (the default) keeps the existing wire format. I checked it against go-webmuxd's generated Go code. The browser now forwards only complete mux packets (Revise the protobuf API to send complete messages #2).muxmode addsOpenChannel,ChannelData,CloseChannelandChannelStateChangedmessages, so framing and ACKs stay in the browser. go-webmuxd will need changes before it can use this mode.@bufbuild/protobuf. Repository URLs now point to hack-different. The release workflow usednpm ciwith only ayarn.lockin the repo, so I switched it to yarn. Version bumped to 0.9.0.Still open, in other repos:
muxmode in go-webmuxd, switching webmuxd-example to depend on this package, andwebmuxd-ui.Not yet tested on a real iPhone. All tests run against a fake device that follows usbmuxd's behaviour.
Generated by Claude Code