191 Commits
Author SHA1 Message Date
RustDeskandClaude Opus 5.5 680b60395e fix(hbbr): match IPv4 clients against the relay lists in their IPv4 form (#748)
* Match IPv4 clients against the relay lists in their IPv4 form

hbbr listens dual-stack by default, so a direct IPv4 client reaches
relay() as ::ffff:a.b.c.d. relay() checked BLACKLIST and BLOCKLIST with
that form, while the lists hold the plain IPv4 that `ba` and `Ba` are
given. A blacklisted IPv4 client was therefore never throttled, and
adding it to the blocklist did not end its session. handle_connection
already normalizes with try_into_v4 for its accept-time check; relay()
now does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* Keep IPv4-mapped list entries matching in relay()

The previous commit looked the lists up in the plain IPv4 form only, so
an entry in the ::ffff:a.b.c.d form stopped matching. That is the form
`usage` and the pairing logs print, so an admin copying an address from
them, or an existing list file holding one, lost the throttle and the
mid-session blocklist check. relay() now matches either form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* Match either form of an IPv4-mapped client at accept too

handle_connection checked the blocklist in plain IPv4 form only, so an
entry in the ::ffff: form, the one usage prints, let the client connect.
If that client was the leg parked first, relay() never checks it and the
whole session ran. It now matches either form, as relay() does.

The relay() test gains a client that is not listed, which must outlive
the first list check, and a new test covers the accept check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* Require a timeout in the list tests' unlisted cases

An unlisted client passed if relay() or the connection ended with an
error, not only if it stayed up until the timeout. Each case now names
the one outcome it expects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:33:32 +08:00
RustDeskandClaude Opus 5.5 0415b0e057 Bound message sizes on hbbs and hbbr (#747)
hbbs drops a connection whose frame header announces more than
MAX_MESSAGE_KB (default 64, capped at 65536) on 21115, 21116 and the
websocket 21118, and gives each websocket 8 KiB buffers instead of
tungstenite's 128 KiB default.

hbbr bounds the relay request to 128 KiB until the two legs pair, then
lifts the bound on framed legs and restores tungstenite's defaults on
websocket legs. That needs set_config on an accepted stream, so
tokio-tungstenite and tungstenite now come from the rustdesk-org forks.


Claude-Session: https://claude.ai/code/session_01JAxkkh9Gd5dwGW8vL9JNV8

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:24:28 +08:00
RustDeskandClaude Opus 5.5 98ffcee829 Bound console reply writes with a deadline (#746)
Since #717 the console sends its reply with write_all, which waits until
every byte is sent. A local client that sends a command and then stops
reading would hold the task and its socket forever. Give the write the
same 1 s deadline as the read above it, and log a reply that fails or
runs late instead of dropping the error.


Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:07:52 +08:00
jahvari 36a0996ee8 fix: write complete administrative console responses (#717)
* fix: write complete administrative console responses

* Document changed function contracts
2026-11-07 12:52:17 +08:00
1bd3938cfe Bound stalled relay writes in both directions (#723)
* Bound stalled relay writes in both directions

* Document changed function contracts

* Clarify relay authentication documentation

---------

Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:47:28 +08:00
jahvariandRustDesk e5c0a4261d Preserve connection ports when applying forwarded WebSocket IPs (#725)
* Preserve connection ports when applying forwarded WebSocket IPs

* Document changed function contracts

* Update relay_server.rs

* Update IP address handling in rendezvous server

---------

Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
2026-11-07 12:44:26 +08:00
jahvari 474fbc7de4 Bound WebSocket upgrade handshake duration (#722)
* Bound WebSocket upgrade handshake duration

* Document changed function contracts
2026-11-07 12:43:08 +08:00
jahvari 134008e0e9 Fix relay waiter expiration after pair ID reuse (#721)
* Fix relay waiter expiration after pair ID reuse

* Keep waiter regressions separate from other relay tests

* Document changed function contracts

* Clarify relay authentication documentation
2026-11-07 12:07:52 +08:00
rustdeskandClaude Opus 5.5 08cd4428a7 Cover more relay UUID spellings in the validation test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkh9Gd5dwGW8vL9JNV8
2026-11-04 17:28:17 +08:00
rustdeskandClaude Opus 5.5 44de977af3 Validate relay UUIDs before forwarding
The peer sends the relay uuid to whatever relay_server names, so a uuid
carrying line breaks reaches that service verbatim. RequestRelay and
RelayResponse with a uuid that is empty, longer than 128 bytes, or outside
[A-Za-z0-9_-] now close the connection. The empty ack a peer sends for a
RequestRelay is still allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkh9Gd5dwGW8vL9JNV8
2026-11-04 17:28:10 +08:00
fufesou 873230e35a fix: key file perm (#705)
* fix: key file perm

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: enforce secure private key permissions on Unix

Create new keys with mode 0600 and verify permissions before writing.
Tighten existing keys to 0600 and propagate permission failures.
Preserve dangling symlinks and clean up failed key creation.

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: preserve read-only keys and prevent public key clobbering

Accept existing 0400 keys without changing their permissions.
Write the public key only after private key creation and writing succeed.

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: generate missing public keys and reject mismatched key pairs

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: publish public keys atomically without overwriting existing files

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: key file perms, comments

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: reject key conflicts and clean up failed private key writes

Reuse symlink resolution and simplify key loading and regression tests.

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: key file perm, simple refactor

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-10 17:34:18 +08:00
RustDeskandClaude Opus 5.5 5e37f45dfe Fix/punch reqs bound (#713)
* fix(hbbs): bound the punch-request record store

PUNCH_REQS grew without limit; its dedupe scan only covers the newest 30
entries, so cycling 31 online peer ids from one source appended a record
per request for the lifetime of the process. Keep at most 10,000 entries,
evicting the oldest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

* feat(hbbs): make the punch-request record cap configurable

MAX_PUNCH_REQUESTS sets how many records the punch-requests console
command keeps (default 10000); 0 disables recording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

* fix(hbbs): cap peer id length at 253 bytes

RegisterPk accepted ids up to a whole UDP datagram, so 31 registered
peers with ~64 KB ids still let the bounded punch-request store reach
hundreds of MB. Reject longer ids in RegisterPk and RegisterPeer, the
same bound the Pro server uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

* feat(hbbs): keep 100000 punch-request records by default

With peer ids capped at 253 bytes a full store is roughly 45 MB at
worst, so a larger default keeps more console history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

* test(hbbs): assert which punch-request records survive eviction

The length check alone passed if the newest record were evicted or new
records were dropped once full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

* test(hbbs): cover MAX_PUNCH_REQUESTS=0 in the punch-request test

At zero capacity the loop never ran and the new front/back asserts
unwrapped an empty queue. Make at least one request so the disabled
path is exercised, and only check eviction order when records are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 16:51:29 +08:00
rustdesk af7d7f0b02 fix bin 2026-07-25 11:42:45 +08:00
rustdesk 538aef71d1 bind interface and refactor doc 2026-07-24 10:56:56 +08:00
rustdesk 109d9a2351 fix more UDP reflection/amplification 2026-07-23 18:43:32 +08:00
rustdesk 70dcfdeb95 https://github.com/rustdesk/rustdesk-server/issues/634 2026-07-21 07:12:57 +08:00
Luc BusquinandClaude Opus 4.8 91fb928c6e Fix i32 overflow: peers offline 24.9-49.7 days wrongly reported online (#676)
`Duration::as_millis()` returns u128; casting it `as i32` in the
online-status and punch-hole checks keeps only the low 32 bits as a
signed integer. Once a peer has not registered for more than 2^31 ms
(~24.855 days), the value wraps negative and passes the
`elapsed < REG_TIMEOUT` test, so a long-offline peer is reported online
and connection attempts are relayed to its stale socket_addr. The
in-memory peer map is never evicted, so last_reg_time stays frozen until
hbbs restarts, making the false-online window 24.86-49.71 days (and it
repeats every ~49.71 days).

Widen REG_TIMEOUT and the two elapsed casts from i32 to i64 so the
comparison no longer overflows.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 10:14:03 +08:00
rustdesk 80d3a50566 https://github.com/rustdesk/rustdesk-server/issues/670 2026-07-01 12:17:57 +08:00
rustdesk 46e9ecd47d fix pr 2026-01-12 17:28:25 +08:00
rustdesk 5d1b4ba78a connection log query 2026-01-06 23:59:47 +08:00
rustdesk 4e8d6d08e2 fix https://github.com/rustdesk/rustdesk-server/issues/435 2025-11-03 13:03:19 +08:00
rustdesk 2c57e51ec5 higher default bandwidth 2025-06-22 15:03:13 +09:00
bato3 235a3c326c In cargo it is named "rustdesk-utils" (#551) 2025-04-29 20:40:55 +08:00
乐 621da3c8fe fix: 127.0.0.1 is not loopback (#515) 2025-02-06 20:25:10 +08:00
21pages 7a509f6975 replace libs/hbb_common with submodule (#502)
cargo update -p schannel to fix crash on higher rust toolchain, https://github.com/seanmonstar/reqwest/issues/2311

Signed-off-by: 21pages <sunboeasy@gmail.com>
2025-01-20 17:34:22 +08:00
Integral 772db7422f refactor: replace static with const for global constants (#494) 2024-12-07 17:54:53 +08:00
rustdesk 6f18a97644 v1.1.12 2024-10-07 16:21:36 +08:00
Fionera b37033d92c docs: the servers are by comma instead of colon (#462) 2024-09-28 23:34:47 +08:00
rustdesk e40994d62e remove useless KEY_FOR_API 2024-05-26 21:43:13 +08:00
rustdesk 5078a1f797 reuse port, and revert hbbr -k 2024-05-24 18:37:11 +08:00
rustdesk c4c26dd6d7 change -k to default _ 2024-05-24 17:57:37 +08:00
writegr 6e91f41a10 chore: fix some typos in comments (#404)
Signed-off-by: writegr <wellweek@outlook.com>
2024-04-18 14:39:10 +08:00
rustdesk 79f0eb497b trim private key 2024-01-31 11:30:42 +08:00
Paolo Asperti 94ae51458c fix Pk size check (#361)
* more descriptive error

* fix key size check
2024-01-31 11:21:00 +08:00
RustDesk 324dfd6a1f fix https://github.com/rustdesk/rustdesk-server/issues/306 2024-01-30 19:02:30 +08:00
RustDesk 70242e6eb2 Update common.rs 2024-01-30 18:29:04 +08:00
paspo cea8403dbc private key size check 2024-01-30 11:18:43 +01:00
rustdesk 1142cf105b Fix #324 to remove unsafe 2023-12-01 11:32:07 +08:00
rustdesk f1e941bf9f fix is_loopback 2023-06-16 15:13:23 +08:00
rustdesk 411502cd0b https://github.com/rustdesk/rustdesk-server/issues/260 2023-06-08 20:02:30 +08:00
rustdesk fd1c21b114 fmt 2023-06-08 14:11:37 +08:00
RustDesk d8e3cb9e65 Merge pull request #249 from nsgundy/FixNoDirectConnectionWhenBothPeersOnLan
Fix no direct connection when both peers on LAN
2023-06-08 13:53:09 +08:00
rustdesk 3a7904fa8e fix test_hbb and bump version 1.1.8 2023-06-08 13:42:34 +08:00
nsgundy 85a20769fb Consider peers to be on same intranet if is_lan() returns true for both 2023-05-19 15:21:59 +00:00
nsgundy aeeca0d7d1 Fix ip4 mapped ip6 addresses not considered to be part of network 2023-05-19 15:21:20 +00:00
rustdesk 675bf3c1f5 fix command line buffer and test addr 2023-03-16 00:53:58 +08:00
rustdesk ec202209f3 fix ID_EXISTS not sent out due to ipv6 change 2023-02-18 13:41:45 +08:00
rustdesk e2f4962ba8 clippy 2023-02-08 16:45:30 +08:00
rustdesk 7e307a5a1c CI 2023-02-08 16:00:12 +08:00
rustdesk d88e4b5151 make hbbr / hbbs share the PORT value of .env 2023-02-01 23:31:00 +08:00