Commit Graph

22 Commits

Author SHA1 Message Date
rustdesk 0a36139a58 fix(webrtc): reject malformed fragment framing, correct receive-path docs
`next()` read every non-FRAG_END header as "more fragments", so a peer whose
framing had diverged was only caught by the MAX_FRAME_LENGTH cap — and a
FRAG_MORE carrying no payload was never caught at all: it adds nothing to the
accumulator, so the cap never trips and the loop spins for as long as the peer
keeps writing, with no error and no teardown. Decide the header's meaning in one
match, so a future header kind cannot be handled in one place and missed in the
other. Neither case is reachable from send_bytes_inner, which emits FRAG_MORE
only for a full MAX_FRAGMENT_PAYLOAD chunk.

Release the accumulator on the error paths rather than truncating it: at the cap
that is ~1 GiB still referenced through the SESSIONS clone.

Doc corrections, all of them overclaims in the previous pass:

- the cancel-safety entry held only for the successful read path.
  read_data_channel does await after dequeuing on its ErrShortBuffer and DCEP
  branches, and next() awaits pc.close() on its error paths — where
  RTCPeerConnection::close latches is_closed before its first await, so a
  cancelled close silently turns every later close into a no-op and leaves the
  pc in SESSIONS.
- recv_state: cancellation drops the guard mid-message, so it is the
  single-reader assumption, not the mutex, that ultimately keeps two readers
  from splicing into one accumulator.
- is_relayed: stream.rs promised None before pair selection while webrtc.rs
  documented Some(true) under Relay policy; align both.
- get_local_endpoint: examples/webrtc.rs calls it too, not only the tests.
- PunchHole.reserved 11: named the wrong writer — PunchHole is written by the
  rendezvous server, not by peers. Reserve the name as well as the tag.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 13:21:01 +08:00
rustdesk 6aa8fbe46b docs: webrtc 0.13 MSRV pin rationale and upgrade checklist
- Cargo.toml: record why webrtc is pinned to 0.13 — >=0.14 pulls sdp 0.10 /
  webrtc-util 0.12 using usize::is_multiple_of (needs rustc >=1.87), while
  rustdesk CI builds with Rust 1.75 (sciter i128 ABI pin)
- module-level upgrade checklist in src/webrtc.rs listing the version-coupled
  webrtc-rs internals this transport relies on (SCTP write backpressure,
  64KB message cap, detach() semantics, handler-capture leak cycle,
  Disconnected transience, stats-based is_relayed), all verified against
  webrtc 0.13 / webrtc-data 0.11 / webrtc-sctp 0.12
- send_bytes: document the bounded-backpressure mechanism (128 KiB PendingQueue
  semaphore + cwnd/rwnd cap) and that it is NOT cancel-safe

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 13:21:01 +08:00
rustdesk 0952f18b8e fix: preserve WebRTC endpoint and send semantics 2026-08-22 13:21:01 +08:00
rustdesk f98f3e8732 feat: WebRTC data-plane framing, DTLS binding, and pc-leak fixes
- 1-byte-header fragmentation past the 64KB SCTP cap; empty-message and clean-EOF handling
- is_relayed() via selected candidate-pair stats for the direct/relayed flag
- IdPk.dtls_fingerprint + rendezvous webrtc SDP/IceCandidate proto fields
- fix pc leaks: Weak capture breaks the state-handler Arc self-cycle; close pc on new() error paths

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-22 13:21:01 +08:00
rustdesk 9277af2452 feat: support trickle ICE in WebRTCStream 2026-08-22 13:21:01 +08:00
lc e4224a19bc Apply suggestions from code review 2025-11-17 15:19:20 +08:00
lichon 2dc15df250 Update src/webrtc.rs
webrtc session clean fallback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-17 14:55:52 +08:00
lc 3282977e66 Apply suggestions from code review 2025-11-17 13:18:27 +08:00
lc 7cb29b1117 add ice-servers config 2025-11-16 18:43:31 +08:00
lc 0da5d379fc support turn relay config, and force_relay option 2025-11-16 04:04:25 +08:00
lichon 483cf9d225 Apply suggestions from code review 2025-11-15 16:37:34 +08:00
lichon b10a96b7bc Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-15 16:04:59 +08:00
lc 3a919aef54 minor change 2025-11-15 00:27:09 +08:00
lc 955e49dc4b use webrtc sdp fingerprint as session key 2025-11-14 20:32:49 +08:00
lc 5dcfea1ee4 support send_timeout 2025-11-14 16:03:02 +08:00
RustDesk 47dc73de1e Update src/webrtc.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-14 11:46:59 +08:00
lc 67ad83a2b2 fix webrtc example when webrtc disabled 2025-11-13 23:25:53 +08:00
lc f9e70f3d46 remove typo 2025-11-13 23:11:33 +08:00
lc f5f78c84d5 remove unwraps 2025-11-13 23:07:01 +08:00
lc 4cea3a7769 better example support local dc stream
fix read/write issue
clear sessions after close
2025-11-13 20:59:32 +08:00
lc 8ae4651bc7 make webrtc-rs optional feature 2025-11-13 16:53:07 +08:00
lc 442160d704 add webrtc stream 2025-11-12 19:46:55 +08:00