Commit Graph
482 Commits
Author SHA1 Message Date
fufesou 3ee3afd438 Serialize peer deletion with credential writes
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-26 15:22:00 +08:00
fufesou f15eb3d40d Merge branch 'main' into fix/trusted-device-v2 2026-10-25 18:07:47 +08:00
RustDesk edefa08b79 Merge pull request #626 from rustdesk/custom-websocket-port
feat(websocket): add websocket-port for a proxy off the default port
2026-10-22 17:52:30 +08:00
rustdeskandClaude Opus 5.5 dfb9d0d1c6 fix(websocket): match websocket-port only against configured servers
websocket_port() took the rendezvous host from get_rendezvous_server(),
which falls back to a cached or public server when none is set. With
only relay-server and websocket-port set, the public rendezvous server
also got the port, and registration failed. Match the servers this
client is set up with instead: the exe-name host, custom-rendezvous-server,
the build-time server, and relay-server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:28:28 +08:00
rustdeskandClaude Opus 5.5 b3bf7b76e2 fix(websocket): throttle the invalid websocket-port warning
check_ws runs on every rendezvous reconnect, online query and relay
connect, so an invalid websocket-port logged a warning each time.
Keep one line a minute with a count of the rest. Also import the key
with the other config keys instead of in the function body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:04:26 +08:00
fufesou cef0aedf40 Keep trusted-device credentials in configuration sync snapshots
Refresh cached trust fields after successful credential writes and provide explicit persisted credential synchronization. Ordinary settings saves continue to preserve the destination credentials.

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-22 16:25:27 +08:00
rustdeskandClaude Opus 5.5 34846eef9f feat(websocket): add websocket-port for a proxy off the default port
check_ws turns a domain endpoint into ws(s)://<domain>/ws/id or
/ws/relay with no port, so a reverse proxy that cannot take 443 (or 80)
is unreachable, even when api-server already points at it, for example
https://example.com:8443.

websocket-port adds that port for the hosts this client is configured
with: custom-rendezvous-server and relay-server. A relay that hbbs hands
out on another host, or a peer's server, keeps the default port, since
another machine has its own proxy. IP endpoints are unchanged, and an
empty option gives the same URL as before.

https://github.com/rustdesk/rustdesk-server-pro/discussions/1029

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 16:05:24 +08:00
fufesou 41d50c4052 Remove unused trusted-device import stripping helper
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-21 23:07:40 +08:00
fufesou 77f924d7a3 fix: support atomic legacy trusted-device migration
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-20 23:24:04 +08:00
RustDesk ed07431021 Merge pull request #620 from 21pages/suppress_log
fix: reduce noisy smithay client toolkit logs
2026-10-20 16:50:15 +08:00
fufesou 040bf3f662 refactor: remove unused legacy trusted-device detector
The V2 management UI no longer displays legacy enrollment metadata. Remove the unused presence helper while preserving legacy records during ordinary saves.

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-20 16:11:45 +08:00
fufesou e2b17fd06c fix: recover config saves while preserving valid legacy trust
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-19 01:21:02 -07:00
fufesou e4f0e8fa9b Merge branch 'main' into fix/trusted-device-v2 2026-10-18 20:45:59 -07:00
fufesou 2289227c5f fix: preserve legacy trust data and validate V2 storage
Retain legacy trusted-device records for migration without using them for authentication. Preserve malformed V2 values for strict validation while allowing explicit revocation to replace them.

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-16 05:21:07 -07:00
21pages 20d5019a42 fix: reduce noisy smithay client toolkit logs 2026-10-16 17:35:46 +08:00
RustDesk 5d52530b63 Merge pull request #609 from AzimovIz/remoteUSB
Add REMOTE_USB connection type
2026-10-14 20:51:07 +08:00
RustDesk a63c5b2301 Merge pull request #600 from 21pages/websocket-proxy
websocket proxy support
2026-10-14 20:50:15 +08:00
21pages 423fb71085 fix: return local address for direct WebSocket connections 2026-10-14 20:04:48 +08:00
fufesou dcc0381b7b fix: preserve trusted credentials when configuration reads fail
Stop ordinary Config2 and peer settings saves when the current file cannot be read. Keep first-save behavior for missing files and log failures without replacing V2 records with defaults.

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-14 02:21:27 -07:00
fufesou c11a5971a3 fix: minimize trusted-device configuration save changes
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-13 18:48:53 -07:00
fufesou 8791bf0d33 fix: simplify trusted-device configuration storage
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-13 18:18:38 -07:00
21pages 0ccaaf2cf6 fix: parse IPv6 HTTP proxy authorities correctly 2026-10-13 18:58:42 +08:00
fufesou a2df328d0b fix: preserve trusted-device grants in Config2
Add fallible grant persistence with file locking and atomic replacement. Preserve the persisted grant state during ordinary settings writes so stale configuration snapshots cannot restore revoked devices.

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-12 21:59:19 -07:00
21pages 2d998e7b02 fix: reuse the initial TCP connection for HTTPS proxies 2026-10-13 11:51:29 +08:00
21pages 4c04a7a130 fix: allow proxy reads while flushing is pending 2026-10-13 11:51:29 +08:00
21pages 19b8b2242d fix: always use configured proxy for WebSocket 2026-10-12 18:58:03 +08:00
21pages 9ee2f3ef9a fix: bracket IPv6 targets in HTTP CONNECT requests 2026-10-10 19:45:51 +08:00
21pages 3aade011c0 feat: add opt-in WebSocket proxy support
Support WS and WSS over SOCKS5, HTTP, and HTTPS proxies, including custom
ports. Use the configured proxy only when allow-websocket-proxy is enabled;
explicit proxy configuration takes precedence. Propagate proxy failures
without retrying a direct connection.

Add regression coverage for proxy routing, authentication, TLS, custom
ports, direct defaults, and failure handling.

Signed-off-by: 21pages <sunboeasy@gmail.com>

fix: flush WebSocket proxy tunnels before native TLS reads

Flush buffered HTTP and HTTPS tunnel writes before NativeTls reads so WSS handshakes can complete on macOS. Apply the adapter only to NativeTls WebSocket connections through HTTP or HTTPS proxies.

Extend the existing proxy round-trip test with HTTPS and SOCKS5 NativeTls cases. The websocket_proxy integration test passes in the rustdesk workspace.

Signed-off-by: 21pages <sunboeasy@gmail.com>

refactor: simplify WebSocket proxy configuration

Select the configured proxy inside WsFramedStream::new based on the WebSocket proxy option and remove the explicit proxy argument. Update the socket client and drop the unused Stream::connect_websocket wrapper.

Adapt integration tests to configured proxies and cover custom target ports and WebSocket close handling.
2026-10-10 11:50:09 +08:00
AzimovIzandClaude Opus 5.5 b4be9744bf Drop the REMOTE_USB connection type
USB forwarding now runs inside a normal remote desktop session
(rustdesk/rustdesk#16278), so it needs no connection type of its own. Only
ControlPermissions.Permission.usb remains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: AzimovIz <sergo.p.987@gmail.com>
2026-10-09 13:44:15 +00:00
AzimovIzandClaude Opus 5.5 bee7c2458c Add REMOTE_USB connection type and usb control permission
Adds ConnType::REMOTE_USB for the RemoteUsb feature (rustdesk/rustdesk#16278),
following the same pattern as TERMINAL, and ControlPermissions.Permission.usb
so USB forwarding can be controlled centrally like the other permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: AzimovIz <sergo.p.987@gmail.com>
2026-09-26 13:12:59 +00:00
rustdeskandClaude Opus 5.5 94ec710894 Build the webrtc feature standalone against the rustdesk-org fork
src/webrtc.rs calls fork-only APIs (set_ice_max_binding_requests,
set_no_congestion_control), which only rustdesk's root [patch] supplied,
so building this crate on its own with --features webrtc failed with
E0425/E0599. Mirror the root patch here; it applies only when this crate
is the root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-25 16:30:59 +08:00
RustDesk 229b904508 Merge pull request #614 from rustdesk/kx-v2
Kx v2
2026-09-23 14:48:27 +08:00
rustdeskandClaude Fable 5.1 42c77b9a3b tcp: pin the subkeys for an advertisement above the pick
With advertised and picked both 1, swapping their order in the
derivation leaves the vector unchanged. Advertised 3 with picked 1 is
what a client meets at a newer server, and tells the two apart.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-23 14:27:51 +08:00
rustdeskandClaude Opus 5.5 2849258460 tcp: pin the version 0 frame and the version 1 subkeys
The existing tests run both ends on the same code, so they pass even
if the derivation changes. Fixed bytes catch that: the version 0 frame
released peers send, and the same subkey vector hbbs's copy of this
code pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-23 13:20:36 +08:00
rustdeskandClaude Opus 5.5 cee8cf3dc3 stream: refuse a key exchange version set_negotiated_key does not know
Version 1 is matched explicitly and any other picked version is an
error, so adding a version without its arm here fails instead of
running as version 1. WebRTC takes only version 0, as both handshakes
already require.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-23 13:20:36 +08:00
rustdeskandClaude Opus 5.5 cbc8772d4a stream: set_negotiated_key, one place that maps the picked version to a key
Every handshake picked a version and then repeated the same choice: at
least 1 splits the key, 0 sets it as before. Stream now makes that choice
from the transcript it is already given, so callers make one call and a
later version is handled here rather than at each of them. Version 0
still goes through set_key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-23 09:53:34 +08:00
rustdeskandClaude Fable 5.1 26582e163d tcp: KX_PARAMS_DOMAIN, the prefix under which KxParams is signed
The server signs its ephemeral key, IdPk records and KxParams with one
key, and a protobuf carries no type of its own: a signed IdPk parses as
a KxParams whose pk is the id and whose version is 0. The prefix keeps
the three apart; the client requires it before parsing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-22 17:59:11 +08:00
rustdeskandClaude Fable 5.1 e74a188f4f KeyExchange: sign KxParams, a structure, in place of a fixed byte string
The server's second signature covered "rdkx-ver" || key || version, a
layout that could take nothing more. It now covers KxParams, a message
holding the key as it went out and the advertised version, so anything
the server needs signed later is a field added to it, and a client that
does not know a field parses past it, as with IdPk on the peer side.
Field 3 keeps its number under the name signed_params.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-22 17:43:38 +08:00
rustdeskandClaude Fable 5.1 5194159858 kx: drop the advertisement echo
signed_version settles the server's version inside the key exchange, so
an echo of it on the messages after has nothing left to confirm. With it
go RendezvousMessage.kx_advertised, the check the transport ran on each
decrypted frame, and the tests of both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-22 17:22:01 +08:00
rustdeskandClaude Fable 5.1 e3452acf59 kx: comments say what the fields and functions are
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-22 15:02:44 +08:00
rustdeskandClaude Fable 5.1 d9f519e915 KeyExchange: signed_version, the server's signature over its version
The echo catches an advertisement lowered in the clear only once a tagged
frame arrives, so the initiator's first frame has already gone out under
the lower version by then. A server that signs its version instead sets
bit 255 of the ephemeral X25519 key inside the signed keys[0] and puts
sign("rdkx-ver" || key || version LE) here. RFC 7748 masks that bit, so
the box opens as before on either side, and a legacy server, whose keys
are canonical, never sets it. A client that sees the bit, or the field,
verifies before trusting the version, so the pair settles it at the
handshake rather than one frame pair later.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-22 13:18:45 +08:00
rustdeskandClaude Fable 5.1 1266b56150 kx_advertised: every message after the exchange, not the first alone
The contract named the server's first message after the key exchange. That
frame sits at a position an attacker needs no key to find, so one who had
lowered the advertisement in the clear only had to drop it to be rid of
the check for the whole session. With every message carrying the echo,
being rid of it means dropping them all, which is a plain DoS.

The client already kept the check armed until an echo arrived; this is the
wording the server side is written to.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
2026-09-21 18:33:33 +08:00
rustdeskandClaude Opus 5 445486ccaa tcp: drop box_pk_of until something calls it
It has no caller here or in the servers; the responder that would keep
only the secret half does not exist yet, so it belongs to that change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
2026-09-21 18:33:33 +08:00
rustdeskandClaude Opus 5 955621899e tcp: keep the advertisement check armed until an echo arrives
The check was spent on the first frame that decrypted, whatever it held.
A server tags the messages it chooses to, and a frame carrying no echo
reads as `echoed == 0`, which passes; on the way out it also disarmed the
check for good, so an attacker who rewrote the advertised version only had
to let one untagged frame through to be rid of the only thing that would
have caught it.

A zero now says nothing either way and leaves the check standing. Only a
non-zero echo settles the question, matching or refusing the stream.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
2026-09-21 18:33:33 +08:00
rustdeskandClaude Fable 5.1 e272fede36 tcp: key exchange version 1, one stream key per direction
Version 1 of the key exchange splits the exchanged key into a subkey per
direction, the way Noise splits its cipher states after the handshake, and
leaves the nonce layout and the handshake messages as they are. Each subkey
is a keyed BLAKE2b over the handshake transcript: both ephemeral public keys,
the version the responder advertised and the one the initiator picked, so a
change to any of it in transit leaves the two sides with different keys. The
original scheme is version 0, which is also what an absent field means.

Negotiated through new fields old peers do not see: the side that speaks
first advertises the newest version it has (`KeyExchange.version` from the
server, `IdPk.kx_version` inside the signed identity from the controlled
side), the other side answers with the highest both have, and the pair runs
that. Any old peer on either end keeps today's stream byte for byte. The
controlled side's advertisement sits inside the signature; the server's is
repeated in `RendezvousMessage.kx_advertised` on its first message after the
exchange, inside the encrypted channel, and a client that was shown a
different value in the clear refuses the stream.

`Encrypt::new` is unchanged; `new_split`, `set_key_split` and
`check_kx_advertised` are added beside it, and `box_pk_of` for a responder
that kept only the secret half of its ephemeral pair. The tests pin the
version 0 output as well as the split and the echo.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-21 18:33:33 +08:00
rustdeskandClaude Fable 5.1 d9895ff9cb websocket: tungstenite 0.29 from rustdesk-org, read buffer grown as bytes arrive
Upstream reserves a frame's whole declared length the moment its header
is in, bounded only by max_frame_size, so a header alone buys the
allocation it names: 128 KiB before a session is authorized and 16 MiB
after. The rustdesk-org tungstenite-rs fork on rustdesk-patches-0.29,
upstream v0.29.0, grows the read buffer one read_buffer_size chunk at a
time as the bytes actually arrive instead, and tokio-tungstenite moves to
its rustdesk-patches-0.29 branch to match, still one commit for
set_config. 0.27's read chunking comes with the move, so a large frame no
longer clears its whole grown buffer on every read.

No source change: Bytes payloads and the non-exhaustive config arrived in
0.26 and 0.25 and were already in use here, and 0.28's boxing of
Error::Http derefs at its one use. The read buffer keeps tungstenite's
128 KiB default, this side reading video frames and file blocks over a
handful of connections rather than small messages over thousands. The
workspace root patches tungstenite to the fork, where cargo reads
[patch], so this crate's copy and tokio-tungstenite's resolve to one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
2026-09-21 17:58:32 +08:00
RustDesk 7dc56d69e0 Merge pull request #611 from fufesou/fix/websocket-check-encrypt
fix(websocket): reject text frames after encryption is enabled
2026-09-20 18:12:20 +08:00
fufesou 1f47a8ec92 fix(websocket): reject text frames after encryption is enabled
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-09-20 17:51:49 +08:00
rustdeskandClaude Fable 5.1 7a5ad5252e socket_client: only the controller's NAT test takes the resolver's address
`new_direct_udp_for` is back on `test_target`. The punch reply the
controlled side sends with it goes to the address it picks, and that reply
lost is a device online and unreachable - so it keeps the handshake that
proves the address, as the registration does. The controller's NAT test,
once per connection, is what could not afford the proof, a round trip
right before the connection it then opens to the same host; it alone takes
the resolver's preferred address, as `new_direct_udp_for_unverified`, and
a wrong one there costs that connection its UDP punch and nothing more.

That lookup is the first on the controller's connection path and the one
not under CONNECT_TIMEOUT, so it gets a second: a resolver that hangs
would otherwise hold the connection for its whole retry schedule before
`connect_tcp` even starts, and what a slower lookup loses is, again, only
the NAT test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-19 00:18:16 +08:00
rustdeskandClaude Fable 5.1 0bc83361d6 socket_client: the rendezvous registration keeps its proven address
f688d41 replaced the TCP handshake in `test_target` with the resolver's
first answer for every caller. The two are the same when an IPv6 route is
missing, or leads to nothing: a v6-only host gets the synthesized address
first either way, and the handshake sat out its second on a black hole and
fell back to that same first answer. They differ when the server refuses
IPv6 outright - an AAAA published for a daemon bound to 0.0.0.0, a firewall
that rejects - where the handshake failed fast and moved on to the A
record, and the resolver's order stays on the AAAA.

That matters on one path. `new_udp_for` and `rebind_udp_for` choose the
address the rendezvous registration lives on, and `start_udp` never leaves
UDP for TCP nor asks for a second candidate: a rebind after `MAX_FAILS2`
calls the same function and gets the same address. A self-hosted server
with such an AAAA would never see the controlled side register. Those two
keep the handshake, one round trip per server connection, under the old
name and its old behaviour. `new_direct_udp_for`, per connection and
against servers whose records are ours, takes the resolver's answer as
`resolve_target`: the round trip it was spared stays spared.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
2026-09-18 16:05:50 +08:00