Skip to content

Add a Wi-Fi transport with PIN pairing over QUIC - #3

Merged
FacuM merged 15 commits into
mainfrom
wifi-transport
Oct 26, 2026
Merged

FacuM merged 15 commits into
mainfrom
wifi-transport

Conversation

@FacuM

@FacuM FacuM commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a Wi-Fi transport between the Android app and the host. It uses QUIC (quinn + rustls) on UDP 27183, is off by default, and pairs devices with a one-time PIN over SPAKE2. The USB/adb path is unchanged, and the Android app falls back to the paired host over Wi-Fi automatically.

Changes

  • Transport
    • QUIC (quinn + rustls) on UDP 27183. Off by default; enabled with run --wifi or the tray toggle.
    • One QUIC stream per channel. Control is bidirectional. Input, cursor and video are tagged unidirectional streams with send priorities Control > Input > Cursor > Video. A tag is reserved for audio.
    • Input is therefore never queued behind a video burst.
    • TCP over adb reverse is unchanged.
  • Pairing and security
    • Persistent self-signed identities on both sides.
    • Pairing uses a one-time 6-digit PIN (2 min, 5 attempts) through SPAKE2, with an HMAC confirmation bound to the TLS exporter and to both certificate fingerprints. This blocks MITM attacks and offline guessing of the PIN.
    • Sessions use mutual TLS pinned to the paired fingerprints.
    • The listener does a stateless retry for unvalidated source addresses.
    • Forgetting a device (CLI, tray or editing the file) ends its live session within about 2 s.
    • Pairing links and QR codes are limited to local-network addresses.
    • When a host has forgotten the tablet, the tablet drops the host and stops retrying it, showing a localized notice.
  • Discovery: mDNS _ezdisplay._udp with the name and a fingerprint prefix. The address can also be typed by hand.
  • Host and tray
    • ezd-host run --wifi [--pair] shows the PIN and QR code.
    • ezd-host paired list|forget.
    • Tray Wi-Fi card: toggle, pair (PIN + QR), paired list with Forget.
  • Android
    • Connection section in Settings: discovered hosts, PIN pairing, QR deep link with an address/PIN confirmation, paired hosts, and a latency warning.
    • The app falls back from USB to the paired host over Wi-Fi automatically, rotating away from addresses that failed recently.
  • Firewall
    • The Windows installer adds private-profile inbound rules for UDP 27183 and removes them on uninstall.
    • On Linux, a ufw application profile and a firewalld service are installed by the Arch and .deb packages. Nothing is opened automatically.
    • The README has the commands. ezd-host diag reports a firewall section, and run --wifi prints a hint when a firewall is active.
  • Docs: README Wi-Fi section, docs/protocol.md Security/Pairing, Windows testing checklist.

Scope notes

  • Windows checks (installer firewall rules, Wi-Fi from the Nitro) are not yet verified. They are covered by the manual checklist in docs/windows-testing.md.
  • Known limitations:
    • A revoked session ends with the generic "host shutting down" reason, not a dedicated one.
    • The paired-devices file has no OS-level lock, because the MSRV of 1.85 predates File::lock.

Verification

  • Host: cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, and cargo test --workspace (646 passed).
  • Android: ./gradlew assembleFullDebug assemblePlayDebug lintFullDebug testFullDebugUnitTest all pass.
  • Real device (foldable Android phone against the KDE Linux host over Wi-Fi):
    • mDNS discovery and PIN pairing work.
    • The automatic USB→Wi-Fi fallback streams at transfer p50 ~5 ms and end-to-end p50 ~25–40 ms, with 0 dropped frames.
    • It reconnects without a PIN after a host restart.
    • Input arrives on its own stream.
    • Forgetting the device on the PC ends the live session at once. The phone then drops the host, stops retrying Wi-Fi and shows the localized notice.

FacuM added 12 commits October 25, 2026 16:51
Add a QUIC transport (quinn with rustls/ring, TLS 1.3) where both
peers use self-signed certificates pinned by SHA-256 fingerprint.
Control and video run on separate streams through a split mux, so
video loss never delays input or cursor updates.

Pairing uses SPAKE2 with a PIN, followed by HMAC key confirmation
bound to the TLS exporter and both certificate fingerprints. A
pairing window allows 5 attempts within 5 minutes and is guarded by
a generation check. A QR URI carries the pairing data. The host
limits what unauthenticated peers can do.

Protocol minor version is bumped to 0.5. The `quic` feature is off
in the workspace dependency so the Windows MSVC cross-check builds
without ring. CI gives ring the NDK clang for the Android check.
Add `ezd-host run --wifi [ADDR]` to accept tablets over the QUIC
link, and `--pair` to open a pairing window. Pairing shows a QR code
and a PIN in the terminal. `ezd-host paired list` and
`ezd-host paired forget` manage the paired tablets, which are stored
in the config directory. The host advertises itself over mDNS as
`_ezdisplay._udp`.

Only one session runs at a time across USB and Wi-Fi. Pairing events
are reported through the live status.

The fake client gains `--wifi`, `--pin`, `--uri` and `--state-dir`
for testing the Wi-Fi path. Its strings are added in all six
locales. The `wifi` feature is on by default.
The Connection page gets a Wi-Fi card: a switch (which restarts the
service, as the listener is read at start), a latency warning, the host
address and short fingerprint, a Pair a device button that opens the
pairing window and shows the PIN, a QR code and the time left, and the
paired devices with Forget. HostService gains paired_devices and
forget_paired. The Windows installer opens UDP 27183 on the private
profile for ezdisplay.exe and ezd-host.exe and removes the rules on
uninstall.
Move pairing, the paired-host store and the connect-with-retry loop into ezd-client-core, keep the fake client as a thin wrapper, and add the startWifi, wifiPair, wifiHosts, wifiForget and wifiIdentity entry points to ezd-android.
Discover hosts with NsdManager, pair by PIN or ezd://pair link, fall back from USB to a paired host, and add a Connection settings section for all layouts, localized in six languages.
A Wi-Fi session now uses one stream per channel: control (bidirectional), input (client), cursor and video (host), so loss on one channel never delays another. Unidirectional streams start with a tag byte and are dispatched by tag. The mux gains per-channel lanes (spawn_mux_lanes, MuxReceiver::new_lanes); a channel without a lane stays on the control stream in priority order. Send priorities: control 4, input 3, cursor 2, audio 1 (reserved), video 0.
Forgetting a device ends its streaming session at once, and a session re-checks the store every 2 s so a forget from another process also ends it. Unvalidated UDP sources get a stateless retry before taking a connection slot. Forget by fingerprint never matches names, and an exact fingerprint wins over a name in the CLI lookup.
…he local network

Links now show the host address and the PIN and are refused unless the address is on the local network (checked in Kotlin and in the native pairing). Typed public addresses get a warning. Names lose bidi and format characters. A failing discovered address is skipped for 60 s so a spoofed announcement cannot block the connection.
Add a ufw application profile and a firewalld service for UDP 27183, installed by the Arch package and the .deb (nothing is opened automatically), document the commands, and report the firewall state in diag and in a localized hint when Wi-Fi starts.
When the pinned host refuses with NotPaired, the client removes it from its paired hosts instead of retrying. Android gets a stable failure code next to the English detail, shows the localized reason and keeps it above the USB retry messages until a host is paired again.
FacuM added 3 commits October 25, 2026 22:18
# Conflicts:
#	android/app/src/main/kotlin/com/librestatic/ezdisplay/MainActivity.kt
#	crates/ezd-android/src/bridge.rs
#	crates/ezd-host-service/src/config.rs
#	docs/protocol.md
@FacuM
FacuM merged commit 21d5e40 into main Oct 26, 2026
10 checks passed
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.

1 participant