Architecture & Failover
Connekt uses a star-topology Rust Hub (connekt-core / connekt-hub) that abstracts away transport mechanics and exposes one unified peer registry across USB and LAN.
Core Design Principles
Multi-App Safe per Physical Device
Every connected app identifies itself with a stable peer_id composed of its persistent device fingerprint and bundle/package identifier (<device_hash>/<app_package>). Multiple apps on the same Android or iOS device — and multiple browser tabs — connect side-by-side over the same physical link without port collisions or crosstalk.
Link Priority & Automatic Deduplication
Each peer can maintain multiple simultaneous transports inside PeerRegistry. The Hub ranks transports by deterministic priority:
| Transport | Priority | Mechanism |
|---|---|---|
adb | 100 | Android USB via adb reverse tcp:19527 |
usbmux | 100 | iOS USB via usbmuxd loopback listener |
lan | 50 | LAN WebSocket (/ws) discovered via UDP broadcast or Bonjour (_connekt._tcp) |
custom | 25 | User-supplied custom Transport adapter |
relay | 10 | Future authenticated WAN WebSocket relay |
When a device is reachable over both USB and LAN:
- Both connections merge under a single
peer_id(never duplicated as two peers). - Outbound traffic routes over the highest-priority active transport (
USB, priority100). - The
LANlink stays warm inHOT_STANDBYmode.
USB → Wi-Fi Hot-Standby Failover
- While tethered, messages, RPCs, and binary streams travel over USB (
ADB reverse/usbmuxd). - The moment the USB cable is unplugged,
PeerRegistryremoves the dead USB link and immediately promotes the standbyLANWebSocket toactive_transport. - When the cable is plugged back in, USB reconnects automatically and reclaims priority
100seamlessly.
iOS Privacy-First LAN Default
Both Android and iOS keep enableLan = false by default. This guarantees that pure USB debugging sessions on iOS never trigger Apple's "Local Network" permission prompt unless your app explicitly opts into wireless failover (enableLan = true).
Zero-Copy Routing & Stream Multiplexing
- Multicast fan-out: Sending to
[peerA, peerB]or"*"wraps the payload once inbytes::Bytes(reference-counted) and fans out across target queues with zero buffer copies. - 0-RTT Binary Streams:
STREAM_OPENcarries optional JSON metadata (meta), while everySTREAM_DATAchunk carries zero JSON overhead (only the fixed 19-byte CK v1 binary header + raw chunk bytes). - Early Reject & Cancel: Receivers inspect
stream.metaimmediately ononStreamand can callreject(reason)before reading a single byte, tearing down the stream on the sender cleanly.
See Wire Protocol (CK v1) for exact binary framing details.