Compare commits

..
18 Commits
Author SHA1 Message Date
rustdeskandClaude Fable 5.2 57d8b91f1d Update hbb_common: the datagram formats are pinned by a test
The submodule gains one test, which opens a recorded hello and welcome
and compares what is sealed after them with recorded bytes. Nothing
the client runs changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:09 +08:00
rustdeskandClaude Fable 5.2 3a8f62a68a Register in plaintext beside the probe once fallen back
Update hbb_common, where any answer on the session sets the proof
state. Every fourth round of a fallen-back socket went sealed only, so
a server without the seal never answered it: that registration came
3 s late and counted as a timeout. It now goes in plaintext with an
empty hello beside it, and a server that seals by now is still noticed
in that round. A rebind also sent every socket back to probing, so one
that rebinds before its two probes time out never registered; a socket
that has not sealed keeps its count across a rebind now.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:09 +08:00
rustdeskandClaude Fable 5.2 0c384e3dbd Update hbb_common: the proof goes only until the server holds it
A registration carries the device's signature until the server's
answer says it holds the proof of the session, and none after, so a
registration after the first is 64 bytes shorter. Nothing changes here
but the submodule and the comment that said every registration carries
the proof.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:08 +08:00
rustdeskandClaude Opus 5.5 629d273ec9 Register under the session and prove the device there
Update hbb_common, whose hello no longer carries a signature: a
registration now goes only as data under the session, carrying the
device's proof, and with no session yet an empty hello goes instead,
the registration following its welcome at once. A punch reply goes
under the same session; only with none yet, as right after a cookie,
does it go as a hello.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:08 +08:00
rustdeskandClaude Opus 5.5 9302626cc0 Send the hello again with the cookie a server past its budget answers with
A server past its hello budget now answers a hello with a cookie for the
client's address instead of dropping it. The client sends that hello
again with the cookie, and the socket counts as sealed, since only a
server that seals sends one: forged hellos at the server can no longer
push a new socket into plaintext. Later hellos carry the cookie, the
one-off PunchHoleSent too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:07 +08:00
rustdeskandClaude Opus 5.5 516e5828da Update hbb_common: forward secrecy for the welcome
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:07 +08:00
rustdeskandClaude Opus 5.5 3d0123a307 Update hbb_common: keep the replaced session for receiving
A push sealed under the session a welcome replaced still opens until one
opens under the new session, so hbbs can wait to see the new session
used before pushing under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:06 +08:00
rustdeskandClaude Opus 5.5 1dc1abceb0 Update hbb_common: name the standards behind udp_seal
Comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:06 +08:00
rustdeskandClaude Opus 5.5 9b168d81e1 Keep a punch reply sealed while a missed answer is retried
A missed registration answer moves a sealed socket to resealing, which
used to drop its host from the one-off seal list, so the PunchHoleSent of
a UDP punch went out in plaintext until the next answer. The socket's
server still seals then; only a rebind, which may reach another server,
or the socket going away forgets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:05 +08:00
rustdeskandClaude Opus 5.5 cffe93f1a2 Update hbb_common: no hello budget for a datagram too short to be one
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:05 +08:00
rustdeskandClaude Opus 5.5 9082f3d912 Update hbb_common: 1024-number udp_seal replay window
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:05 +08:00
rustdeskandClaude Opus 5.5 5789712752 Retry a missed sealed answer under the session and with a hello at once
Taking turns cost a server that restarted one more timeout before its
hello. Each retry now sends both: the datagram under the session, which
a server that only lost an answer takes without its hello budget, and a
hello for one that restarted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:04 +08:00
rustdeskandClaude Opus 5.5 d12b8c5894 Retry a missed sealed answer under the session before a hello
A server that only lost an answer still holds the session, but the
retry went as a hello, which shares the server's hello budget with
anyone who floods it. The first retry now goes under the session, and
retries alternate with hellos for a server that restarted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:04 +08:00
rustdeskandClaude Opus 5.5 19f368c837 Re-seal after a missed answer instead of probing afresh
A socket whose answer went missing while sealed dropped its session
and probed again: until a new welcome, pushes under the session it
still shared with the server were lost and plaintext pushes were
taken, and three misses in a row fell back to taking plaintext
registration answers, a forged UUID_MISMATCH among them.

Such a socket now sends hellos while keeping the session for pushes
until a welcome replaces it, and never falls back, since its server
seals. A rebind, which may reach another server, still probes afresh
and may fall back, so a server rolled back to an older build is
reached again within about a minute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:03 +08:00
rustdeskandClaude Opus 5.5 de85cea9cd Take only an empty sealed payload as the welcome to an empty hello
Any sealed message whose union this build does not know also parsed
with no union, so a newer server's push cleared the pending
registration and its timeout. The welcome to an empty hello is the
only sealed datagram with nothing in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:03 +08:00
rustdeskandClaude Opus 5.5 5ac7a3bafe Keep the sealed session while a signed hello replaces it
Re-signing a session from an empty hello reset it first, so for one
round trip pushes under the old key were dropped and plaintext pushes
were taken from a server that seals every push. The signed hello now
goes out beside the session, which the welcome replaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:02 +08:00
rustdeskandClaude Opus 5.5 54c8c2e018 Drop forged registration answers while probing, follow key changes
While probing every registration goes as a hello, so a plaintext answer to
one is forged: acting on it let a spoofed UUID_MISMATCH change the device ID.
A RegisterPk with a new key reloads the device key for later hellos. A rebind
in a timed-out round now leaves the new socket its two hellos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:02 +08:00
rustdeskandClaude Opus 5.5 925443d770 Seal the UDP registration and punch replies to the rendezvous server
A socket probes with signed hellos, falls back to plaintext after two go
unanswered (an older server) and re-probes every fourth round; once a sealed
datagram opens it sends only sealed data and drops plaintext answers to its
registrations. A hello never carries a RegisterPk, which a replay from
another address would move the route with; after a RegisterPk is answered the
next RegisterPeer goes as a signed hello again, since the server may not have
had the device's key when the first one came. A UDP punch's PunchHoleSent goes
sealed while the server is. Without a key for the server nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
2026-12-02 18:29:01 +08:00
101 changed files with 838 additions and 1519 deletions

No files matched your search

@@ -38,7 +38,6 @@ set -euo pipefail
readonly NO_MATCHES=0
readonly SINGLE_MATCH=1
readonly THEME_MATCHES=2
readonly CONNECTION_PAGE=flutter/lib/desktop/pages/connection_page.dart
has_exact_count() {
local -r expected_count="$1"
@@ -94,10 +93,6 @@ validate_patch_inputs() {
echo "Flutter 3.44 source patch input is missing or unreadable: flutter/lib/common/widgets/dialog.dart" >&2
return 1
fi
if [[ ! -f "$CONNECTION_PAGE" || ! -r "$CONNECTION_PAGE" ]]; then
echo "Flutter 3.44 source patch input is missing or unreadable: $CONNECTION_PAGE" >&2
return 1
fi
}
# The lock diff reverses only once applied, so a restored pubspec.lock is not taken as patched.
@@ -123,8 +118,7 @@ is_complete_patch_state() {
'scrollbarTheme: scrollbarThemeDark,' 'backgroundColor: Color(0xFF18191E),' \
flutter/lib/common.dart &&
has_exact_count "$SINGLE_MATCH" 'selectAllOnFocus: isDesktop ? false : null,' \
flutter/lib/common/widgets/dialog.dart &&
has_exact_count "$SINGLE_MATCH" 'selectAllOnFocus: isDesktop ? false : null,' "$CONNECTION_PAGE"
flutter/lib/common/widgets/dialog.dart
}
is_unpatched_state() {
@@ -140,9 +134,7 @@ is_unpatched_state() {
has_exact_count "$NO_MATCHES" 'google_fonts: ^8.1.0' flutter/pubspec.yaml &&
has_exact_count "$SINGLE_MATCH" 'inputFormatters: inputFormatters,' \
flutter/lib/common/widgets/dialog.dart &&
has_exact_count "$NO_MATCHES" 'selectAllOnFocus' flutter/lib/common/widgets/dialog.dart &&
has_exact_count "$SINGLE_MATCH" 'controller: fieldTextEditingController,' "$CONNECTION_PAGE" &&
has_exact_count "$NO_MATCHES" 'selectAllOnFocus' "$CONNECTION_PAGE"
has_exact_count "$NO_MATCHES" 'selectAllOnFocus' flutter/lib/common/widgets/dialog.dart
}
if ! validate_patch_inputs; then
@@ -152,7 +144,7 @@ fi
if is_complete_patch_state && has_lock_patch; then
echo "Flutter 3.44 source patches already applied."
git --no-pager diff -- flutter/lib/common.dart flutter/pubspec.yaml \
flutter/lib/common/widgets/dialog.dart "$CONNECTION_PAGE"
flutter/lib/common/widgets/dialog.dart
exit 0
fi
@@ -178,10 +170,6 @@ sed -i 's/google_fonts: \^6.2.1/google_fonts: ^8.1.0/' flutter/pubspec.yaml
# DialogTextField keeps the caret when a desktop field regains focus (see the header):
sed -i 's/inputFormatters: inputFormatters,/inputFormatters: inputFormatters,\
selectAllOnFocus: isDesktop ? false : null,/' flutter/lib/common/widgets/dialog.dart
# Refreshing suggestions rewrites the remote ID and invalidates its selection.
# Flutter 3.44 then applies the focus selection policy even while the field stays focused.
sed -i 's/controller: fieldTextEditingController,/controller: fieldTextEditingController,\
selectAllOnFocus: isDesktop ? false : null,/' "$CONNECTION_PAGE"
# Fail loudly if any expected substitution did not produce the complete state.
if ! is_complete_patch_state; then
@@ -190,4 +178,4 @@ if ! is_complete_patch_state; then
fi
git --no-pager diff -- flutter/lib/common.dart flutter/pubspec.yaml \
flutter/lib/common/widgets/dialog.dart "$CONNECTION_PAGE"
flutter/lib/common/widgets/dialog.dart
@@ -12,7 +12,7 @@
#
# Idempotent. To undo the source changes locally:
# git checkout -- flutter/lib/common.dart flutter/lib/common/widgets/dialog.dart \
# flutter/lib/desktop/pages/connection_page.dart flutter/pubspec.yaml flutter/pubspec.lock
# flutter/pubspec.yaml flutter/pubspec.lock
set -euo pipefail
flutter --version | grep -q "Flutter 3\.44\." || {
-13
View File
@@ -1,13 +0,0 @@
# Locked, hash-checked dependencies of res/job.py for the release-signing steps.
# Install with: pip3 install --only-binary=:all: --require-hashes -r .github/requirements/sign-files.txt
# argparse is part of the standard library and must not be installed from PyPI.
requests==2.32.5 \
--hash=sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6
urllib3==2.6.3 \
--hash=sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4
idna==3.20 \
--hash=sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c
certifi==2026.10.23 \
--hash=sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1
charset-normalizer==3.5.2 \
--hash=sha256:b6b751274acb69d77b3323d6b7dbaa3c7fdfc1eb829b7eb61d262f32e1af9685
-1
View File
@@ -46,7 +46,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install prerequisites
-1
View File
@@ -109,7 +109,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install prerequisites
+3 -16
View File
@@ -66,7 +66,7 @@ env:
VCPKG_COMMIT_ID: "9e593bb18ea69cc5095e012465dcd675a822ed0d"
VCPKG_CMAKE_VERSION: "4.3.0"
ARMV7_VCPKG_COMMIT_ID: "6f29f12e82a8293156836ad81cc9bf5af41fe836" # 2025.01.13, got "/opt/artifacts/vcpkg/vcpkg: No such file or directory" with latest version
VERSION: "1.5.4"
VERSION: "1.5.3"
NDK_VERSION: "r28c"
#signing keys env variable checks
ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}"
@@ -127,7 +127,6 @@ jobs:
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install Syft
@@ -222,7 +221,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Restore bridge files
@@ -468,7 +466,7 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true' && env.SIGN_BASE_URL != '-2'
shell: bash
run: |
pip3 install --only-binary=:all: --require-hashes -r .github/requirements/sign-files.txt
pip3 install requests argparse
BASE_URL=${{ env.SIGN_BASE_URL }} SECRET_KEY=${{ secrets.SIGN_SECRET_KEY }} python3 res/job.py sign_files ./rustdesk/
- name: Verify Windows Flutter version
@@ -662,7 +660,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install LLVM and Clang
@@ -777,7 +774,7 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true' && env.SIGN_BASE_URL != '-2'
shell: bash
run: |
pip3 install --only-binary=:all: --require-hashes -r .github/requirements/sign-files.txt
pip3 install requests argparse
BASE_URL=${{ env.SIGN_BASE_URL }} SECRET_KEY=${{ secrets.SIGN_SECRET_KEY }} python3 res/job.py sign_files ./Release/
- name: Verify Windows Sciter version
@@ -887,7 +884,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install flutter
@@ -1017,7 +1013,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Import the codesign cert
@@ -1596,7 +1591,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Check JNI natives are in ffi.FFI
@@ -1899,7 +1893,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install flutter
@@ -2072,7 +2065,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Set Swap Space
@@ -2533,7 +2525,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Install Rust toolchain
@@ -2835,7 +2826,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Modify vcpkg.json for armv7
@@ -3075,7 +3065,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Download Binary
@@ -3152,7 +3141,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Download Binary
@@ -3216,7 +3204,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
- name: Prepare env
+1 -3
View File
@@ -17,7 +17,7 @@ env:
TAG_NAME: "nightly"
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
VCPKG_COMMIT_ID: "9e593bb18ea69cc5095e012465dcd675a822ed0d"
VERSION: "1.5.4"
VERSION: "1.5.3"
NDK_VERSION: "r26d"
#signing keys env variable checks
ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}"
@@ -88,7 +88,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
persist-credentials: false
ref: ${{ matrix.job.ref }}
submodules: recursive
@@ -251,7 +250,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
persist-credentials: false
ref: ${{ matrix.job.ref }}
submodules: recursive
-1
View File
@@ -60,4 +60,3 @@ flutter/web/
/third_party/libdrmtap/
# Local git worktrees
.worktrees/
flutter/*.sh
Generated
+7 -7
View File
@@ -1717,7 +1717,7 @@ dependencies = [
[[package]]
name = "cpal"
version = "0.15.3"
source = "git+https://github.com/rustdesk-org/cpal?branch=osx-screencapturekit#3361bd6aa877e110f6df6cd98dc7c7f6427cb79b"
source = "git+https://github.com/rustdesk-org/cpal?branch=osx-screencapturekit#96d4da121b7d949677ac5b6887413a9185fd7f39"
dependencies = [
"alsa",
"cidre",
@@ -7061,7 +7061,7 @@ dependencies = [
[[package]]
name = "rustdesk"
version = "1.5.4"
version = "1.5.3"
dependencies = [
"android-wakelock",
"android_logger",
@@ -7178,7 +7178,7 @@ dependencies = [
[[package]]
name = "rustdesk-portable-packer"
version = "1.5.4"
version = "1.5.3"
dependencies = [
"brotli",
"dirs 5.0.1",
@@ -7255,9 +7255,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.23.46"
version = "0.23.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643"
dependencies = [
"log",
"once_cell",
@@ -8209,7 +8209,7 @@ dependencies = [
[[package]]
name = "tao"
version = "0.25.0"
source = "git+https://github.com/rustdesk-org/tao?branch=dev#74684bd8b7f565a0edf9412f7403f6433f0d5efb"
source = "git+https://github.com/rustdesk-org/tao?branch=dev#288c219cb0527e509590c2b2d8e7072aa9feb2d3"
dependencies = [
"bitflags 1.3.2",
"cc",
@@ -8249,7 +8249,7 @@ dependencies = [
[[package]]
name = "tao-macros"
version = "0.1.2"
source = "git+https://github.com/rustdesk-org/tao?branch=dev#74684bd8b7f565a0edf9412f7403f6433f0d5efb"
source = "git+https://github.com/rustdesk-org/tao?branch=dev#288c219cb0527e509590c2b2d8e7072aa9feb2d3"
dependencies = [
"proc-macro2 1.0.93",
"quote 1.0.36",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "rustdesk"
version = "1.5.4"
version = "1.5.3"
authors = ["rustdesk <info@rustdesk.com>"]
edition = "2021"
build= "build.rs"
+17 -18
View File
@@ -18,22 +18,24 @@ AppDir:
id: rustdesk
name: rustdesk
icon: rustdesk
version: 1.5.4
version: 1.5.3
exec: usr/share/rustdesk/rustdesk
exec_args: $@
apt:
arch:
- arm64
allow_unauthenticated: true
sources:
# Ubuntu's 2012 and 2018 archive signing keys (both sign focal), exported from ubuntu-keyring:
# gpg --show-keys ubuntu-archive-keyring.asc. apt trusts them for every source below.
- sourceline: deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
key_url: file:ubuntu-archive-keyring.asc
- sourceline: deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
- sourceline: deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted
universe multiverse
- sourceline: deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted
universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
include:
- libc6:arm64
- libgtk-3-0
@@ -77,16 +79,13 @@ AppDir:
# AppRun sets these to "$APPDIR/...:$XDG_DATA_DIRS", and setting them at all suppresses the XDG
# defaults, so a host that leaves them unset loses /usr/share and /etc/xdg. gdk-pixbuf 2.43+
# (Arch, Fedora) then finds no glycin loaders and every PNG decode fails, aborting on the first
# remote cursor. The host value goes last, after a "/": unset, AppRun expands it to nothing, and
# an empty element would make GLib search the CWD; "/" leaves the root instead, and a set
# value's first absolute path becomes the same "//path".
XDG_DATA_DIRS: $APPDIR/usr/local/share:$APPDIR/usr/share:/usr/local/share:/usr/share:/$XDG_DATA_DIRS
XDG_CONFIG_DIRS: $APPDIR/etc/xdg:/etc/xdg:/$XDG_CONFIG_DIRS
# Host paths come before $APPDIR so Wayland capture uses the host's GStreamer and PipeWire.
# Arch Linux ARM has neither /lib64 nor a multiarch dir on aarch64, only /usr/lib.
APPDIR_LIBRARY_PATH: /lib64:/usr/lib/aarch64-linux-gnu:/usr/lib:$APPDIR/lib/aarch64-linux-gnu:$APPDIR/lib/aarch64-linux-gnu/security:$APPDIR/lib/systemd:$APPDIR/usr/lib/aarch64-linux-gnu:$APPDIR/usr/lib/aarch64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/immodules:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/printbackends:$APPDIR/usr/lib/aarch64-linux-gnu/krb5/plugins/preauth:$APPDIR/usr/lib/aarch64-linux-gnu/libcanberra-0.30:$APPDIR/usr/lib/aarch64-linux-gnu/pulseaudio:$APPDIR/usr/lib/aarch64-linux-gnu/sasl2:$APPDIR/usr/lib/aarch64-linux-gnu/vdpau:$APPDIR/usr/share/rustdesk/lib:$APPDIR/lib/aarch64
GST_PLUGIN_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:/usr/lib/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
GST_PLUGIN_SYSTEM_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:/usr/lib/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
# remote cursor. The host value goes last: unset it expands to an empty element, which GLib
# resolves against the CWD, and that must not outrank the defaults below.
XDG_DATA_DIRS: $APPDIR/usr/local/share:$APPDIR/usr/share:/usr/local/share:/usr/share:$XDG_DATA_DIRS
XDG_CONFIG_DIRS: $APPDIR/etc/xdg:/etc/xdg:$XDG_CONFIG_DIRS
APPDIR_LIBRARY_PATH: /lib64:/usr/lib/aarch64-linux-gnu:$APPDIR/lib/aarch64-linux-gnu:$APPDIR/lib/aarch64-linux-gnu/security:$APPDIR/lib/systemd:$APPDIR/usr/lib/aarch64-linux-gnu:$APPDIR/usr/lib/aarch64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/immodules:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/printbackends:$APPDIR/usr/lib/aarch64-linux-gnu/krb5/plugins/preauth:$APPDIR/usr/lib/aarch64-linux-gnu/libcanberra-0.30:$APPDIR/usr/lib/aarch64-linux-gnu/pulseaudio:$APPDIR/usr/lib/aarch64-linux-gnu/sasl2:$APPDIR/usr/lib/aarch64-linux-gnu/vdpau:$APPDIR/usr/share/rustdesk/lib:$APPDIR/lib/aarch64
GST_PLUGIN_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
GST_PLUGIN_SYSTEM_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
test:
fedora-30:
image: appimagecrafters/tests-env:fedora-30
+14 -17
View File
@@ -18,25 +18,23 @@ AppDir:
id: rustdesk
name: rustdesk
icon: rustdesk
version: 1.5.4
version: 1.5.3
exec: usr/share/rustdesk/rustdesk
exec_args: $@
apt:
arch:
- amd64
allow_unauthenticated: true
sources:
# Ubuntu's 2012 and 2018 archive signing keys (both sign focal), exported from ubuntu-keyring:
# gpg --show-keys ubuntu-archive-keyring.asc. apt trusts them for every source below.
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal main restricted
key_url: file:ubuntu-archive-keyring.asc
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal-updates main restricted
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal universe
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal-updates universe
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal multiverse
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal-updates multiverse
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal-backports main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted
universe multiverse
- sourceline: deb https://archive.ubuntu.com/ubuntu/ focal-security main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted
universe multiverse
include:
# https://github.com/rustdesk/rustdesk/issues/9103
@@ -84,11 +82,10 @@ AppDir:
# AppRun sets these to "$APPDIR/...:$XDG_DATA_DIRS", and setting them at all suppresses the XDG
# defaults, so a host that leaves them unset loses /usr/share and /etc/xdg. gdk-pixbuf 2.43+
# (Arch, Fedora) then finds no glycin loaders and every PNG decode fails, aborting on the first
# remote cursor. The host value goes last, after a "/": unset, AppRun expands it to nothing, and
# an empty element would make GLib search the CWD; "/" leaves the root instead, and a set
# value's first absolute path becomes the same "//path".
XDG_DATA_DIRS: $APPDIR/usr/local/share:$APPDIR/usr/share:/usr/local/share:/usr/share:/$XDG_DATA_DIRS
XDG_CONFIG_DIRS: $APPDIR/etc/xdg:/etc/xdg:/$XDG_CONFIG_DIRS
# remote cursor. The host value goes last: unset it expands to an empty element, which GLib
# resolves against the CWD, and that must not outrank the defaults below.
XDG_DATA_DIRS: $APPDIR/usr/local/share:$APPDIR/usr/share:/usr/local/share:/usr/share:$XDG_DATA_DIRS
XDG_CONFIG_DIRS: $APPDIR/etc/xdg:/etc/xdg:$XDG_CONFIG_DIRS
APPDIR_LIBRARY_PATH: /lib64:/usr/lib/x86_64-linux-gnu:$APPDIR/lib/x86_64-linux-gnu:$APPDIR/lib/x86_64-linux-gnu/security:$APPDIR/lib/systemd:$APPDIR/usr/lib/x86_64-linux-gnu:$APPDIR/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules:$APPDIR/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends:$APPDIR/usr/lib/x86_64-linux-gnu/krb5/plugins/preauth:$APPDIR/usr/lib/x86_64-linux-gnu/libcanberra-0.30:$APPDIR/usr/lib/x86_64-linux-gnu/pulseaudio:$APPDIR/usr/lib/x86_64-linux-gnu/sasl2:$APPDIR/usr/lib/x86_64-linux-gnu/vdpau:$APPDIR/usr/share/rustdesk/lib:$APPDIR/lib/x86_64
GST_PLUGIN_PATH: /lib64/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0
GST_PLUGIN_SYSTEM_PATH: /lib64/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0
@@ -1,41 +0,0 @@
diff --git a/src/apprun/runtime_interpreter.c b/src/apprun/runtime_interpreter.c
index fe06502..33ddd8e 100644
--- a/src/apprun/runtime_interpreter.c
+++ b/src/apprun/runtime_interpreter.c
@@ -143,6 +143,20 @@ long compare_version_strings(const char *a, const char *b) {
return 0;
}
+/* An empty element, as appending an unset LD_LIBRARY_PATH leaves, makes the dynamic loader search
+ * the current directory. */
+static void apprun_drop_empty_path_elements(char *path) {
+ char *out = path;
+ for (const char *in = path; *in != '\0'; in++) {
+ if (*in == ':' && (out == path || out[-1] == ':'))
+ continue;
+ *out++ = *in;
+ }
+ if (out > path && out[-1] == ':')
+ out--;
+ *out = '\0';
+}
+
void configure_embed_libc() {
#ifdef DEBUG
fprintf(stderr, "APPRUN_DEBUG: using appdir libc\n");
@@ -150,6 +164,7 @@ void configure_embed_libc() {
char *ld_library_path = apprun_shell_expand_variables("$"APPDIR_LIBRARY_PATH_ENV":"
"$"APPDIR_LIBC_LIBRARY_PATH_ENV":"
"$"APPRUN_ENV_ORIG_PREFIX"LD_LIBRARY_PATH", NULL);
+ apprun_drop_empty_path_elements(ld_library_path);
apprun_env_set("LD_LIBRARY_PATH", ld_library_path, "", ld_library_path);
free(ld_library_path);
@@ -161,6 +176,7 @@ void configure_system_libc() {
#endif
char *ld_library_path = apprun_shell_expand_variables("$"APPDIR_LIBRARY_PATH_ENV":"
"$"APPRUN_ENV_ORIG_PREFIX"LD_LIBRARY_PATH", NULL);
+ apprun_drop_empty_path_elements(ld_library_path);
apprun_env_set("LD_LIBRARY_PATH", ld_library_path, "", ld_library_path);
free(ld_library_path);
+2 -6
View File
@@ -1,11 +1,8 @@
#!/usr/bin/env bash
# AppRun v2.0.0, which appimage-builder downloads, splits every argument into a 1 KiB stack
# buffer, so any argument of 1024 bytes or more aborts the AppImage before RustDesk starts.
# It also appends the host's LD_LIBRARY_PATH after a ":", so an unset one leaves an empty element
# that makes the loader search the current directory for libraries.
# Build it with apprun-split-arguments.patch and apprun-no-empty-library-path.patch into the path
# appimage-builder checks before downloading. ubuntu:16.04 is what upstream released from, so the
# host glibc floor is unchanged.
# Build it with apprun-split-arguments.patch into the path appimage-builder checks before
# downloading. ubuntu:16.04 is what upstream released from, so the host glibc floor is unchanged.
set -euo pipefail
arch=$1
@@ -28,7 +25,6 @@ echo "$sha256 $tmp/apprun.tar.gz" | sha256sum -c -
mkdir "$src"
tar -xzf "$tmp/apprun.tar.gz" -C "$src" --strip-components=1
patch -d "$src" -p1 < "$here/apprun-split-arguments.patch"
patch -d "$src" -p1 < "$here/apprun-no-empty-library-path.patch"
docker run --rm -v "$src:/src" -w /src -e DEBIAN_FRONTEND=noninteractive "$image" bash -c "
set -e
-53
View File
@@ -1,53 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBE+tgXgBEADfiL1KNFHT4H4Dw0OR9LemR8ebsFl+b9E44IpGhgWYDufj0gaM
/UJ1Ti3bHfRT39VVZ6cv1P4mQy0bnAKFbYz/wo+GhzjBWtn6dThYv7n+KL8bptSC
Xgg1a6en8dCCIA/pwtS2Ut/g4Eu6Z467dvYNlMgCqvg+prKIrXf5ibio48j3AFvd
1dDJl2cHfyuON35/83vXKXz0FPohQ7N7kPfI+qrlGBYGWFzC/QEGje360Q2Yo+rf
MoyDEXmPsoZVqf7EE8gjfnXiRqmz/Bg5YQb5bgnGbLGiHWtjS+ACIdLUq/h+jlSp
57jw8oQktMh2xVMX4utDM0UENeZnPllVJSlR0b+ZmZz7paeSar8Yxn4wsNlL7GZb
pW5A/WmcmWfuMYoPhBo5Fq1V2/siKNU3UKuf1KH+X0p1oZ4oOcZ2bS0Zh3YEG8IQ
ce9Bferq4QMKsekcG9IKS6WBIU7BwaElI2ILD0gSwu8KzvNSEeIJhYSsBIEzrWxI
BXoN2AC9PCqqXkWlI5Xr/86RWllB3CsoPwEfO8CLJW2LlXTen/Fkq4wT+apdhHei
WiSsq/J5OEff0rKHBQ3fK7fyVuVNrJFb2CopaBLyCxTupvxs162jjUNopt0c7OqN
BoPoUoVFAxUSpeEwAw6xrM5vROyLMSeh/YnTuRy8WviRapZCYo6naTCY5wARAQAB
tEJVYnVudHUgQXJjaGl2ZSBBdXRvbWF0aWMgU2lnbmluZyBLZXkgKDIwMTIpIDxm
dHBtYXN0ZXJAdWJ1bnR1LmNvbT6JAjgEEwECACIFAk+tgXgCGwMGCwkIBwMCBhUI
AgkKCwQWAgMBAh4BAheAAAoJEDtP5qzAsh8yXX4QAJHUdK6eYMyJcrFP3yKXtUYQ
MpaHRM/floqZtOFhlmcLVMgBNOr0eLvBU0JcZyZpHMvZciTDBMWX8ItCYVjRejf0
K0lPvHHRGaE7t6JHVUCeznNbDMnOPYVwlVJdZLOa6PmE5WXVXpk8uTA8vm6RO2rS
23vE7U0pQlV+1GVXMWH4ZLjaQs/Tm7wdvRxeqTbtfOEeHGLjmsoh0erHfzMV4wA/
9Zq86WzuJS1HxXR6OYDC3/aQX7CxYT1MQxEw/PObnHtkl3PRMWdTW7fSQtulEXzp
r2/JCev6Mfc8Uy0aD3jng9byVk9GpdNFEjGgaUqjqyZosvwAZ4/dmRjmMEibXeNU
GC8HeWC3WOVV8L/DiA+miJlwPvwPiA1ZuKBI5A8VF0rNHW7QVsG8kQ+PDHgRdsmh
pzSRgykN1PgK6UxScKX8LqNKCtKpuEPApka7FQ1u4BoZKjjpBhY1R4TpfFkMIe7q
W8XfqoaP99pED3xXch2zFRNHitNJr+yQJH4z/o+2UvnTA2niUTHlFSCBoU1MvSq1
N2J3qU6oR2cOYJ4ZxqWyCoeQR1x8aPnLlcn4le6HU7TocYbHaImcIt7qnG4Ni0OW
P4giEhjOpgxtrWgl36mdufvriwya+EHXzn36EvQ9O+bm3fyarsnhPe01rlsRxqBi
K1JOw/g4GnpX8iLGEX1VmQINBFufwdoBEADv/Gxytx/LcSXYuM0MwKojbBye81s0
G1nEx+lz6VAUpIUZnbkqdXBHC+dwrGS/CeeLuAjPRLU8AoxE/jjvZVp8xFGEWHYd
klqXGZ/gJfP5d3fIUBtZHZEJl8B8m9pMHf/AQQdsC+YzizSG5t5Mhnotw044LXtd
EEkx2t6Jz0OGrh+5IoxqX7pZiq6Cv19BohaUioKMdp7ES6RYfN7ol6HSLFlrMXtV
fh/ijpN9j3ZhVGVeRC8kKHQsJ5PkIbmvxBiUh7SJmfZUx0IQhNMaDHXfdZAGNtnh
zzNReb1FqNLSVkrS/PnsAQzMhG1BDm2VOSF64jebKXffFqM5LXRQTeqTLsjUbbrq
R6s/GCO8UF7jfUj6I7taLygmsHO/JD4jpKRC0gbpUBfaiJyLvuepx3kWoqL3sN0L
hlMI80+fA7GTvoOx4tpqVlzlE6TajYu+jfW3QpOFS5ewEMdL26hzxsZg/geZvTbA
rcP+OsJKRmhv4kNo6AydyHQ/3ZV/f3X9mT3/SPLbJaumkgp3Yzd6t5PeBu+ZQk/m
N5WNNuaihNEV7llb1ZhvY0Fxu9BVd/BNl0rzuxp3rIinB2TX2SCg7wE5xXkwXuQ/
2eTDE0v0HlGntkuZjGowDZkxHZQSxZVOzdZCRVaX/WEFLpKa2AQpw5RJrQ4oZ/Of
ifXyJzP27o03wQARAQABtEJVYnVudHUgQXJjaGl2ZSBBdXRvbWF0aWMgU2lnbmlu
ZyBLZXkgKDIwMTgpIDxmdHBtYXN0ZXJAdWJ1bnR1LmNvbT6JAjgEEwEKACIFAluf
wdoCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEIcZINGZG8k8LHMQAKS2
cnxz/5WaoCOWArf5g6UHbeOCgc5DBm0hCuFDZWWv427aGei3CPuLw0DGLCXZdyc5
dqE8mvjMlOmmAKKlj1uGg3TYCbQWjWPeMnBPZbkFgkZoXJ7/6CB7bWRht1sHzpt1
LTZ+SYDwOwJ68QRp7DRaZl9Y6QiUbeuhq2DUcTofVbBxbhrckN4ZteLvm+/nG9m/
ciopc66LwRdkxqfJ32Cyq+1TS5VaIJDG7DWziG+Kbu6qCDM4QNlg3LH7p14CrRxA
bc4lvohRgsV4eQqsIcdFkuVY5HPPj2K8TqpY6STe8Gh0aprG1RV8ZKay3KSMpnyV
1fAKn4fM9byiLzQAovC0LZ9MMMsrAS/45AvC3IEKSShjLFn1X1dRCiO6/7jmZEoZ
tAp53hkf8SMBsi78hVNrBumZwfIdBA1v22+LY4xQK8q4XCoRcA9G+pvzU9YVW7cR
nDZZGl0uwOw7z9PkQBF5KFKjWDz4fCk+K6+YtGpovGKekGBb8I7EA6UpvPgqA/Qd
I0t1IBP0N06RQcs1fUaAQEtz6DGy5zkRhR4pGSZn+dFET7PdAjEK84y7BdY4t+U1
jcSIvBj0F2B7LwRL7xGpSpIKi/ekAXLs117bvFHaCvmUYN7JVp1GMmVFxhIdx6CF
m3fxG8QjNb5tere/YqK+uOgcXny1UlwtCUzlrSaP
=GitC
-----END PGP PUBLIC KEY BLOCK-----
+28 -52
View File
@@ -1015,64 +1015,40 @@ class BottomSheetBody extends StatelessWidget {
final _actions = actions ?? [];
return BottomSheet(
builder: (BuildContext context) {
final mediaQuery = MediaQuery.of(context);
final view = View.maybeOf(context);
final viewBottomPadding = view != null && view.devicePixelRatio > 0
? view.padding.bottom / view.devicePixelRatio
: 0.0;
final bottomInset = mediaQuery.padding.bottom > viewBottomPadding
? mediaQuery.padding.bottom
: viewBottomPadding;
return Container(
height: 65,
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
color: MyTheme.accent50,
borderRadius: BorderRadius.vertical(top: Radius.circular(10))),
child: SafeArea(
top: false,
minimum: EdgeInsets.only(bottom: bottomInset),
child: Container(
height: 65,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
leading,
SizedBox(width: 16),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
leading,
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18)),
Text(text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14)) // TODO color
],
),
)
Text(title, style: TextStyle(fontSize: 18)),
Text(text,
style: TextStyle(fontSize: 14)) // TODO color
],
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
..._actions,
IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: onCanceled,
),
],
)
],
),
)
],
),
Row(children: () {
_actions.add(IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: onCanceled,
));
return _actions;
}())
],
),
));
},
+22 -31
View File
@@ -566,13 +566,12 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
}
return Container(
color: MyTheme.canvasColor,
child: withKeyHelpTools(
inputModel.isPhysicalMouse.value
? getBodyForMobile()
: RawTouchGestureDetectorRegion(
child: getBodyForMobile(),
ffi: gFFI,
)),
child: inputModel.isPhysicalMouse.value
? getBodyForMobile()
: RawTouchGestureDetectorRegion(
child: getBodyForMobile(),
ffi: gFFI,
),
);
}),
),
@@ -713,27 +712,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
!gFFI.canvasModel.cursorEmbedded &&
!gFFI.inputModel.relativeMouseMode.value;
// The key bar sits above the canvas, outside its gesture region: a touch on the bar must not
// also reach the canvas recognizers, which would send it to the remote as a mouse event.
// The cursor and the touch-mode virtual mouse stay above the bar, as they were inside the canvas
// stack. The mouse-mode virtual mouse stays inside the region: see getBodyForMobile.
Widget withKeyHelpTools(Widget body) => Stack(children: [
Positioned.fill(child: body),
Obx(() {
final chatKeyboardRequested =
gFFI.chatModel.softKeyboardRequested.value;
return KeyHelpTools(
keyboardIsVisible: keyboardVisibilityController.isVisible &&
(_showEdit || chatKeyboardRequested),
showGestureHelp: _showGestureHelp);
}),
if (showCursorPaint) CursorPaint(widget.id),
if (gFFI.ffiModel.touchMode)
FloatingMouse(
ffi: gFFI,
),
]);
Widget getBodyForMobile() {
return Container(
color: MyTheme.canvasColor,
@@ -745,6 +723,14 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
right: 10,
child: QualityMonitor(gFFI.qualityMonitorModel),
),
Obx(() {
final chatKeyboardRequested =
gFFI.chatModel.softKeyboardRequested.value;
return KeyHelpTools(
keyboardIsVisible: keyboardVisibilityController.isVisible &&
(_showEdit || chatKeyboardRequested),
showGestureHelp: _showGestureHelp);
}),
SizedBox(
width: 0,
height: 0,
@@ -776,9 +762,14 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
).workaroundFreezeLinuxMint(),
),
];
// Holding a virtual button while another finger drags needs both pointers in the canvas
// recognizers (isSpecialHoldDragActive), so these stay inside the gesture region.
if (!gFFI.ffiModel.touchMode) {
if (showCursorPaint) {
paints.add(CursorPaint(widget.id));
}
if (gFFI.ffiModel.touchMode) {
paints.add(FloatingMouse(
ffi: gFFI,
));
} else {
paints.add(FloatingMouseWidgets(
ffi: gFFI,
));
-2
View File
@@ -1188,8 +1188,6 @@ class FfiModel with ChangeNotifier {
}
if (waitForFirstImage.isFalse) return;
// A second show under the same tag would orphan the first overlay: no dismiss can reach it.
clearWaitingForImage(dialogManager, sessionId);
dialogManager.show(
(setState, close, context) => CustomAlertDialog(
title: null,
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# 1.1.9-1 works for android, but for ios it becomes 1.1.91, need to set it to 1.1.9-a.1 for iOS, will get 1.1.9.1, but iOS store not allow 4 numbers
version: 1.5.4+72
version: 1.5.3+71
environment:
sdk: '^3.1.0'
@@ -1,69 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
Widget buildSubject({
VoidCallback? onCanceled,
List<IconButton>? actions,
}) {
return MaterialApp(
home: Scaffold(
bottomSheet: BottomSheetBody(
leading: const Icon(Icons.check),
title: 'Wybrano',
text: '1 elementów [Lokalny]',
onCanceled: onCanceled,
actions: actions,
),
),
);
}
testWidgets('keeps action buttons above bottom system navigation bar',
(tester) async {
tester.view.physicalSize = const Size(360, 800);
tester.view.devicePixelRatio = 1.0;
tester.view.padding = const FakeViewPadding(bottom: 48);
tester.view.viewPadding = const FakeViewPadding(bottom: 48);
addTearDown(tester.view.reset);
var canceled = false;
await tester.pumpWidget(buildSubject(
onCanceled: () => canceled = true,
actions: [
IconButton(icon: const Icon(Icons.save_alt), onPressed: () {}),
IconButton(icon: const Icon(Icons.compare_arrows), onPressed: () {}),
IconButton(icon: const Icon(Icons.delete_forever), onPressed: () {}),
],
));
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(BottomSheetBody)).height, 113.0);
for (final icon in const [
Icons.save_alt,
Icons.compare_arrows,
Icons.delete_forever,
Icons.cancel_outlined,
]) {
expect(tester.getBottomRight(find.byIcon(icon)).dy,
lessThanOrEqualTo(752.0));
}
await tester.tap(find.byIcon(Icons.cancel_outlined));
await tester.pump();
expect(canceled, isTrue);
});
testWidgets('preserves default height when bottom inset is zero',
(tester) async {
tester.view.physicalSize = const Size(360, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
await tester.pumpWidget(buildSubject());
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(BottomSheetBody)).height, 65.0);
});
}
@@ -1,66 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/common/widgets/peers_view.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/pages/connection_page.dart';
import 'package:flutter_hbb/generated_bridge.dart';
import 'package:flutter_hbb/models/peer_model.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:provider/provider.dart';
class _OutgoingClient extends Fake implements RustdeskImpl {
@override
bool isOutgoingOnly({dynamic hint}) => true;
@override
bool isDisableAb({dynamic hint}) => true;
@override
bool isDisableGroupPanel({dynamic hint}) => true;
@override
bool mainIsOptionFixed({required String key, dynamic hint}) => false;
@override
String mainGetLocalOption({required String key, dynamic hint}) => '';
@override
String getLocalFlutterOption({required String k, dynamic hint}) =>
k == kOptionPeerTabVisible ? '[false,false,false,false,false]' : '';
@override
Future<void> setLocalFlutterOption(
{required String k, required String v, dynamic hint}) async {}
@override
String translate(
{required String name, required String locale, dynamic hint}) =>
'';
@override
Future<String> mainGetLastRemoteId({dynamic hint}) async => '';
@override
Future<void> mainLoadRecentPeers({dynamic hint}) async {}
@override
Future<void> mainLoadLanPeers({dynamic hint}) async {}
}
void main() {
testWidgets('refreshing recent peers keeps the remote ID caret',
(tester) async {
isTest = true;
platformFFI.setBindingForTesting(_OutgoingClient());
await initGlobalFFI();
await tester.pumpWidget(MaterialApp(
theme: MyTheme.lightTheme,
home: ChangeNotifierProvider.value(
value: gFFI.peerTabModel,
child: const Scaffold(body: ConnectionPage()),
),
));
final field = find.descendant(
of: find.byType(RawAutocomplete<Peer>),
matching: find.byType(TextField));
await tester.showKeyboard(field);
await tester.pumpAndSettle();
await tester.enterText(field, 'lhb');
await platformFFI.tryHandle({'name': LoadEvent.recent, 'peers': '[]'});
await tester.pumpAndSettle();
expect(tester.widget<TextField>(field).controller!.selection,
const TextSelection.collapsed(offset: 3));
}, variant: TargetPlatformVariant.only(TargetPlatform.windows));
}
@@ -1,68 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/generated_bridge.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_test/flutter_test.dart';
class _Binding extends Fake implements RustdeskImpl {
@override
String translate(
{required String name, required String locale, dynamic hint}) =>
name;
@override
String mainGetLocalOption({required String key, dynamic hint}) => '';
@override
String getLocalFlutterOption({required String k, dynamic hint}) => '';
@override
bool isDisableAb({dynamic hint}) => false;
@override
bool isDisableAccount({dynamic hint}) => false;
@override
bool isDisableGroupPanel({dynamic hint}) => false;
@override
Future<void> sessionOnWaitingForImageDialogShow(
{required SessionID sessionId, dynamic hint}) async {}
@override
Future<void> sessionInputOsPassword(
{required SessionID sessionId,
required String value,
dynamic hint}) async {}
}
void main() {
setUpAll(() async {
isTest = true;
platformFFI.setBindingForTesting(_Binding());
await initGlobalFFI();
});
// A reconnect to an already selected Windows session reports the wait twice.
testWidgets('no waiting dialog is left after a repeated wait is dismissed',
(tester) async {
await tester.pumpWidget(MaterialApp(
navigatorKey: globalKey,
home: const Scaffold(),
));
final model = gFFI.ffiModel;
model.waitForFirstImage.value = true;
for (var i = 0; i < 2; i++) {
model.showConnectedWaitingForImage(gFFI.dialogManager, gFFI.sessionId,
'success', 'Successful', kMsgboxTextWaitingForImage);
}
await tester.pump();
expect(find.text(kMsgboxTextWaitingForImage), findsWidgets);
// Both the first frame and leaving the remote page end in dismissAll().
gFFI.dialogManager.dismissAll();
await tester.pump(const Duration(seconds: 2));
expect(find.text(kMsgboxTextWaitingForImage), findsNothing);
});
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -3,8 +3,6 @@ mod paste_observer;
mod paste_task;
pub mod pasteboard_context;
pub use pasteboard_context::has_rustdesk_file_url_owner;
pub fn should_handle_msg(msg: &crate::ClipboardFile) -> bool {
matches!(
msg,
@@ -29,7 +29,6 @@ lazy_static::lazy_static! {
}
pub const TEMP_FILE_PREFIX: &str = ".rustdesk_";
const RUSTDESK_FILE_URL_OWNER_TYPE: &str = "com.rustdesk.file-url-owner";
#[derive(Default, Debug, Clone, PartialEq)]
pub(super) struct PasteObserverInfo {
@@ -294,10 +293,6 @@ impl PasteboardContext {
)]);
let item = objc2_app_kit::NSPasteboardItem::new();
item.setDataProvider_forTypes(&ProtocolObject::from_id(provider), &types);
item.setString_forType(
&NSString::from_str(""),
&NSString::from_str(RUSTDESK_FILE_URL_OWNER_TYPE),
);
self.pasteboard.clearContents();
if !self
.pasteboard
@@ -435,82 +430,3 @@ pub fn create_pasteboard_context() -> ResultType<Box<PasteboardContext>> {
context.init();
Ok(context)
}
pub fn has_rustdesk_file_url_owner() -> bool {
autoreleasepool(|_| unsafe {
let Some(pasteboard): Option<Id<NSPasteboard>> =
msg_send_id![NSPasteboard::class(), generalPasteboard]
else {
return false;
};
let Some(items) = pasteboard.pasteboardItems() else {
return false;
};
items.iter().any(|item| {
item.types()
.iter()
.any(|ty| ty.to_string() == RUSTDESK_FILE_URL_OWNER_TYPE)
})
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ownership_check_skips_lazy_provider_until_external_read() {
struct TempFileGuard(String);
impl Drop for TempFileGuard {
fn drop(&mut self) {
if let Err(e) = std::fs::remove_file(&self.0) {
eprintln!("failed to remove temp file {}: {e}", self.0);
}
}
}
let pasteboard: Option<Id<NSPasteboard>> =
unsafe { msg_send_id![NSPasteboard::class(), generalPasteboard] };
let pasteboard = pasteboard.expect("failed to get general pasteboard");
let (tx, rx) = channel();
let (tx_paste_task, rx_paste_task) = channel();
let context = PasteboardContext {
pasteboard: pasteboard.clone(),
observer: Arc::new(Mutex::new(PasteObserver::new())),
tx_handle: Some(ContextInfo {
tx,
handle: thread::spawn(|| {}),
}),
tx_remove_file: None,
remove_file_handle: None,
tx_paste_task,
paste_task: Arc::new(Mutex::new(PasteTask::new(rx_paste_task))),
};
let before_count = PasteboardContext::temp_files_count();
autoreleasepool(|_| {
context
.set_clipboard_item(context.tx_handle.as_ref().unwrap(), 9, 7)
.unwrap();
});
assert!(has_rustdesk_file_url_owner());
assert!(
rx.try_recv().is_err(),
"ownership check must not invoke lazy file-url provider"
);
assert_eq!(PasteboardContext::temp_files_count(), before_count);
let url = unsafe { pasteboard.stringForType(NSPasteboardTypeFileURL) }
.expect("external read should resolve lazy file URL")
.to_string();
let task_info = rx
.try_recv()
.expect("external read should notify provider channel")
.expect("provider should create placeholder file");
let _guard = TempFileGuard(task_info.source_path.clone());
assert!(url.ends_with(&task_info.source_path));
assert!(Path::new(&task_info.source_path).exists());
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "rustdesk-portable-packer"
version = "1.5.4"
version = "1.5.3"
edition = "2021"
description = "RustDesk Remote Desktop"
+1 -1
View File
@@ -24,7 +24,7 @@ use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use base::platform::linux::{WaylandDisplayInfo, CMD_SH};
use hbb_common::{anyhow::anyhow, bail, config, serde_json, ResultType};
use hbb_common::{anyhow::anyhow, bail, config, serde_json, tokio, ResultType};
use super::capturable::PixelProvider;
use super::capturable::{Capturable, Recorder};
+1 -1
View File
@@ -1,5 +1,5 @@
pkgname=rustdesk
pkgver=1.5.4
pkgver=1.5.3
pkgrel=0
epoch=
pkgdesc=""
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 97 KiB

+1 -1
View File
@@ -1,5 +1,5 @@
Name: rustdesk
Version: 1.5.4
Version: 1.5.3
Release: 0
Summary: RPM package
License: GPL-3.0
+1 -1
View File
@@ -1,5 +1,5 @@
Name: rustdesk
Version: 1.5.4
Version: 1.5.3
Release: 0
Summary: RPM package
License: GPL-3.0
+1 -1
View File
@@ -1,5 +1,5 @@
Name: rustdesk
Version: 1.5.4
Version: 1.5.3
Release: 0
Summary: RPM package
License: GPL-3.0
+5 -82
View File
@@ -4,11 +4,10 @@ use hbb_common::{
config::Config,
get_time,
password_security::{decrypt_vec_or_original, encrypt_vec_or_original},
tls::TlsType,
ResultType,
};
use serde_derive::{Deserialize, Serialize};
use std::{fmt, sync::Mutex, time::Duration};
use std::sync::Mutex;
use totp_rs::{Algorithm, Secret, TOTP};
lazy_static::lazy_static! {
@@ -112,7 +111,7 @@ pub fn get_2fa(raw: Option<String>) -> Option<TOTP> {
.unwrap_or_default()
}
#[derive(Clone, Default, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct TelegramBot {
#[serde(skip)]
pub token_str: String,
@@ -120,16 +119,6 @@ pub struct TelegramBot {
pub chat_id: String,
}
impl fmt::Debug for TelegramBot {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TelegramBot")
.field("token_str", &"[redacted]")
.field("token", &"[redacted]")
.field("chat_id", &self.chat_id)
.finish()
}
}
impl TelegramBot {
fn into_string(&self) -> ResultType<String> {
let token = encrypt_vec_or_original(self.token_str.as_bytes(), "00", 1024);
@@ -165,39 +154,18 @@ impl TelegramBot {
}
}
// The URL carries the bot token: never fall back to accepting an invalid certificate, and drop
// the URL from errors so the token stays out of the log.
async fn post_telegram(url: String, body: String) -> ResultType<String> {
let resp = crate::hbbs_http::create_http_client_async(TlsType::Rustls, false)
.post(url)
.header("Content-Type", "application/json")
.body(body)
.timeout(Duration::from_secs(12))
.send()
.await
.map_err(|e| anyhow!("{:?}", e.without_url()))?;
resp.text()
.await
.map_err(|e| anyhow!("{:?}", e.without_url()))
}
// https://gist.github.com/dideler/85de4d64f66c1966788c1b2304b9caf1
pub async fn send_2fa_code_to_telegram(text: &str, bot: TelegramBot) -> ResultType<()> {
let url = format!("https://api.telegram.org/bot{}/sendMessage", bot.token_str);
let params = serde_json::json!({"chat_id": bot.chat_id, "text": text});
post_telegram(url, params.to_string()).await?;
crate::post_request(url, params.to_string(), "").await?;
Ok(())
}
pub fn get_chatid_telegram(bot_token: &str) -> ResultType<Option<String>> {
let url = format!("https://api.telegram.org/bot{}/getUpdates", bot_token);
// because caller is in tokio runtime, so we must run the request in a new thread.
let handle = std::thread::spawn(move || -> ResultType<String> {
hbb_common::tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?
.block_on(post_telegram(url, String::new()))
});
// because caller is in tokio runtime, so we must call post_request_sync in new thread.
let handle = std::thread::spawn(move || crate::post_request_sync(url, "".to_owned(), ""));
let resp = handle.join().map_err(|_| anyhow!("Thread panicked"))??;
let value = serde_json::from_str::<serde_json::Value>(&resp).map_err(|e| anyhow!(e))?;
@@ -234,48 +202,3 @@ pub fn get_chatid_telegram(bot_token: &str) -> ResultType<Option<String>> {
Ok(chat_id)
}
#[cfg(test)]
mod tests {
use super::{post_telegram, TelegramBot};
use hbb_common::tokio::{self, net::TcpListener};
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
#[test]
fn telegram_bot_debug_redacts_both_token_fields() {
let bot = TelegramBot {
token_str: "test-telegram-token".to_owned(),
token: vec![17, 29, 43],
chat_id: "test-chat".to_owned(),
};
let debug = format!("{bot:?}");
assert!(!debug.contains(&bot.token_str));
assert!(!debug.contains(&format!("{:?}", bot.token)));
assert!(debug.contains(&bot.chat_id));
}
#[tokio::test]
async fn telegram_request_has_no_tls_fallback_and_hides_the_token() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let port = listener.local_addr().unwrap().port();
let attempts = Arc::new(AtomicUsize::new(0));
let counter = attempts.clone();
tokio::spawn(async move {
while let Ok((stream, _)) = listener.accept().await {
counter.fetch_add(1, Ordering::SeqCst);
drop(stream);
}
});
let token = "123456:test-telegram-token";
let url = format!("https://127.0.0.1:{port}/bot{token}/sendMessage");
let err = post_telegram(url, String::new()).await.unwrap_err();
assert!(!err.to_string().contains(token), "{err}");
assert_eq!(attempts.load(Ordering::SeqCst), 1);
}
}
-22
View File
@@ -758,26 +758,6 @@ impl<T: InvokeUiSession> Remote<T> {
match data {
Data::Close => {
self.send_close_reason(peer, "").await;
if peer.is_webrtc() {
// Reconnect starts the next round without waiting for this one, and that
// round reuses this peer's file clipboard channel. Give it up before the
// wait, or this round's cleanup removes the channel the next one is using.
#[cfg(any(target_os = "windows", feature = "unix-file-copy-paste"))]
clipboard::remove_channel_by_conn_id(self.client_conn_id);
// The next round also loads the saved transfer jobs as soon as it logs in.
// The wait discards what arrives, so the jobs no longer change after this.
let _ = self.sync_jobs_status_to_local().await;
// Makes the save on exit a no-op, so it cannot write these jobs over what a
// newer round saved in the meantime.
self.is_connected = false;
// Dropping the stream can discard the queued reason, and then the controlled
// side keeps this session for a password-free reconnect. It closes once it
// has read the reason.
let _ = tokio::time::timeout(Duration::from_secs(1), async {
while let Some(Ok(_)) = peer.next().await {}
})
.await;
}
return false;
}
Data::Login((os_username, os_password, password, remember)) => {
@@ -1719,7 +1699,6 @@ impl<T: InvokeUiSession> Remote<T> {
Some(message::Union::VideoFrame(vf)) => {
if !self.first_frame {
self.first_frame = true;
log::info!("Received first video frame");
self.handler.close_success();
self.handler.adapt_size();
self.send_toggle_virtual_display_msg(peer).await;
@@ -2375,7 +2354,6 @@ impl<T: InvokeUiSession> Remote<T> {
}
}
Some(misc::Union::CloseReason(c)) => {
log::info!("Received CloseReason from the controlled side: {c:?}");
self.sent_close_reason = true; // The controlled end will close, no need to send close reason
self.handler.msgbox("error", "Connection Error", &c, "");
return false;
-23
View File
@@ -408,14 +408,6 @@ impl ClipboardContext {
side: ClipboardSide,
force: bool,
) -> ResultType<Vec<ClipboardData>> {
#[cfg(all(feature = "unix-file-copy-paste", target_os = "macos"))]
{
if formats.iter().any(|f| matches!(f, ClipboardFormat::FileUrl))
&& clipboard::platform::unix::macos::has_rustdesk_file_url_owner()
{
return Ok(vec![]);
}
}
let _lock = ARBOARD_MTX.lock().unwrap();
let data = self.get_formats(formats)?;
if data.is_empty() {
@@ -520,21 +512,6 @@ impl ClipboardContext {
#[cfg(feature = "unix-file-copy-paste")]
fn try_empty_clipboard_files(&mut self, side: ClipboardSide) {
let _lock = ARBOARD_MTX.lock().unwrap();
#[cfg(all(feature = "unix-file-copy-paste", target_os = "macos"))]
{
if clipboard::platform::unix::macos::has_rustdesk_file_url_owner() {
if let Err(e) = self.inner.set_formats(&[
ClipboardData::Text("".to_string()),
ClipboardData::Special((
RUSTDESK_CLIPBOARD_OWNER_FORMAT.to_owned(),
side.get_owner_data(),
)),
]) {
log::error!("Failed to empty clipboard files: {}", e);
}
return;
}
}
if let Ok(data) = self.get_formats(&[ClipboardFormat::FileUrl]) {
let urls = Self::get_file_urls_set_by_rustdesk(data, side);
if !urls.is_empty() {
+2 -2
View File
@@ -193,7 +193,7 @@ impl Drop for KcpStream {
}
#[cfg(test)]
pub(crate) mod tests {
mod tests {
use super::*;
use std::time::Duration;
@@ -205,7 +205,7 @@ pub(crate) mod tests {
(Arc::new(a), Arc::new(b))
}
pub(crate) async fn establish() -> ((KcpStream, Stream), (KcpStream, Stream)) {
async fn establish() -> ((KcpStream, Stream), (KcpStream, Stream)) {
let (a, b) = connected_pair().await;
let (accept_res, connect_res) = tokio::join!(
KcpStream::accept(b, Duration::from_secs(5), None),
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "وضع لوحة المفاتيح"),
("Enable Unicode input", "تفعيل إدخال Unicode"),
("unicode-input-tip", "التقاط نص Unicode الذي ترسله أدوات مثل KeePassXC Auto-Type. يتطلب استخدام مصدر الإدخال 1."),
("Remote terminal access requires an active desktop session", "يتطلب الوصول إلى الطرفية عن بُعد جلسة سطح مكتب نشطة"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Klaviatura rejimi"),
("Enable Unicode input", "Unicode girişini aktivləşdir"),
("unicode-input-tip", "KeePassXC Auto-Type kimi alətlərin göndərdiyi Unicode mətnini tutun. Giriş mənbəyi 1 tələb olunur."),
("Remote terminal access requires an active desktop session", "Terminala uzaqdan daxil olmaq üçün aktiv masaüstü sessiyası tələb olunur"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Рэжым клавіятуры"),
("Enable Unicode input", "Уключыць увод Unicode"),
("unicode-input-tip", "Захопліваць тэкст Unicode, які дасылаюць інструменты накшталт KeePassXC Auto-Type. Патрабуецца крыніца ўводу 1."),
("Remote terminal access requires an active desktop session", "Для аддаленага доступу да тэрмінала патрэбны актыўны сеанс працоўнага стала"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Режим на клавиатурата"),
("Enable Unicode input", "Разрешаване на въвеждане на Unicode"),
("unicode-input-tip", "Прихващане на Unicode текст, изпратен от инструменти като KeePassXC Auto-Type. Изисква източник на въвеждане 1."),
("Remote terminal access requires an active desktop session", "За отдалечен достъп до терминала е необходима активна сесия на работния плот"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Mode de teclat"),
("Enable Unicode input", "Habilita l'entrada Unicode"),
("unicode-input-tip", "Captura el text Unicode enviat per eines com ara KeePassXC Auto-Type. Requereix la font d'entrada 1."),
("Remote terminal access requires an active desktop session", "Per accedir al terminal de manera remota cal una sessió d’escriptori activa"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "键盘模式"),
("Enable Unicode input", "启用 Unicode 输入"),
("unicode-input-tip", "捕获 KeePassXC 自动输入等工具发送的 Unicode 文本。需要使用输入源 1。"),
("Remote terminal access requires an active desktop session", "访问远程终端需要一个活动的桌面会话"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Režim klávesnice"),
("Enable Unicode input", "Povolit vstup Unicode"),
("unicode-input-tip", "Zachytávat text Unicode odesílaný nástroji, jako je KeePassXC Auto-Type. Vyžaduje zdroj vstupu 1."),
("Remote terminal access requires an active desktop session", "Pro vzdálený přístup k terminálu je potřeba aktivní relace pracovní plochy"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tastaturtilstand"),
("Enable Unicode input", "Aktivér Unicode-input"),
("unicode-input-tip", "Opfang Unicode-tekst sendt af værktøjer som KeePassXC Auto-Type. Kræver inputkilde 1."),
("Remote terminal access requires an active desktop session", "Fjernadgang til terminalen kræver en aktiv skrivebordssession"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tastaturmodus"),
("Enable Unicode input", "Unicode-Eingabe aktivieren"),
("unicode-input-tip", "Unicode-Text erfassen, der von Werkzeugen wie KeePassXC Auto-Type gesendet wird. Erfordert Eingabequelle 1."),
("Remote terminal access requires an active desktop session", "Der Fernzugriff auf das Terminal erfordert eine aktive Desktop-Sitzung"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Λειτουργία πληκτρολογίου"),
("Enable Unicode input", "Ενεργοποίηση εισαγωγής Unicode"),
("unicode-input-tip", "Λήψη κειμένου Unicode που αποστέλλεται από εργαλεία όπως το KeePassXC Auto-Type. Απαιτείται η πηγή εισόδου 1."),
("Remote terminal access requires an active desktop session", "Η απομακρυσμένη πρόσβαση στο τερματικό απαιτεί ενεργή συνεδρία επιφάνειας εργασίας"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Klavara reĝimo"),
("Enable Unicode input", "Ebligi Unicode-enigon"),
("unicode-input-tip", "Kapti Unicode-tekston senditan de iloj kiel KeePassXC Auto-Type. Postulas enigfonton 1."),
("Remote terminal access requires an active desktop session", "Fora aliro al la terminalo postulas aktivan labortablan seancon"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modo de teclado"),
("Enable Unicode input", "Habilitar la entrada Unicode"),
("unicode-input-tip", "Captura texto Unicode enviado por herramientas como KeePassXC Auto-Type. Requiere la fuente de entrada 1."),
("Remote terminal access requires an active desktop session", "Para acceder al terminal de forma remota se necesita una sesión de escritorio activa"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Klaviatuurirežiim"),
("Enable Unicode input", "Luba Unicode'i sisestus"),
("unicode-input-tip", "Püüa kinni selliste tööriistade nagu KeePassXC Auto-Type saadetud Unicode'i tekst. Nõuab sisendallikat 1."),
("Remote terminal access requires an active desktop session", "Kaugjuurdepääs terminalile nõuab aktiivset töölauaseanssi"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Teklatuaren modua"),
("Enable Unicode input", "Gaitu Unicode sarrera"),
("unicode-input-tip", "Atzeman KeePassXC Auto-Type bezalako tresnek bidalitako Unicode testua. 1. sarrera-iturria behar du."),
("Remote terminal access requires an active desktop session", "Terminalera urrunetik sartzeko, mahaigaineko saio aktibo bat behar da"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "حالت صفحه کلید"),
("Enable Unicode input", "فعال‌سازی ورودی Unicode"),
("unicode-input-tip", "متن Unicode ارسال‌شده توسط ابزارهایی مانند KeePassXC Auto-Type را دریافت می‌کند. به منبع ورودی 1 نیاز دارد."),
("Remote terminal access requires an active desktop session", "دسترسی از راه دور به ترمینال به یک نشست فعال دسکتاپ نیاز دارد"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Näppäimistötila"),
("Enable Unicode input", "Ota Unicode-syöte käyttöön"),
("unicode-input-tip", "Sieppaa työkalujen (esimerkiksi KeePassXC Auto-Type) lähettämää Unicode-tekstiä. Vaatii syötelähteen 1."),
("Remote terminal access requires an active desktop session", "Päätteen etäkäyttö edellyttää aktiivista työpöytäistuntoa"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Mode du clavier"),
("Enable Unicode input", "Activer la saisie Unicode"),
("unicode-input-tip", "Capturer le texte Unicode envoyé par des outils tels que KeePassXC Auto-Type. Nécessite la source d'entrée 1."),
("Remote terminal access requires an active desktop session", "L’accès à distance au terminal nécessite une session de bureau active"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "კლავიატურის რეჟიმი"),
("Enable Unicode input", "Unicode შეყვანის ჩართვა"),
("unicode-input-tip", "Unicode ტექსტის მიღება, რომელსაც აგზავნიან ისეთი ხელსაწყოები, როგორიცაა KeePassXC Auto-Type. საჭიროა შეყვანის წყარო 1."),
("Remote terminal access requires an active desktop session", "ტერმინალზე დისტანციური წვდომისთვის საჭიროა სამუშაო მაგიდის აქტიური სესია"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modo de teclado"),
("Enable Unicode input", "Activar a entrada Unicode"),
("unicode-input-tip", "Capturar o texto Unicode enviado por ferramentas como KeePassXC Auto-Type. Require a fonte de entrada 1."),
("Remote terminal access requires an active desktop session", "Para acceder ao terminal de forma remota cómpre ter unha sesión de escritorio activa"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "કીબોર્ડ મોડ"),
("Enable Unicode input", "Unicode ઇનપુટ સક્ષમ કરો"),
("unicode-input-tip", "KeePassXC Auto-Type જેવા સાધનો દ્વારા મોકલાયેલ Unicode લખાણ કૅપ્ચર કરો. ઇનપુટ સ્રોત 1 જરૂરી છે."),
("Remote terminal access requires an active desktop session", "ટર્મિનલને રિમોટ રીતે ઍક્સેસ કરવા માટે સક્રિય ડેસ્કટોપ સત્ર જરૂરી છે"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "מצב מקלדת"),
("Enable Unicode input", "אפשר קלט Unicode"),
("unicode-input-tip", "לכידת טקסט Unicode שנשלח מכלים כגון KeePassXC Auto-Type. נדרש מקור קלט 1."),
("Remote terminal access requires an active desktop session", "כדי לגשת למסוף מרחוק נדרשת הפעלת שולחן עבודה פעילה"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "कीबोर्ड मोड"),
("Enable Unicode input", "Unicode इनपुट सक्षम करें"),
("unicode-input-tip", "KeePassXC Auto-Type जैसे टूल द्वारा भेजे गए Unicode पाठ को कैप्चर करें। इसके लिए इनपुट स्रोत 1 आवश्यक है।"),
("Remote terminal access requires an active desktop session", "टर्मिनल तक दूरस्थ पहुँच के लिए एक सक्रिय डेस्कटॉप सत्र आवश्यक है"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Način rada tipkovnice"),
("Enable Unicode input", "Omogući Unicode unos"),
("unicode-input-tip", "Hvatanje Unicode teksta koji šalju alati poput KeePassXC Auto-Type. Potreban je izvor unosa 1."),
("Remote terminal access requires an active desktop session", "Za udaljeni pristup terminalu potrebna je aktivna sesija radne površine"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Billentyűzetmód"),
("Enable Unicode input", "Unicode-bevitel engedélyezése"),
("unicode-input-tip", "Az olyan eszközök által küldött Unicode-szöveg rögzítése, mint a KeePassXC Auto-Type. Az 1. bemeneti forrást igényli."),
("Remote terminal access requires an active desktop session", "A terminál távoli eléréséhez aktív asztali munkamenet szükséges"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Mode papan ketik"),
("Enable Unicode input", "Aktifkan input Unicode"),
("unicode-input-tip", "Tangkap teks Unicode yang dikirim oleh alat seperti KeePassXC Auto-Type. Memerlukan sumber input 1."),
("Remote terminal access requires an active desktop session", "Akses terminal jarak jauh memerlukan sesi desktop yang aktif"),
].iter().cloned().collect();
}
+3 -4
View File
@@ -830,9 +830,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("drm-capture-tip", "Cattura lo schermo direttamente dalla scheda grafica tramite il servizio RustDesk, senza il prompt di condivisione dello schermo Wayland, anche al login schermo. Potrebbe non funzionare con tutti i dispositivi; se le connessioni chiedono ancora di condividere lo schermo, disabilita questa opzione o usa X11. La modifica di questa opzione disconnetterà le sessioni attuali."),
("wayland-drm-tip", "Per l'accesso non presidiato in Wayland, prova 'Cattura schermo DRM', o se non funziona usa X11."),
("login-wayland-drm-tip", "Per accedere alla schermata di accesso Wayland, prova 'Cattura schermo DRM' o passa a X11."),
("Keyboard mode", "Modo tastiera"),
("Enable Unicode input", "Abilita input Unicode"),
("unicode-input-tip", "Cattura testo Unicode inviato da strumenti come KeePassXC Auto-Type. Richiede input sorgente 1."),
("Remote terminal access requires an active desktop session", ""),
("Keyboard mode", ""),
("Enable Unicode input", ""),
("unicode-input-tip", ""),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "キーボードモード"),
("Enable Unicode input", "Unicode 入力を有効にする"),
("unicode-input-tip", "KeePassXC Auto-Type などのツールが送信する Unicode テキストを取り込みます。入力ソース 1 が必要です。"),
("Remote terminal access requires an active desktop session", "ターミナルへのリモートアクセスには、アクティブなデスクトップセッションが必要です"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "키보드 모드"),
("Enable Unicode input", "Unicode 입력 활성화"),
("unicode-input-tip", "KeePassXC Auto-Type 같은 도구가 보내는 Unicode 텍스트를 캡처합니다. 입력 소스 1이 필요합니다."),
("Remote terminal access requires an active desktop session", "터미널에 원격으로 접속하려면 활성 데스크톱 세션이 필요합니다"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Пернетақта режимі"),
("Enable Unicode input", "Unicode енгізуін қосу"),
("unicode-input-tip", "KeePassXC Auto-Type сияқты құралдар жіберген Unicode мәтінін қабылдау. Енгізу көзі 1 қажет."),
("Remote terminal access requires an active desktop session", "Терминалға қашықтан қол жеткізу үшін белсенді жұмыс үстелі сеансы қажет"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Klaviatūros režimas"),
("Enable Unicode input", "Įgalinti Unicode įvestį"),
("unicode-input-tip", "Perimti Unicode tekstą, kurį siunčia tokie įrankiai kaip KeePassXC Auto-Type. Reikalingas įvesties šaltinis 1."),
("Remote terminal access requires an active desktop session", "Nuotolinei prieigai prie terminalo reikia aktyvaus darbalaukio seanso"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tastatūras režīms"),
("Enable Unicode input", "Iespējot Unicode ievadi"),
("unicode-input-tip", "Pārtvert Unicode tekstu, ko nosūta tādi rīki kā KeePassXC Auto-Type. Nepieciešams ievades avots 1."),
("Remote terminal access requires an active desktop session", "Lai attālināti piekļūtu terminālim, ir nepieciešama aktīva darbvirsmas sesija"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "കീബോർഡ് മോഡ്"),
("Enable Unicode input", "Unicode ഇൻപുട്ട് പ്രവർത്തനക്ഷമമാക്കുക"),
("unicode-input-tip", "KeePassXC Auto-Type പോലുള്ള ഉപകരണങ്ങൾ അയയ്ക്കുന്ന Unicode ടെക്സ്റ്റ് ക്യാപ്‌ചർ ചെയ്യുക. ഇൻപുട്ട് ഉറവിടം 1 ആവശ്യമാണ്."),
("Remote terminal access requires an active desktop session", "ടെർമിനൽ വിദൂരമായി ആക്‌സസ് ചെയ്യാൻ സജീവമായ ഒരു ഡെസ്ക്ടോപ്പ് സെഷൻ ആവശ്യമാണ്"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tastaturmodus"),
("Enable Unicode input", "Aktiver Unicode-inndata"),
("unicode-input-tip", "Fang opp Unicode-tekst som sendes av verktøy som KeePassXC Auto-Type. Krever inndatakilde 1."),
("Remote terminal access requires an active desktop session", "Fjerntilgang til terminalen krever en aktiv skrivebordsøkt"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Toetsenbordmodus"),
("Enable Unicode input", "Unicode-invoer inschakelen"),
("unicode-input-tip", "Unicode-tekst opvangen die wordt verzonden door hulpmiddelen zoals KeePassXC Auto-Type. Vereist invoerbron 1."),
("Remote terminal access requires an active desktop session", "Voor toegang op afstand tot de terminal is een actieve bureaubladsessie vereist"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tryb klawiatury"),
("Enable Unicode input", "Włącz wprowadzanie Unicode"),
("unicode-input-tip", "Przechwytuj tekst Unicode wysyłany przez narzędzia takie jak KeePassXC Auto-Type. Wymaga źródła wejścia 1."),
("Remote terminal access requires an active desktop session", "Zdalny dostęp do terminala wymaga aktywnej sesji pulpitu"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modo do teclado"),
("Enable Unicode input", "Habilitar entrada Unicode"),
("unicode-input-tip", "Captura texto Unicode enviado por ferramentas como o KeePassXC Auto-Type. Requer a fonte de entrada 1."),
("Remote terminal access requires an active desktop session", "O acesso remoto ao terminal requer uma sessão ativa da área de trabalho"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modo do teclado"),
("Enable Unicode input", "Ativar entrada Unicode"),
("unicode-input-tip", "Captura texto Unicode enviado por ferramentas como o KeePassXC Auto-Type. Requer a fonte de entrada 1."),
("Remote terminal access requires an active desktop session", "O acesso remoto ao terminal requer uma sessão ativa do ambiente de trabalho"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Mod tastatură"),
("Enable Unicode input", "Activează introducerea Unicode"),
("unicode-input-tip", "Capturează textul Unicode trimis de instrumente precum KeePassXC Auto-Type. Necesită sursa de intrare 1."),
("Remote terminal access requires an active desktop session", "Accesul de la distanță la terminal necesită o sesiune desktop activă"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Режим клавиатуры"),
("Enable Unicode input", "Включить ввод Unicode"),
("unicode-input-tip", "Перехватывать текст Unicode, отправляемый такими инструментами, как KeePassXC Auto-Type. Требуется источник ввода 1."),
("Remote terminal access requires an active desktop session", "Для удалённого доступа к терминалу нужен активный сеанс рабочего стола"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modalidade de tecladu"),
("Enable Unicode input", "Abìlita s'intrada Unicode"),
("unicode-input-tip", "Catura su testu Unicode imbiadu dae ainas comente KeePassXC Auto-Type. Bisòngiat sa mitza de intrada 1."),
("Remote terminal access requires an active desktop session", "Pro acèdere a su terminale dae tesu serbit una sessione de iscrivania ativa"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Režim klávesnice"),
("Enable Unicode input", "Povoliť vstup Unicode"),
("unicode-input-tip", "Zachytávať text Unicode odosielaný nástrojmi, ako je KeePassXC Auto-Type. Vyžaduje sa zdroj vstupu 1."),
("Remote terminal access requires an active desktop session", "Vzdialený prístup k terminálu vyžaduje aktívnu reláciu pracovnej plochy"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Način tipkovnice"),
("Enable Unicode input", "Omogoči vnos Unicode"),
("unicode-input-tip", "Zajemi besedilo Unicode, ki ga pošiljajo orodja, kot je KeePassXC Auto-Type. Zahteva vir vnosa 1."),
("Remote terminal access requires an active desktop session", "Za oddaljeni dostop do terminala je potrebna aktivna seja namizja"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Modaliteti i tastierës"),
("Enable Unicode input", "Aktivizo hyrjen Unicode"),
("unicode-input-tip", "Kap tekstin Unicode të dërguar nga mjete si KeePassXC Auto-Type. Kërkon burimin e hyrjes 1."),
("Remote terminal access requires an active desktop session", "Për të hyrë në terminal nga larg, nevojitet një sesion aktiv i desktopit"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Režim tastature"),
("Enable Unicode input", "Omogući Unicode unos"),
("unicode-input-tip", "Hvatanje Unicode teksta koji šalju alati kao što je KeePassXC Auto-Type. Zahteva izvor unosa 1."),
("Remote terminal access requires an active desktop session", "Za udaljeni pristup terminalu potrebna je aktivna sesija radne površine"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Tangentbordsläge"),
("Enable Unicode input", "Aktivera Unicode-inmatning"),
("unicode-input-tip", "Fånga Unicode-text som skickas av verktyg som KeePassXC Auto-Type. Kräver inmatningskälla 1."),
("Remote terminal access requires an active desktop session", "Fjärråtkomst till terminalen kräver en aktiv skrivbordssession"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "விசைப்பலகை முறை"),
("Enable Unicode input", "Unicode உள்ளீட்டை இயக்கு"),
("unicode-input-tip", "KeePassXC Auto-Type போன்ற கருவிகள் அனுப்பும் Unicode உரையைப் பிடிக்கவும். உள்ளீட்டு மூலம் 1 தேவை."),
("Remote terminal access requires an active desktop session", "முனையத்தைத் தொலைவிலிருந்து அணுக, செயலில் உள்ள டெஸ்க்டாப் அமர்வு தேவை"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", ""),
("Enable Unicode input", ""),
("unicode-input-tip", ""),
("Remote terminal access requires an active desktop session", ""),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "โหมดคีย์บอร์ด"),
("Enable Unicode input", "เปิดใช้งานการป้อนข้อมูล Unicode"),
("unicode-input-tip", "จับข้อความ Unicode ที่ส่งจากเครื่องมือ เช่น KeePassXC Auto-Type โดยต้องใช้แหล่งป้อนข้อมูล 1"),
("Remote terminal access requires an active desktop session", "การเข้าถึงเทอร์มินัลจากระยะไกลต้องใช้เซสชันเดสก์ท็อปที่กำลังใช้งานอยู่"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Klavye modu"),
("Enable Unicode input", "Unicode girişini etkinleştir"),
("unicode-input-tip", "KeePassXC Auto-Type gibi araçların gönderdiği Unicode metnini yakalar. Giriş kaynağı 1 gerektirir."),
("Remote terminal access requires an active desktop session", "Terminale uzaktan erişim için etkin bir masaüstü oturumu gerekir"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "鍵盤模式"),
("Enable Unicode input", "啟用 Unicode 輸入"),
("unicode-input-tip", "擷取 KeePassXC 自動輸入等工具傳送的 Unicode 文字。需要使用輸入來源 1。"),
("Remote terminal access requires an active desktop session", "若要存取遠端終端機,必須有作用中的桌面工作階段"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Режим клавіатури"),
("Enable Unicode input", "Увімкнути введення Unicode"),
("unicode-input-tip", "Перехоплювати текст Unicode, надісланий такими інструментами, як KeePassXC Auto-Type. Потрібне джерело введення 1."),
("Remote terminal access requires an active desktop session", "Для віддаленого доступу до термінала потрібен активний сеанс стільниці"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "کی بورڈ موڈ"),
("Enable Unicode input", "Unicode ان پٹ کو فعال کریں"),
("unicode-input-tip", "KeePassXC Auto-Type جیسے ٹولز کے بھیجے گئے Unicode متن کو کیپچر کریں۔ ان پٹ کا ماخذ 1 درکار ہے۔"),
("Remote terminal access requires an active desktop session", "ٹرمینل تک ریموٹ رسائی کے لیے ایک فعال ڈیسک ٹاپ سیشن درکار ہے"),
].iter().cloned().collect();
}
-1
View File
@@ -833,6 +833,5 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Keyboard mode", "Chế độ bàn phím"),
("Enable Unicode input", "Bật đầu vào Unicode"),
("unicode-input-tip", "Thu nhận văn bản Unicode do các công cụ như KeePassXC Auto-Type gửi đến. Yêu cầu nguồn đầu vào 1."),
("Remote terminal access requires an active desktop session", "Cần có một phiên màn hình nền đang hoạt động để truy cập terminal từ xa"),
].iter().cloned().collect();
}
+13 -107
View File
@@ -2,8 +2,6 @@ use super::{gtk_sudo, CursorData, ResultType};
use desktop::Desktop;
pub use base::platform::linux::*;
pub(crate) mod terminal;
#[cfg(feature = "drm")]
pub fn dispatch_wayland_display_probe() {
use std::ffi::OsStr;
@@ -1091,16 +1089,9 @@ mod audio_latency_env_tests {
}
}
const LOGIND_SESSION_ARG: &str = "--logind-session=";
#[inline]
fn try_start_server_(desktop: Option<&Desktop>) -> ResultType<Option<Child>> {
let session = desktop
.map_or(Some(""), Desktop::root_server_session)
.map(|id| format!("{LOGIND_SESSION_ARG}{id}"));
let mut args = vec!["--server"];
args.extend(session.as_deref());
match desktop.filter(|desktop| !desktop.uses_service_environment()) {
match desktop {
Some(desktop) => {
let mut envs = vec![];
if !desktop.display.is_empty() {
@@ -1140,22 +1131,17 @@ fn try_start_server_(desktop: Option<&Desktop>) -> ResultType<Option<Child>> {
get_cur_term(&desktop.uid).unwrap_or_else(|| suggest_best_term()),
));
run_as_user(
args,
vec!["--server"],
Some((desktop.uid.clone(), desktop.username.clone())),
envs,
)
}
None => Ok(Some(crate::run_me(args)?)),
None => Ok(Some(crate::run_me(vec!["--server"])?)),
}
}
#[inline]
fn start_server(desktop: Option<&Desktop>, server: &mut Option<Child>) {
// should_start_server checked before force_stop_server() and the DRM greeter grace, so a
// sleep requested in between would otherwise still get a --server.
if is_system_preparing_for_sleep() {
return;
}
match try_start_server_(desktop) {
Ok(ps) => *server = ps,
Err(err) => {
@@ -1289,47 +1275,10 @@ fn should_start_server(
} else {
start_new = true;
}
if start_new && is_system_preparing_for_sleep() {
start_new = false;
}
*cm0 = cm;
start_new
}
// A --server started while the system enters sleep probes the GPU encoders, and NVENC init during
// suspend entry can hang the NVIDIA driver (#17208). logind keeps PreparingForSleep set from the
// sleep request until the system has resumed, so the start is retried by the loop after wake.
fn is_system_preparing_for_sleep() -> bool {
use dbus::blocking::{stdintf::org_freedesktop_dbus::Properties, Connection};
let preparing = Connection::new_system().and_then(|conn| {
conn.with_proxy(
"org.freedesktop.login1",
"/org/freedesktop/login1",
Duration::from_secs(1),
)
.get::<bool>("org.freedesktop.login1.Manager", "PreparingForSleep")
});
match preparing {
Ok(true) => {
hbb_common::throttled_log!(
Duration::from_secs(60),
info,
"system is preparing for sleep; --server starts after wake"
);
true
}
Ok(false) => false,
Err(err) => {
hbb_common::throttled_log!(
Duration::from_secs(600),
warn,
"failed to read logind PreparingForSleep: {err}"
);
false
}
}
}
// to-do: stop_server(&mut user_server); may not stop child correctly
// stop_rustdesk_servers() is just a temp solution here.
fn force_stop_server() {
@@ -1380,16 +1329,14 @@ pub fn start_os_service() {
update_active_user_lookup_cache(&desktop);
// Duplicate logic here with should_start_server.
let root_desktop = desktop.uses_service_environment().then_some(&desktop);
let root_session_changed = desktop.uid == "0" && sid != desktop.sid;
if root_desktop.is_some() || desktop.is_login_wayland() {
if desktop.username == "root" || desktop.is_login_wayland() {
// try kill subprocess "--server"
stop_server(&mut user_server);
// try start subprocess "--server"
// A switch between root logins needs a new server bound to the selected session.
// No need to check is_display_changed here.
if should_start_server(
true,
root_session_changed,
false,
&mut uid,
&desktop,
&mut cm0,
@@ -1403,13 +1350,14 @@ pub fn start_os_service() {
// SDDM Wayland greeter (is_gdm_user covers both) or a greetd one (tty_greeter), and
// desktop.uid is that greeter's uid, so this drops to whichever greeter owns seat0.
// A greeter neither recognizes (e.g. LightDM) never reaches this branch -- it takes
// the unprivileged else-branch below already. A genuine root graphical session (UID 0)
// the unprivileged else-branch below already. A genuine root graphical session (username=="root")
// has no lower uid to drop to, so it stays root. The whole branch is gated on the drm
// feature and on allow-drm-capture. Only a root desktop supplies a session ID for terminals.
// feature and on allow-drm-capture; otherwise it is upstream's single
// `start_server(None, ..)` line.
#[cfg(not(feature = "drm"))]
start_server(root_desktop, &mut server);
start_server(None, &mut server);
#[cfg(feature = "drm")]
if drm_capture_enabled() && root_desktop.is_none() && !desktop.uid.is_empty() {
if drm_capture_enabled() && desktop.username != "root" && !desktop.uid.is_empty() {
start_server(Some(&desktop), &mut server);
// If dropping to the greeter uid did not produce a RUNNING server, fall back to a
// root --server so the login screen stays remotable instead of looping on a
@@ -1427,15 +1375,14 @@ pub fn start_os_service() {
start_server(None, &mut server);
}
} else {
start_server(root_desktop, &mut server);
start_server(None, &mut server);
}
}
} else if desktop.username != "" {
// try kill subprocess "--server"
stop_server(&mut server);
let is_display_changed =
root_session_changed || desktop.display != display || desktop.xauth != xauth;
let is_display_changed = desktop.display != display || desktop.xauth != xauth;
display = desktop.display.clone();
xauth = desktop.xauth.clone();
@@ -2502,22 +2449,6 @@ mod desktop {
super::is_gdm_user(&self.username) && self.protocol == DISPLAY_SERVER_WAYLAND
}
/// An empty session ID marks a privileged greeter and denies its terminal.
pub(super) fn root_server_session(&self) -> Option<&str> {
if self.uid != "0" {
return None;
}
if self.username.is_empty() || self.is_login_wayland() {
Some("")
} else {
Some(&self.sid)
}
}
pub(super) fn uses_service_environment(&self) -> bool {
self.uid == "0" && (self.username == "root" || self.is_login_wayland())
}
/// The greeter's compositor creates its socket after logind has registered the session,
/// so a greeter first seen without one is asked again on every refresh until it has one.
/// Every compositor variable is dropped, not only the x11 values guessed meanwhile: going
@@ -2957,31 +2888,6 @@ mod desktop {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn uid_zero_alias_binds_terminal_to_its_desktop() {
let session = |uid: &str, username: &str, protocol: &str| Desktop {
sid: "8".into(),
uid: uid.into(),
username: username.into(),
protocol: protocol.into(),
..Desktop::default()
};
let admin = session("0", "desktop-admin", DISPLAY_SERVER_WAYLAND);
assert_eq!(admin.root_server_session(), Some("8"));
assert!(!admin.uses_service_environment());
assert!(session("0", "root", DISPLAY_SERVER_WAYLAND).uses_service_environment());
let user = session("1000", "root", DISPLAY_SERVER_X11);
assert_eq!(user.root_server_session(), None);
let greeter = session("0", "gdm", DISPLAY_SERVER_WAYLAND);
assert_eq!(greeter.root_server_session(), Some(""));
assert!(greeter.uses_service_environment());
}
}
}
/// A session-bus idle-inhibit interface, tried in order; the first that answers wins.
-262
View File
@@ -1,262 +0,0 @@
use super::{CMD_LOGINCTL, LOGIND_SESSION_ARG};
use dbus::{
blocking::{stdintf::org_freedesktop_dbus::Properties, Connection},
Path,
};
use hbb_common::{
anyhow::{ensure, Context},
timeout, tokio, users, whoami, ResultType,
};
const SESSION_LOOKUP_TIMEOUT_MS: u64 = 2_000;
const DBUS_TIMEOUT: std::time::Duration =
std::time::Duration::from_millis(SESSION_LOOKUP_TIMEOUT_MS);
const LOGIN1: &str = "org.freedesktop.login1";
const LOGIN1_PATH: &str = "/org/freedesktop/login1";
pub(crate) async fn is_allowed() -> ResultType<bool> {
let arg = std::env::args_os().nth(2).unwrap_or_default();
let selector = logind_selector(arg.to_str().filter(|_| crate::is_server()));
session_allows_terminal(users::get_effective_uid(), selector).await
}
fn logind_selector(arg: Option<&str>) -> Option<&str> {
match arg.and_then(|arg| arg.strip_prefix(LOGIND_SESSION_ARG)) {
Some("") => None, // The service explicitly marked a greeter fallback.
None => Some(""), // Even on logind v237, an empty selector means the caller's own session.
Some(id) => Some(id),
}
}
async fn session_allows_terminal(uid: u32, selector: Option<&str>) -> ResultType<bool> {
if uid != 0 {
return Ok(true);
}
let Some(id) = selector else { return Ok(false) };
let mut cmd = tokio::process::Command::new(CMD_LOGINCTL.as_str());
cmd.kill_on_drop(true).args(["show-session", "--all"]);
for field in [
"Id", "User", "Class", "State", "Remote", "Seat", "Type", "Display",
] {
cmd.args(["-p", field]);
}
cmd.args(["--", id]);
let output = timeout(SESSION_LOOKUP_TIMEOUT_MS, cmd.output())
.await
.context("loginctl show-session timed out")?
.context("could not run loginctl show-session")?;
let status = output.status;
ensure!(
status.success(),
"loginctl show-session failed ({status}): {}",
String::from_utf8_lossy(&output.stderr).trim_end()
);
let properties = std::str::from_utf8(&output.stdout)?;
let display = std::env::var("DISPLAY").ok();
let check = root_desktop_display(properties, id, display.as_deref());
verify_display(check, local_x11_session).await
}
enum DisplayCheck<'a> {
Matched,
SocketSession { number: u32, session: &'a str },
}
fn root_desktop_display<'a>(
properties: &'a str,
id: &str,
display: Option<&str>,
) -> Option<DisplayCheck<'a>> {
let value = |key: &str| {
let mut fields = properties.lines().filter_map(|line| line.strip_prefix(key));
let first = fields.next()?;
fields.next().is_none().then_some(first)
};
if (!id.is_empty() && value("Id=")? != id)
|| value("User=")? != "0"
// Active stays yes while a logging-out session still holds the seat; State is closing then.
|| value("State=")? != "active"
|| value("Remote=")? != "no"
|| value("Seat=")?.is_empty()
|| !matches!(
value("Class=")?,
"user" | "user-early" | "user-light" | "user-early-light"
)
{
return None;
}
match value("Type=")? {
"wayland" => Some(DisplayCheck::Matched),
"x11" => {
let server = x11_server(display?)?;
match value("Display=")? {
// GDM on Xorg can leave Display empty on an active graphical session.
"" if server.0.is_empty() && server.1.bytes().all(|b| b.is_ascii_digit()) => {
Some(DisplayCheck::SocketSession {
number: server.1.parse().ok()?,
session: value("Id=").filter(|id| !id.is_empty())?,
})
}
expected if x11_server(expected) == Some(server) => Some(DisplayCheck::Matched),
_ => None,
}
}
_ => None,
}
}
async fn verify_display<F>(
check: Option<DisplayCheck<'_>>,
socket_session: impl FnOnce(u32) -> F,
) -> ResultType<bool>
where
F: std::future::Future<Output = ResultType<String>>,
{
match check {
Some(DisplayCheck::Matched) => Ok(true),
Some(DisplayCheck::SocketSession { number, session }) => {
Ok(socket_session(number).await? == session)
}
None => Ok(false),
}
}
async fn local_x11_session(number: u32) -> ResultType<String> {
timeout(SESSION_LOOKUP_TIMEOUT_MS, async {
let (pid, _socket) = local_x11_peer(number).await?;
tokio::task::spawn_blocking(move || x11_peer_logind_session(pid)).await?
})
.await
.context("X11 session lookup timed out")?
}
async fn local_x11_peer(number: u32) -> ResultType<(u32, tokio::net::UnixStream)> {
use std::io::ErrorKind::{ConnectionRefused, NotFound};
let path = format!("/tmp/.X11-unix/X{number}");
let mut peer = None;
// X11 transports can use either name. If both exist, they must identify the same server.
for name in [format!("\0{path}"), path] {
let socket = match tokio::net::UnixStream::connect(name).await {
Ok(socket) => socket,
Err(err) if matches!(err.kind(), NotFound | ConnectionRefused) => continue,
Err(err) => return Err(err.into()),
};
let cred = socket.peer_cred()?;
ensure!(cred.uid() == 0, "local X11 peer does not run as root");
let pid = cred
.pid()
.filter(|&p| p > 0)
.context("local X11 socket has no peer PID")? as u32;
if let Some((previous, _)) = &peer {
ensure!(*previous == pid, "local X11 sockets have different peers");
} else {
peer = Some((pid, socket));
}
}
peer.context("no local X11 socket for the root desktop")
}
fn x11_peer_logind_session(pid: u32) -> ResultType<String> {
let bus = Connection::new_system()?;
let manager = bus.with_proxy(LOGIN1, LOGIN1_PATH, DBUS_TIMEOUT);
let (path,): (Path<'static>,) =
manager.method_call("org.freedesktop.login1.Manager", "GetSessionByPID", (pid,))?;
let session = bus.with_proxy(LOGIN1, path, DBUS_TIMEOUT);
const SESSION: &str = "org.freedesktop.login1.Session";
let id = session.get(SESSION, "Id")?;
ensure!(
session.get::<String>(SESSION, "State")? == "active",
"local X11 peer session is not active"
);
Ok(id)
}
fn x11_server(display: &str) -> Option<(&str, &str)> {
let (host, number) = display.rsplit_once(':')?;
let number = number.split('.').next()?;
let local = matches!(host, "" | "unix" | "unix/")
|| whoami::fallible::hostname().ok().as_deref() == Some(host);
(!number.is_empty()).then_some((if local { "" } else { host }, number))
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn greeter_fallback_denies_only_root_terminals() {
let fallback = logind_selector(Some(LOGIND_SESSION_ARG));
assert_eq!(fallback, None);
assert!(!session_allows_terminal(0, fallback).await.unwrap());
assert!(session_allows_terminal(117, fallback).await.unwrap());
assert_eq!(logind_selector(None), Some(""));
assert_eq!(logind_selector(Some("--logind-session=7")), Some("7"));
}
#[tokio::test]
async fn gdm_x11_with_empty_display_can_authorize_its_own_root_desktop() {
let session =
"Id=8\nUser=0\nClass=user\nSeat=seat0\nState=active\nRemote=no\nType=x11\nDisplay=";
for (display, peer_session, allowed) in [
(":1", "8", true),
("unix/:1", "8", true),
("unix/:1", "9", false),
] {
let check = root_desktop_display(session, "8", Some(display));
let result = verify_display(check, |number| {
assert_eq!(number, 1);
std::future::ready(Ok(peer_session.to_owned()))
})
.await
.unwrap();
assert_eq!(result, allowed);
}
assert!(root_desktop_display(session, "8", Some("remote:1")).is_none());
for invalid in [
session.replace("Class=user", "Class=greeter"),
session.replace("\nDisplay=", ""),
format!("{session}\nDisplay="),
] {
assert!(root_desktop_display(&invalid, "8", Some(":1")).is_none());
}
}
#[test]
fn root_terminal_requires_its_own_local_desktop() {
let is_active_root_desktop =
|props: &str, id: &str, display: Option<&str>| match root_desktop_display(
props, id, display,
) {
Some(DisplayCheck::Matched) => true,
None => false,
Some(DisplayCheck::SocketSession { .. }) => panic!("unexpected X11 socket check"),
};
let session = "Id=7\nUser=0\nClass=user\nSeat=seat1\nState=active\nRemote=no";
let hostname = whoami::fallible::hostname().unwrap();
let x11 = format!("{session}\nType=x11\nDisplay={hostname}:0");
assert!(is_active_root_desktop(&x11, "7", Some(":0.0")));
assert!(is_active_root_desktop(&x11, "7", Some("unix/:0.0")));
assert!(!is_active_root_desktop(&x11, "7", Some("tcp/:0")));
assert!(!is_active_root_desktop(&x11, "8", Some(":0")));
assert!(!is_active_root_desktop(&x11, "", Some(":1")));
assert!(!is_active_root_desktop(
&format!("{session}\nType=x11"),
"7",
None
));
let other_host = format!("other.{hostname}:0");
assert!(!is_active_root_desktop(&x11, "7", Some(&other_host)));
let wayland = format!("{session}\nType=wayland");
assert!(is_active_root_desktop(&wayland, "", None));
let greeter = wayland.replace("Class=user", "Class=greeter");
assert!(!is_active_root_desktop(&greeter, "7", None));
// logind during a logout: still the seat's active session, but closing.
let logging_out = wayland.replace("State=active", "Active=yes\nState=closing");
assert!(!is_active_root_desktop(&logging_out, "7", None));
for required in session.lines() {
let missing = wayland.replace(required, "");
assert!(!is_active_root_desktop(&missing, "7", None), "{required}");
}
}
}
+6 -71
View File
@@ -32,7 +32,6 @@ use winapi::{
pub(super) const PRIVACY_MODE_IMPL: &str = super::PRIVACY_MODE_IMPL_WIN_VIRTUAL_DISPLAY;
const CONFIG_KEY_REG_RECOVERY: &str = base::config::keys::OPTION_REG_RECOVERY;
const ADDED_DISPLAY: &str = "added_display";
const STATE_CHECK_LOG_INTERVAL: Duration = Duration::from_secs(60);
fn check_active_displays(displays: impl Iterator<Item = DISPLAY_DEVICEW>) -> ResultType<()> {
@@ -138,11 +137,6 @@ struct Display {
primary: bool,
}
fn decode_display_name(name: &[WCHAR]) -> Result<String, std::string::FromUtf16Error> {
let end = name.iter().position(|&c| c == 0).unwrap_or(name.len());
String::from_utf16(&name[..end])
}
pub struct PrivacyModeImpl {
impl_key: String,
conn_id: i32,
@@ -198,7 +192,8 @@ impl PrivacyModeImpl {
let mut i: DWORD = 0;
loop {
let mut dd: DISPLAY_DEVICEW = unsafe { std::mem::zeroed() };
#[allow(invalid_value)]
let mut dd: DISPLAY_DEVICEW = unsafe { std::mem::MaybeUninit::uninit().assume_init() };
dd.cb = std::mem::size_of::<DISPLAY_DEVICEW>() as _;
let ok = unsafe { EnumDisplayDevicesW(std::ptr::null(), i, &mut dd as _, 0) };
if ok == FALSE {
@@ -279,7 +274,7 @@ impl PrivacyModeImpl {
fn set_primary_display(&mut self) -> ResultType<String> {
// Multiple virtual displays with different origins are tested.
let display = &self.virtual_displays[0];
let display_name = decode_display_name(&display.name)?;
let display_name = std::string::String::from_utf16(&display.name)?;
#[allow(invalid_value)]
let mut new_primary_dm: DEVMODEW = unsafe { std::mem::MaybeUninit::uninit().assume_init() };
@@ -606,15 +601,9 @@ impl PrivacyMode for PrivacyModeImpl {
));
let reg_connectivity_2 = reg_display_settings::read_reg_connectivity()?;
let registry =
reg_display_settings::diff_recent_connectivity(reg_connectivity_1, reg_connectivity_2);
// Amyuni reports index zero for every monitor. Only a sole display can be identified here.
let added_display = (virtual_display_manager::is_amyuni_idd()
&& !guard.virtual_displays_added.is_empty()
&& guard.virtual_displays.len() == 1)
.then_some(primary_display_name.as_str());
let reg_recovery = display_recovery_value(registry, added_display)?;
if !reg_recovery.is_null() {
if let Some(reg_recovery) =
reg_display_settings::diff_recent_connectivity(reg_connectivity_1, reg_connectivity_2)
{
Config::set_option(
CONFIG_KEY_REG_RECOVERY.to_owned(),
serde_json::to_string(&reg_recovery)?,
@@ -681,30 +670,6 @@ impl Drop for PrivacyModeImpl {
}
}
fn display_recovery_value(
registry: Option<reg_display_settings::RegRecovery>,
added_display: Option<&str>,
) -> serde_json::Result<serde_json::Value> {
let mut record = serde_json::to_value(registry)?;
if let Some(name) = added_display {
record[ADDED_DISPLAY] = name.into();
}
Ok(record)
}
fn recover_added_display(value: &str) -> ResultType<()> {
if !virtual_display_manager::is_amyuni_idd() {
return Ok(());
}
let mut fields: serde_json::Map<_, _> = serde_json::from_str(value)?;
let display: Option<String> =
serde_json::from_value(fields.remove(ADDED_DISPLAY).unwrap_or_default())?;
if let Some(name) = display {
virtual_display_manager::amyuni_idd::recover_privacy_monitor(&name)?;
}
Ok(())
}
#[inline]
fn reset_config_reg_connectivity() {
Config::set_option(CONFIG_KEY_REG_RECOVERY.to_owned(), "".to_owned());
@@ -717,9 +682,6 @@ pub fn restore_reg_connectivity(plug_out_monitors: bool, force: bool) {
}
if plug_out_monitors {
let _ = virtual_display_manager::plug_out_monitor(-1, true, false);
if let Err(err) = recover_added_display(&config_recovery_value) {
log::error!("Failed to recover the privacy mode display: {err}");
}
}
if let Ok(reg_recovery) =
serde_json::from_str::<reg_display_settings::RegRecovery>(&config_recovery_value)
@@ -736,33 +698,6 @@ mod tests {
use super::*;
use hbb_common::tokio::sync::mpsc::{error::TryRecvError, unbounded_channel};
#[test]
fn display_name_ends_at_the_first_nul() {
let name = r"\\.\DISPLAY2";
let mut buffer: Vec<_> = name.encode_utf16().collect();
buffer.extend([0, 0xd800]);
assert_eq!(decode_display_name(&buffer).unwrap(), name);
}
#[test]
fn display_recovery_preserves_legacy_registry_fields() {
let name = "DISPLAY2";
let combined = serde_json::json!({
"path": "monitor", "key": "Recent", "old": [[1], 3], "new": [[2], 3],
"added_display": name
});
let registry = serde_json::from_value(combined.clone()).unwrap();
assert_eq!(
display_recovery_value(Some(registry), Some(name)).unwrap(),
combined
);
assert_eq!(
display_recovery_value(None, Some(name)).unwrap(),
serde_json::json!({"added_display": name})
);
assert!(display_recovery_value(None, None).unwrap().is_null());
}
#[test]
fn privacy_mode_checks_active_displays() {
let virtual_name = virtual_display_manager::get_cur_device_string();
+43 -6
View File
@@ -37,6 +37,8 @@ use crate::{
server::{check_zombie, new as new_server, ConnectionMeta, ServerPtr},
};
mod seal_state;
type Message = RendezvousMessage;
const FAST_RETRY_TIMEOUT: u64 = 3_000;
@@ -48,7 +50,6 @@ fn connection_meta(
ConnectionMeta {
control_permissions,
controlled_context,
..Default::default()
}
}
@@ -422,6 +423,12 @@ impl RendezvousMediator {
host_prefix: Self::get_host_prefix(&host),
keep_alive: crate::DEFAULT_KEEP_ALIVE,
};
let mut seal = seal_state::SealState::new(
&rz.host,
&crate::get_key(true).await,
crate::using_public_server(),
seal_state::device_key(),
);
let mut timer = crate::rustdesk_interval(interval(crate::TIMER_OUT));
const MIN_REG_TIMEOUT: i64 = 3_000;
@@ -468,8 +475,15 @@ impl RendezvousMediator {
n = socket.next() => {
match n {
Some(Ok((bytes, _))) => {
if seal.on_cookie(&bytes, &mut socket, &addr).await? { continue; }
let Some((bytes, sealed)) = seal.open(bytes) else { continue };
if let Ok(msg) = Message::parse_from_bytes(&bytes) {
rz.handle_resp(msg.union, Sink::Framed(&mut socket, &addr), &server, &mut update_latency).await?;
if sealed && bytes.is_empty() {
rz.register_peer(seal.round_sink(&mut socket, &addr)).await?;
last_register_sent = Some(Instant::now());
} else if seal.on_message(sealed, &msg.union) {
rz.handle_resp(msg.union, seal.reply_sink(&mut socket, &addr, sealed), &server, &mut update_latency).await?;
}
} else {
log::debug!("Non-protobuf message bytes received: {:?}", bytes);
}
@@ -503,6 +517,7 @@ impl RendezvousMediator {
}
}
if timeout || (last_register_sent.is_none() && expired) {
seal.on_round(timeout);
if timeout {
fails += 1;
if fails >= MAX_FAILS2 {
@@ -515,6 +530,7 @@ impl RendezvousMediator {
socket = s;
rz.addr = new_addr.clone();
addr = new_addr;
seal.on_rebind();
}
last_dns_check = Instant::now();
}
@@ -523,7 +539,7 @@ impl RendezvousMediator {
old_latency = 0;
}
}
rz.register_peer(Sink::Framed(&mut socket, &addr)).await?;
rz.register_peer(seal.round_sink(&mut socket, &addr)).await?;
last_register_sent = now;
}
}
@@ -1260,7 +1276,7 @@ impl RendezvousMediator {
let mut msg_out = Message::new();
msg_out.set_punch_hole_sent(msg_punch);
let (socket, addr) = new_direct_udp_for(&self.host).await?;
let data = msg_out.write_to_bytes()?;
let data = seal_state::seal_one_shot(&self.host, msg_out.write_to_bytes()?);
socket.send_to(&data, addr).await?;
// The reply is out, and with it the answer and the v6 address: declined is the listen
// alone, and the socket goes at once - a declined request is not worth one kept for its
@@ -1479,6 +1495,17 @@ async fn direct_server(server: ServerPtr) {
enum Sink<'a> {
Framed(&'a mut FramedSocket, &'a TargetAddr<'a>),
Stream(&'a mut Stream),
Sealed(
&'a mut FramedSocket,
&'a TargetAddr<'a>,
&'a mut hbb_common::udp_seal::ClientSeal,
bool,
),
Probe(
&'a mut FramedSocket,
&'a TargetAddr<'a>,
&'a mut hbb_common::udp_seal::ClientSeal,
),
}
impl Sink<'_> {
@@ -1486,6 +1513,17 @@ impl Sink<'_> {
match self {
Sink::Framed(socket, addr) => socket.send(msg, addr.to_owned()).await,
Sink::Stream(stream) => stream.send(msg).await,
Sink::Sealed(socket, addr, seal, rehello) => {
for bytes in seal_state::seal_round(seal, msg, rehello, seal_state::device_key)? {
socket.send_bytes(bytes.into(), addr.to_owned()).await?;
}
Ok(())
}
Sink::Probe(socket, addr, seal) => {
socket.send(msg, addr.to_owned()).await?;
let hello = seal_state::probe(seal)?;
socket.send_bytes(hello.into(), addr.to_owned()).await
}
}
}
}
@@ -1534,7 +1572,7 @@ async fn udp_nat_listen(
peer_addr: SocketAddr,
peer_addr_v4: SocketAddr,
server: ServerPtr,
mut meta: ConnectionMeta,
meta: ConnectionMeta,
slot: PunchSlot,
) -> ResultType<()> {
let tm = Instant::now();
@@ -1551,7 +1589,6 @@ async fn udp_nat_listen(
// The KCP session is up: from here it is a connection like any other and the connection
// layer's own limits apply to it, so the place goes back for the next punch.
drop(slot);
meta.is_kcp = true;
crate::server::create_tcp_connection(server, stream.1, peer_addr_v4, true, meta).await?;
Ok(())
};
+631
View File
@@ -0,0 +1,631 @@
//! Which registration datagrams go sealed, and which received ones are acted on.
//!
//! A socket starts out probing: every registration goes sealed. Two unanswered in a row and the
//! server is taken for one without the seal: registrations go plaintext, and every fourth one
//! takes a hello to notice an upgrade. A sealed datagram that opens makes the socket sealed, where
//! nothing goes plaintext and a plaintext answer to a registration is dropped as forged. A
//! missed answer while sealed is retried both under the session and with a hello, since a server
//! restart retires every session; the session stays for pushes until a welcome replaces it. Such
//! a socket never falls back: its server seals. Only a new socket, which may reach another
//! server, probes afresh. A server past its hello budget answers with a cookie, which only a
//! server that seals sends: the hello goes again with it and the socket is sealed.
use super::{Sink, TargetAddr};
use hbb_common::{
anyhow::bail,
bytes::BytesMut,
config::{Config, RS_PUB_KEY},
protobuf::Message as _,
rendezvous_proto::{rendezvous_message, RendezvousMessage},
sodiumoxide::crypto::sign,
udp::FramedSocket,
udp_seal::{self, ClientSeal, Cookie, OneShot},
ResultType,
};
use std::sync::Mutex;
const PROBE_TRIES: u8 = 2;
const PROBE_EVERY: u8 = 4;
// The hosts whose registration is sealed now, their keys, cookies and sessions: a one-off datagram
// to one of them may go sealed too. Only a socket with a session or a cookie adds its host, so an
// older server never gets one.
static SEALED: Mutex<Vec<(String, sign::PublicKey, Option<Cookie>, Option<OneShot>)>> =
Mutex::new(Vec::new());
#[derive(Clone, Copy, Debug, PartialEq)]
enum Mode {
Probing(u8),
Fallback(u8),
Sealed,
Resealing,
}
impl Mode {
/// A missed answer is no sign the server stopped sealing.
fn seals(self) -> bool {
matches!(self, Mode::Sealed | Mode::Resealing)
}
}
pub(super) struct SealState {
host: String,
server: Option<sign::PublicKey>,
seal: Option<ClientSeal>,
mode: Mode,
}
/// The device's signing key; the server has its public half from RegisterPk.
pub(super) fn device_key() -> Option<sign::SecretKey> {
sign::SecretKey::from_slice(&Config::get_key_pair().0)
}
impl SealState {
/// Without a key for this server nothing is sealed and every path runs as before. The public
/// server's key stands in for an empty setting, and it is no key for any other server.
pub(super) fn new(
host: &str,
key: &str,
public_server: bool,
device: Option<sign::SecretKey>,
) -> Self {
let server = if key == RS_PUB_KEY && !public_server {
None
} else {
crate::common::get_rs_pk(key)
};
Self {
host: host.to_owned(),
server,
seal: server.and_then(|pk| ClientSeal::new(&pk, device)),
mode: Mode::Probing(0),
}
}
/// Before a register round sends; `timed_out` is whether the previous one went unanswered.
pub(super) fn on_round(&mut self, timed_out: bool) {
if self.seal.is_none() {
return;
}
let mode = match self.mode {
Mode::Probing(n) if timed_out && n + 1 >= PROBE_TRIES => Mode::Fallback(0),
Mode::Probing(n) if timed_out => Mode::Probing(n + 1),
Mode::Sealed if timed_out => Mode::Resealing,
Mode::Fallback(r) => Mode::Fallback((r + 1) % PROBE_EVERY),
mode => mode,
};
self.set_mode(mode);
}
/// A new socket may be a new path, so one that sealed is probed again. One that had not
/// keeps its count: a rebind every minute would otherwise keep it probing for good.
pub(super) fn on_rebind(&mut self) {
if let Some(seal) = self.seal.as_mut() {
seal.reset();
}
if self.mode.seals() {
self.set_mode(Mode::Probing(0));
}
}
pub(super) fn round_sink<'a>(
&'a mut self,
socket: &'a mut FramedSocket,
addr: &'a TargetAddr<'a>,
) -> Sink<'a> {
let sealed = !matches!(self.mode, Mode::Fallback(_));
match self.seal.as_mut() {
Some(seal) if sealed => Sink::Sealed(socket, addr, seal, self.mode == Mode::Resealing),
Some(seal) if self.mode == Mode::Fallback(PROBE_EVERY - 1) => {
Sink::Probe(socket, addr, seal)
}
_ => Sink::Framed(socket, addr),
}
}
/// A reply goes the way the datagram it answers came.
pub(super) fn reply_sink<'a>(
&'a mut self,
socket: &'a mut FramedSocket,
addr: &'a TargetAddr<'a>,
sealed: bool,
) -> Sink<'a> {
match self.seal.as_mut() {
Some(seal) if sealed => Sink::Sealed(socket, addr, seal, false),
_ => Sink::Framed(socket, addr),
}
}
/// The bytes to parse and whether they came sealed, or `None` to drop the datagram.
pub(super) fn open(&mut self, bytes: BytesMut) -> Option<(BytesMut, bool)> {
let seal = match self.seal.as_mut() {
Some(seal) if udp_seal::is_sealed(&bytes) => seal,
_ => return Some((bytes, false)),
};
let payload = seal.open(&bytes)?;
self.set_mode(Mode::Sealed);
// A welcome may have brought a new session.
self.publish();
Some((BytesMut::from(&payload[..]), true))
}
/// Whether `bytes` was a cookie reply; one to the latest hello sends that hello again with it.
pub(super) async fn on_cookie(
&mut self,
bytes: &[u8],
socket: &mut FramedSocket,
addr: &TargetAddr<'_>,
) -> ResultType<bool> {
let Some(seal) = self.seal.as_mut().filter(|_| udp_seal::is_cookie(bytes)) else {
return Ok(false);
};
if let Some(again) = seal.on_cookie(bytes) {
let cookie = seal.cookie();
socket.send_bytes(again.into(), addr.to_owned()).await?;
self.set_mode(Mode::Sealed);
if let Some(entry) = SEALED.lock().unwrap().iter_mut().find(|e| e.0 == self.host) {
entry.2 = cookie;
}
}
Ok(true)
}
/// Whether to act on a parsed message. Unless the socket fell back, every registration went
/// sealed, so a plaintext answer to one is forged; once sealed, so is a plaintext push from a
/// server that seals every push.
pub(super) fn on_message(
&mut self,
sealed: bool,
msg: &Option<rendezvous_message::Union>,
) -> bool {
if sealed {
return true;
}
let Some(seal) = self.seal.as_ref() else {
return true;
};
match (self.mode, msg) {
(Mode::Fallback(_), _) => true,
(
_,
Some(rendezvous_message::Union::RegisterPeerResponse(_))
| Some(rendezvous_message::Union::RegisterPkResponse(_)),
) => false,
(Mode::Probing(_), _) => true,
(Mode::Sealed | Mode::Resealing, _) => !seal.pushes_sealed(),
}
}
fn set_mode(&mut self, mode: Mode) {
if self.mode == mode {
return;
}
let was_sealed = self.mode.seals();
self.mode = mode;
match self.server {
Some(_) if mode == Mode::Sealed => self.publish(),
_ if was_sealed && !mode.seals() => self.forget_sealed(),
_ => {}
}
}
fn publish(&self) {
let (Some(server), Some(seal)) = (self.server, self.seal.as_ref()) else {
return;
};
let mut sealed = SEALED.lock().unwrap();
sealed.retain(|e| e.0 != self.host);
sealed.push((self.host.clone(), server, seal.cookie(), seal.one_shot()));
}
fn forget_sealed(&self) {
SEALED.lock().unwrap().retain(|e| e.0 != self.host);
}
}
impl Drop for SealState {
fn drop(&mut self) {
if self.mode.seals() {
self.forget_sealed();
}
}
}
/// The datagram a registration goes out as: data under the session, where it carries the
/// device's proof until the server holds it, or with no session yet an empty hello, the
/// registration following its welcome.
/// `hello` asks for one even under a session, as after a missed answer. A RegisterPk with a key
/// other than the one proofs are signed by means the key pair changed: `device` loads the new
/// one, and is called for nothing else.
fn seal_message(
seal: &mut ClientSeal,
msg: &RendezvousMessage,
hello: bool,
device: impl Fn() -> Option<sign::SecretKey>,
) -> ResultType<Vec<u8>> {
let pk = &msg.register_pk().pk;
if !pk.is_empty() && !seal.signs_as(pk) {
seal.set_device(device().filter(|sk| sk.0[32..] == pk[..]));
}
let sealed = if hello || !seal.has_session() {
seal.hello(&[])
} else {
seal.seal(&msg.write_to_bytes()?)
};
match sealed {
Some(bytes) => Ok(bytes),
None => bail!("failed to seal a datagram to the rendezvous server"),
}
}
/// The datagrams a round's registration goes out as: under the session, and with `rehello` a
/// hello too, which a server that restarted needs and one that only lost an answer does not.
pub(super) fn seal_round(
seal: &mut ClientSeal,
msg: &RendezvousMessage,
rehello: bool,
device: impl Fn() -> Option<sign::SecretKey>,
) -> ResultType<Vec<Vec<u8>>> {
let mut datagrams = vec![seal_message(seal, msg, false, &device)?];
if rehello && !udp_seal::is_hello(&datagrams[0]) {
datagrams.push(seal_message(seal, msg, true, &device)?);
}
Ok(datagrams)
}
/// The hello a fallen-back socket sends beside a plaintext registration, so the round is
/// answered whether or not the server seals by now.
pub(super) fn probe(seal: &mut ClientSeal) -> ResultType<Vec<u8>> {
match seal.hello(&[]) {
Some(bytes) => Ok(bytes),
None => bail!("failed to seal a datagram to the rendezvous server"),
}
}
/// A one-off datagram to `host`, the PunchHoleSent of a UDP punch, goes sealed only while that
/// host's registration is: an older server would drop it, and the punch with it. It goes under the
/// registration's session; with none yet, as right after a cookie, it goes as a hello, 0-RTT data
/// without forward secrecy (RFC 8446 §2.3).
pub(super) fn seal_one_shot(host: &str, data: Vec<u8>) -> Vec<u8> {
let server = SEALED
.lock()
.unwrap()
.iter()
.find(|e| e.0 == host)
.map(|e| (e.1, e.2, e.3.clone()));
let sealed = server.and_then(|(pk, cookie, one_shot)| match one_shot {
Some(one_shot) => one_shot.seal(&data),
None => {
let mut seal = ClientSeal::new(&pk, None)?;
seal.set_cookie(cookie);
seal.seal(&data)
}
});
match sealed {
Some(sealed) => sealed,
None => data,
}
}
#[cfg(test)]
mod tests {
use super::*;
use hbb_common::{
rendezvous_proto::{RegisterPeer, RegisterPk},
tokio,
udp_seal::{Reply, ServerKey, CAP_PUSHES_SEALED},
};
// Each test names its own host: the sealed host is process-wide and tests run in parallel.
fn state(host: &str) -> (SealState, ServerKey) {
let (pk, sk) = sign::gen_keypair();
let device = Some(sign::gen_keypair().1);
(
SealState::new(host, &crate::encode64(pk.0), false, device),
ServerKey::new(&sk, [1u8; 32]).unwrap(),
)
}
fn welcomed(state: &mut SealState, server: &ServerKey, caps: u8) {
let hello = state.seal.as_mut().unwrap().seal(b"").unwrap();
let (_, mut reply) = server.open(&hello, || 1).unwrap();
let welcome = server.seal(&mut reply, caps, b"", || 0).unwrap();
assert!(state.open(BytesMut::from(&welcome[..])).unwrap().1);
}
async fn rounds(state: &mut SealState, timeouts: &[bool]) -> Vec<bool> {
let mut socket = FramedSocket::new("127.0.0.1:0").await.unwrap();
let addr = TargetAddr::Ip("127.0.0.1:9".parse().unwrap());
let mut sealed = Vec::new();
for &timed_out in timeouts {
state.on_round(timed_out);
sealed.push(matches!(
state.round_sink(&mut socket, &addr),
Sink::Sealed(..) | Sink::Probe(..)
));
}
sealed
}
fn message(set: impl FnOnce(&mut RendezvousMessage)) -> RendezvousMessage {
let mut msg = RendezvousMessage::new();
set(&mut msg);
msg
}
#[tokio::test]
async fn two_unanswered_hellos_fall_back_and_every_fourth_round_probes() {
let (mut state, _) = state("fall-back");
let timeouts = [false, true, true, false, false, false, false, false];
assert_eq!(
rounds(&mut state, &timeouts).await,
[true, true, false, false, false, true, false, false]
);
}
#[tokio::test]
async fn without_a_key_for_this_server_nothing_is_sealed() {
for key in ["", RS_PUB_KEY] {
let mut state = SealState::new("no-key", key, false, None);
assert_eq!(rounds(&mut state, &[false, true, true]).await, [false; 3]);
let bytes = BytesMut::from(&udp_seal::MAGIC[..]);
assert_eq!(state.open(bytes.clone()), Some((bytes, false)));
}
let mut public = SealState::new("public", RS_PUB_KEY, true, None);
assert_eq!(rounds(&mut public, &[false]).await, [true]);
}
#[test]
fn once_sealed_plaintext_answers_are_dropped_and_pushes_follow_the_server() {
for caps in [0, CAP_PUSHES_SEALED] {
let (mut state, server) = state("answers");
let answer = Some(rendezvous_message::Union::RegisterPkResponse(
Default::default(),
));
let push = Some(rendezvous_message::Union::PunchHole(Default::default()));
welcomed(&mut state, &server, caps);
assert!(state.on_message(true, &answer));
assert!(!state.on_message(false, &answer));
assert_eq!(state.on_message(false, &push), caps == 0);
}
}
#[tokio::test]
async fn while_probing_plaintext_answers_are_forged_but_fallback_takes_them() {
let (mut state, _) = state("probing");
let answer = Some(rendezvous_message::Union::RegisterPkResponse(
Default::default(),
));
let push = Some(rendezvous_message::Union::PunchHole(Default::default()));
assert!(!state.on_message(false, &answer));
assert!(state.on_message(false, &push));
rounds(&mut state, &[false, true, true]).await;
assert!(
state.on_message(false, &answer),
"an older server answers in plaintext"
);
let mut off = SealState::new("probing-off", "", false, None);
assert!(
off.on_message(false, &answer),
"without a key nothing changes"
);
}
#[test]
fn a_register_pk_with_a_new_device_key_proves_it_with_that_key() {
let (pk, sk) = sign::gen_keypair();
let server = ServerKey::new(&sk, [1u8; 32]).unwrap();
let mut seal = ClientSeal::new(&pk, Some(sign::gen_keypair().1)).unwrap();
let (new_pk, new_sk) = sign::gen_keypair();
let register_peer = message(|m| m.set_register_peer(RegisterPeer::default()));
let hello = seal_message(&mut seal, &register_peer, false, || unreachable!()).unwrap();
let (_, mut reply) = server.open(&hello, || 1).unwrap();
seal.open(&server.seal(&mut reply, 0, b"", || 0).unwrap())
.unwrap();
let register_pk = message(|m| {
m.set_register_pk(RegisterPk {
pk: new_pk.0.to_vec().into(),
..Default::default()
})
});
let data = seal_message(&mut seal, &register_pk, false, || Some(new_sk.clone())).unwrap();
let (opened, _) = server.open(&data, || unreachable!()).unwrap();
assert!(opened.proven_by(new_pk.as_ref()));
}
async fn registration(state: &mut SealState, msg: &RendezvousMessage) -> Vec<Vec<u8>> {
let mut socket = FramedSocket::new("127.0.0.1:0").await.unwrap();
let server = tokio::net::UdpSocket::bind("127.0.0.1:0").await.unwrap();
let addr = TargetAddr::Ip(server.local_addr().unwrap());
state
.round_sink(&mut socket, &addr)
.send(msg)
.await
.unwrap();
let mut buf = [0u8; 2048];
let mut datagrams = Vec::new();
let wait = std::time::Duration::from_millis(100);
while let Ok(Ok(n)) = tokio::time::timeout(wait, server.recv(&mut buf)).await {
datagrams.push(buf[..n].to_vec());
}
datagrams
}
#[tokio::test]
async fn a_missed_answer_while_sealed_retries_under_the_session_and_with_a_hello() {
let (mut state, server) = state("missed");
let register_peer = message(|m| m.set_register_peer(RegisterPeer::default()));
let hello = registration(&mut state, &register_peer).await;
let (_, mut reply) = server.open(&hello[0], || 1).unwrap();
let welcome = server
.seal(&mut reply, CAP_PUSHES_SEALED, b"", || 0)
.unwrap();
assert!(state.open(BytesMut::from(&welcome[..])).unwrap().1);
assert_eq!(registration(&mut state, &register_peer).await.len(), 1);
state.on_round(true);
let retry = registration(&mut state, &register_peer).await;
assert_eq!(retry.len(), 2);
assert!(
server.open(&retry[0], || 2).unwrap().0.pn.is_some(),
"a server that only lost an answer takes it without the hello budget"
);
assert!(
udp_seal::is_hello(&retry[1]),
"a restarted one takes the hello"
);
let punch = Some(rendezvous_message::Union::PunchHole(Default::default()));
assert!(
!state.on_message(false, &punch),
"a plaintext push is still forged"
);
let push = server.seal(&mut Reply::push(1), 0, b"", || 7).unwrap();
assert!(
state.open(BytesMut::from(&push[..])).is_some(),
"a push under the session still opens"
);
}
#[tokio::test]
async fn a_cookie_sends_the_hello_again_and_the_socket_stays_sealed() {
let (mut state, server) = state("cookie");
let register_peer = message(|m| m.set_register_peer(RegisterPeer::default()));
let hello = registration(&mut state, &register_peer).await;
let reply = udp_seal::cookie_reply(&hello[0], [5u8; 16]).unwrap();
let mut socket = FramedSocket::new("127.0.0.1:0").await.unwrap();
let peer = tokio::net::UdpSocket::bind("127.0.0.1:0").await.unwrap();
let addr = TargetAddr::Ip(peer.local_addr().unwrap());
assert!(state.on_cookie(&reply, &mut socket, &addr).await.unwrap());
let mut buf = [0u8; 2048];
let wait = std::time::Duration::from_millis(500);
let n = tokio::time::timeout(wait, peer.recv(&mut buf))
.await
.unwrap()
.unwrap();
assert_eq!(udp_seal::hello_cookie(&buf[..n]), Some([5u8; 16]));
assert!(server.open(&buf[..n], || 1).is_some());
assert_eq!(
rounds(&mut state, &[true; 4]).await,
[true; 4],
"only a server that seals sends a cookie"
);
let punch = seal_one_shot("cookie", b"\x0a\x00".to_vec());
assert_eq!(udp_seal::hello_cookie(&punch), Some([5u8; 16]));
}
#[tokio::test]
async fn a_fallen_back_probe_registers_in_plaintext_beside_its_hello() {
let (mut state, _) = state("probe-round");
rounds(&mut state, &[false, true, true, false, false, false]).await;
let register_peer = message(|m| m.set_register_peer(RegisterPeer::default()));
let probe = registration(&mut state, &register_peer).await;
assert_eq!(probe.len(), 2);
assert_eq!(
probe[0],
register_peer.write_to_bytes().unwrap(),
"an older server answers it as any other round"
);
assert!(udp_seal::is_hello(&probe[1]));
}
#[tokio::test]
async fn a_rebind_does_not_send_a_socket_that_never_sealed_back_to_probing() {
let (mut state, _) = state("rebind-unsealed");
assert_eq!(rounds(&mut state, &[false, true]).await, [true, true]);
state.on_rebind();
assert_eq!(
rounds(&mut state, &[true, false]).await,
[false, false],
"its two probes went unanswered already"
);
state.on_rebind();
assert_eq!(rounds(&mut state, &[false]).await, [false]);
}
#[tokio::test]
async fn a_socket_that_sealed_does_not_fall_back_until_it_rebinds() {
let (mut state, server) = state("no-fall-back");
welcomed(&mut state, &server, 0);
let answer = Some(rendezvous_message::Union::RegisterPkResponse(
Default::default(),
));
assert_eq!(rounds(&mut state, &[true; 6]).await, [true; 6]);
assert!(
!state.on_message(false, &answer),
"its server seals, so a plaintext answer is forged"
);
state.on_rebind();
assert_eq!(
rounds(&mut state, &[false, true, true]).await,
[true, true, false]
);
assert!(
state.on_message(false, &answer),
"a new socket may reach an older server"
);
}
#[test]
fn a_registration_never_rides_a_hello_and_goes_proven_under_the_session() {
let (pk, sk) = sign::gen_keypair();
let server = ServerKey::new(&sk, [1u8; 32]).unwrap();
let (device_pk, device_sk) = sign::gen_keypair();
let mut seal = ClientSeal::new(&pk, Some(device_sk)).unwrap();
let register_peer = message(|m| m.set_register_peer(RegisterPeer::default()));
let register_pk = message(|m| m.set_register_pk(RegisterPk::default()));
let mut reply = None;
for msg in [&register_peer, &register_pk] {
let hello = seal_message(&mut seal, msg, false, || None).unwrap();
let (opened, r) = server.open(&hello, || 1).unwrap();
assert!(opened.pn.is_none() && opened.payload.is_empty());
reply = Some(r);
}
let welcome = server.seal(&mut reply.unwrap(), 0, b"", || 0).unwrap();
seal.open(&welcome).unwrap();
for msg in [&register_peer, &register_pk] {
let data = seal_message(&mut seal, msg, false, || None).unwrap();
let (opened, _) = server.open(&data, || unreachable!()).unwrap();
assert!(opened.proven_by(device_pk.as_ref()));
assert_eq!(
RendezvousMessage::parse_from_bytes(&opened.payload).unwrap(),
*msg
);
}
}
#[test]
fn a_punch_goes_under_the_session_only_while_its_server_seals() {
let data = b"\x0a\x00".to_vec();
assert_eq!(seal_one_shot("punch", data.clone()), data);
let (mut state, server) = state("punch");
welcomed(&mut state, &server, 0);
let (mut other, other_server) = self::state("punch-other");
welcomed(&mut other, &other_server, 0);
let sealed = seal_one_shot("punch", data.clone());
let (opened, _) = server.open(&sealed, || unreachable!()).unwrap();
assert_eq!((opened.key_id, &opened.payload), (1, &data));
assert_eq!(seal_one_shot("another-host", data.clone()), data);
let hello = state.seal.as_mut().unwrap().hello(b"").unwrap();
let (_, mut reply) = server.open(&hello, || 2).unwrap();
let welcome = server.seal(&mut reply, 0, b"", || 0).unwrap();
state.open(BytesMut::from(&welcome[..])).unwrap();
let sealed = seal_one_shot("punch", data.clone());
assert_eq!(
server.open(&sealed, || unreachable!()).unwrap().0.key_id,
2,
"the session a welcome brought"
);
state.on_round(true);
assert!(
server
.open(&seal_one_shot("punch", data.clone()), || unreachable!())
.is_some(),
"a missed answer is no sign the server stopped sealing"
);
state.on_rebind();
assert_eq!(seal_one_shot("punch", data.clone()), data);
welcomed(&mut state, &server, 0);
state.on_round(true);
drop(state);
assert_eq!(seal_one_shot("punch", data.clone()), data);
}
}
-1
View File
@@ -90,7 +90,6 @@ type ConnMap = HashMap<i32, ConnInner>;
pub struct ConnectionMeta {
pub control_permissions: Option<ControlPermissions>,
pub controlled_context: Option<ControlledContext>,
pub is_kcp: bool,
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
+22 -215
View File
@@ -75,8 +75,6 @@ use windows::Win32::Foundation::{CloseHandle, HANDLE};
use crate::virtual_display_manager;
pub type Sender = mpsc::UnboundedSender<(Instant, Arc<Message>)>;
#[cfg(target_os = "linux")]
mod linux_terminal;
mod trusted_devices;
const FAILURE_IDX_ID_WHITELIST: usize = 2;
@@ -228,15 +226,6 @@ fn constant_time_eq(a: &[u8], b: &[u8]) -> bool {
x == 0
}
async fn wait_for_peer_close(stream: &mut Stream, is_kcp: bool) {
// KCP uses a loopback TCP stream and can wait until the timeout when its endpoint stops.
let timeout_secs = if is_kcp || stream.is_webrtc() { 1 } else { 10 };
let _ = time::timeout(Duration::from_secs(timeout_secs), async {
while let Some(Ok(_)) = stream.next().await {}
})
.await;
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn should_use_terminal_os_login_scope(is_terminal: bool, os_login_username: &str) -> bool {
cfg!(target_os = "windows") && is_terminal && !os_login_username.trim().is_empty()
@@ -366,10 +355,10 @@ impl TerminalUserToken {
}
}
}
pub struct Connection<'a> {
pub struct Connection {
inner: ConnInner,
display_idx: usize,
stream: &'a mut Stream,
stream: super::Stream,
server: super::ServerPtrWeak,
hash: Hash,
read_jobs: Vec<fs::TransferJob>,
@@ -447,7 +436,6 @@ pub struct Connection<'a> {
#[cfg(not(any(target_os = "ios")))]
pressed_modifiers: HashSet<rdev::Key>,
closed: bool,
sent_final_message: bool,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
start_cm_ipc_para: Option<StartCmIpcPara>,
auto_disconnect_timer: Option<(Instant, u64)>,
@@ -541,41 +529,18 @@ fn drm_can_serve_login_screen() -> bool {
false
}
impl Connection<'_> {
impl Connection {
pub async fn start(
addr: SocketAddr,
mut stream: super::Stream,
stream: super::Stream,
id: i32,
server: super::ServerPtrWeak,
meta: super::ConnectionMeta,
unauthorized: UnauthorizedID,
) {
// The admission place stays held while the transport drains, unless a newer
// connection needs it.
let is_kcp = meta.is_kcp;
let (wait_for_close, unauthorized) =
Self::_start(addr, &mut stream, id, server, meta, unauthorized).await;
if wait_for_close {
// Only the transport is needed here. Session cleanup must not wait for the peer.
tokio::select! {
_ = wait_for_peer_close(&mut stream, is_kcp) => {}
_ = unauthorized_evicted(&unauthorized) => {}
}
}
}
async fn _start(
addr: SocketAddr,
stream: &mut Stream,
id: i32,
server: super::ServerPtrWeak,
meta: super::ConnectionMeta,
unauthorized: UnauthorizedID,
) -> (bool, Option<UnauthorizedID>) {
let super::ConnectionMeta {
control_permissions,
controlled_context,
is_kcp,
} = meta;
// Android is not supported yet, so we always set control_permissions to None.
#[cfg(target_os = "android")]
@@ -605,7 +570,7 @@ impl Connection<'_> {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let tx_cloned = tx.clone();
let mut conn = Connection {
let mut conn = Self {
inner: ConnInner {
id,
tx: Some(tx),
@@ -680,7 +645,6 @@ impl Connection<'_> {
#[cfg(not(any(target_os = "ios")))]
pressed_modifiers: Default::default(),
closed: false,
sent_final_message: false,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
start_cm_ipc_para: Some(StartCmIpcPara {
rx_to_cm,
@@ -712,7 +676,7 @@ impl Connection<'_> {
conn.closed = true;
// sleep to ensure msg got received.
sleep(1.).await;
return (false, None);
return;
}
#[cfg(target_os = "android")]
start_channel(rx_to_cm, tx_from_cm);
@@ -779,7 +743,6 @@ impl Connection<'_> {
(_tx_clip, rx_clip) = mpsc::unbounded_channel::<i32>();
}
let mut manual_disconnect = false;
loop {
tokio::select! {
// biased; // video has higher priority // causing test_delay_timer failed while transferring big file
@@ -811,7 +774,6 @@ impl Connection<'_> {
ipc::Data::Close => {
conn.chat_unanswered = false; // seen
conn.file_transferred = false; //seen
manual_disconnect = true;
conn.send_close_reason_no_retry("").await;
conn.on_close("connection manager", true).await;
break;
@@ -1111,7 +1073,7 @@ impl Connection<'_> {
_ = conn.file_timer.tick() => {
if !conn.read_jobs.is_empty() {
conn.send_to_cm(ipc::Data::FileTransferLog(("transfer".to_string(), fs::serialize_transfer_jobs(&conn.read_jobs))));
match fs::handle_read_jobs(&mut conn.read_jobs, conn.stream).await {
match fs::handle_read_jobs(&mut conn.read_jobs, &mut conn.stream).await {
Ok(log) => {
if !log.is_empty() {
conn.send_to_cm(ipc::Data::FileTransferLog(("transfer".to_string(), log)));
@@ -1128,7 +1090,6 @@ impl Connection<'_> {
}
Ok(conns) = hbbs_rx.recv() => {
if conns.contains(&id) {
manual_disconnect = true;
conn.send_close_reason_no_retry("Closed manually by web console").await;
conn.on_close("web console", true).await;
break;
@@ -1209,7 +1170,7 @@ impl Connection<'_> {
Some(data) = rx_from_authed.recv() => {
match data {
ipc::Data::Close => {
conn.send_before_close(crate::common::make_privacy_mode_msg(
conn.send(crate::common::make_privacy_mode_msg(
back_notification::PrivacyModeState::PrvOnByOther,
String::new(),
)).await;
@@ -1321,10 +1282,6 @@ impl Connection<'_> {
}
conn.on_close("End", true).await;
log::info!("#{} connection loop exited", id);
(
conn.should_wait_for_peer_close(is_kcp, manual_disconnect),
conn.unauthorized_id.take(),
)
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
@@ -1490,7 +1447,7 @@ impl Connection<'_> {
async fn check_privacy_mode_on(&mut self) -> bool {
if privacy_mode::is_in_privacy_mode() {
self.send_login_error_before_close("Someone turns on privacy mode, exit")
self.send_login_error("Someone turns on privacy mode, exit")
.await;
false
} else {
@@ -1538,15 +1495,13 @@ impl Connection<'_> {
self.decay_id_whitelist_failures();
let (failure, res) = self.check_failure(FAILURE_IDX_ID_WHITELIST).await;
if !res {
// check_failure sent the error; its other callers keep the connection open.
self.sent_final_message = true;
return false;
}
if id_whitelist_allows(&id_whitelist, &self.lr.my_id) {
return true;
}
self.update_failure(failure, false, FAILURE_IDX_ID_WHITELIST);
self.send_login_error_before_close("Your ID is blocked by the peer")
self.send_login_error("Your ID is blocked by the peer")
.await;
self.post_alarm_audit(
AlarmAuditType::IdWhitelist,
@@ -1884,7 +1839,7 @@ impl Connection<'_> {
return true;
};
if pf.multiplex {
crate::port_forward_mux::cap_packet_size(self.stream);
crate::port_forward_mux::cap_packet_size(&mut self.stream);
// `inner.tx` is set for the connection's whole life; `None` here is
// unreachable, and refusing the login is the only honest answer.
self.port_forward_mux = self.inner.tx.clone().map(|tx| {
@@ -1905,7 +1860,7 @@ impl Connection<'_> {
if is_rdp {
addr = "RDP".to_owned();
}
self.send_login_error_before_close(format!(
self.send_login_error(format!(
"Failed to access remote {}. Please make sure it is reachable/open.",
addr
))
@@ -1917,7 +1872,7 @@ impl Connection<'_> {
if is_rdp {
addr = "RDP".to_owned();
}
self.send_login_error_before_close(format!(
self.send_login_error(format!(
"Failed to access remote {}. Please make sure it is reachable/open.",
addr
))
@@ -2537,24 +2492,6 @@ impl Connection<'_> {
self.send(msg_out).await;
}
async fn send_login_error_before_close<T: std::string::ToString>(&mut self, err: T) {
let mut msg_out = Message::new();
let mut res = LoginResponse::new();
res.set_error(err.to_string());
res.trusted_device_v2_supported =
self.lr.trusted_device_v2_supported && self.trusted_device.is_some();
msg_out.set_login_response(res);
self.send_before_close(msg_out).await;
}
/// For the last message before the connection closes, so WebRTC and KCP get to deliver it.
async fn send_before_close(&mut self, msg: Message) {
match self.stream.send(&msg).await {
Ok(()) => self.sent_final_message = true,
Err(err) => log::debug!("Failed to send the last message before closing: {err}"),
}
}
#[inline]
pub fn send_block_input_error(
s: &Sender,
@@ -2967,8 +2904,7 @@ impl Connection<'_> {
Self::login_scope_kind(&self.lr),
Self::login_scope_kind(lr),
);
self.send_login_error_before_close("Connection not allowed")
.await;
self.send_login_error("Connection not allowed").await;
false
}
Some(_) => true,
@@ -3123,7 +3059,7 @@ impl Connection<'_> {
if !crate::common::is_direct_ip_access(&lr.username) && lr.username != Config::get_id()
{
self.send_login_error_before_close(crate::client::LOGIN_MSG_OFFLINE)
self.send_login_error(crate::client::LOGIN_MSG_OFFLINE)
.await;
return false;
}
@@ -3291,8 +3227,7 @@ impl Connection<'_> {
log::warn!(
"Rejected switch sides response for non-remote-desktop session; closing connection"
);
self.send_login_error_before_close("Connection not allowed")
.await;
self.send_login_error("Connection not allowed").await;
return false;
}
self.reset_session_scope_for_login();
@@ -4274,7 +4209,7 @@ impl Connection<'_> {
true
}
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn fill_terminal_user_token(
&mut self,
_username: &str,
@@ -4404,7 +4339,6 @@ impl Connection<'_> {
);
// Terminal OS login is sensitive. Close this connection instead of keeping it
// alive for retries on the same socket after a rate-limit block.
self.sent_final_message = true;
return Some(false);
}
TerminalAuthorizationMode::OsLogin {
@@ -4421,12 +4355,9 @@ impl Connection<'_> {
TerminalAuthorizationMode::SessionUser => FailureScope::Default,
};
#[cfg(target_os = "linux")]
let terminal_login_error = linux_terminal::fill_token(&mut self.terminal_user_token).await;
#[cfg(not(target_os = "linux"))]
let username = normalized_username;
let password = self.lr.os_login.password.clone();
let terminal_login_error = {
let username = normalized_username;
let password = self.lr.os_login.password.clone();
#[cfg(target_os = "windows")]
{
// Concurrency gate for terminal OS login with credentials, to prevent brute-force attacks.
@@ -4471,15 +4402,6 @@ impl Connection<'_> {
} else {
"Terminal session-user authorization"
};
#[cfg(target_os = "linux")]
hbb_common::throttled_log!(
linux_terminal::LOG_INTERVAL,
warn,
"{auth_context} failed: ip={} conn_id={} scope={failure_scope:?} msg='{msg}'",
self.ip,
self.inner.id()
);
#[cfg(not(target_os = "linux"))]
log::warn!(
"{} failed: ip={} conn_id={} scope={:?} msg='{}'",
auth_context,
@@ -5569,15 +5491,6 @@ impl Connection<'_> {
}
}
fn should_wait_for_peer_close(&self, is_kcp: bool, manual_disconnect: bool) -> bool {
// The controller or relay may still be writing when an active session is disconnected.
let wait_for_manual_close = manual_disconnect
&& self.authorized
&& matches!(self.stream, Stream::Tcp(_) | Stream::WebSocket(_));
// Dropping WebRTC or KCP can discard a queued final message.
self.sent_final_message && (is_kcp || self.stream.is_webrtc() || wait_for_manual_close)
}
// The `reason` should be consistent with `check_if_retry` if not empty
async fn send_close_reason_no_retry(&mut self, reason: &str) {
let mut misc = Misc::new();
@@ -5588,10 +5501,7 @@ impl Connection<'_> {
}
let mut msg_out = Message::new();
msg_out.set_misc(misc);
match self.stream.send(&msg_out).await {
Ok(()) => self.sent_final_message = true,
Err(err) => log::debug!("Failed to send CloseReason: {err}"),
}
self.send(msg_out).await;
raii::AuthedConnID::check_remove_session(self.inner.id(), self.session_key());
}
@@ -7000,7 +6910,7 @@ impl Default for PortableState {
}
}
impl Drop for Connection<'_> {
impl Drop for Connection {
fn drop(&mut self) {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
self.release_pressed_modifiers();
@@ -7476,109 +7386,6 @@ mod test {
UNAUTHORIZED_CONNS.lock().unwrap().len()
}
#[tokio::test]
async fn tcp_upload_receives_manual_disconnect_reason() {
use hbb_common::{bytes::Bytes, futures::stream};
let reason = "Closed manually by the peer";
let block = fs::new_block(FileTransferBlock {
data: vec![0; 128 * 1024].into(),
..Default::default()
});
let upload_block = Bytes::from(block.write_to_bytes().unwrap());
// A queued close reason can beat the reset even without the wait. Exercise several connections.
for _ in 0..4 {
let (mut controlled, mut controller, _) = stalled_incoming().await;
let block = &block;
let host = async move {
controlled.next().await.unwrap().unwrap();
controlled.send(block).await.unwrap();
let close = misc_msg(|m| m.set_close_reason(reason.into()));
controlled.send(&close).await.unwrap();
wait_for_peer_close(&mut controlled, false).await;
};
let upload_block = upload_block.clone();
let client = async move {
let Stream::Tcp(tcp) = &mut controller else {
unreachable!("expected loopback TCP");
};
let (writer, mut reader) = (&mut tcp.0).split();
let upload = stream::repeat(upload_block).map(Ok).forward(writer);
let receive = async {
reader.next().await.unwrap().unwrap(); // File data queued ahead of CloseReason.
let frame = reader
.next()
.await
.expect("EOF before CloseReason")
.unwrap();
let message = Message::parse_from_bytes(&frame).unwrap();
assert_eq!(message.misc().close_reason(), reason);
};
tokio::select! {
result = upload => panic!("upload ended before CloseReason: {result:?}"),
() = receive => {}
}
};
timeout(5_000, async { tokio::join!(host, client) })
.await
.unwrap();
}
}
#[tokio::test]
async fn webrtc_controller_receives_manual_disconnect_reason() {
use hbb_common::webrtc::WebRTCStream;
let (mut controller, mut controlled) = timeout(30_000, async {
let offerer = WebRTCStream::new("", false, 20000).await.unwrap();
let offer = offerer.get_local_endpoint().await.unwrap();
let answerer = WebRTCStream::new(&offer, false, 20000).await.unwrap();
let answer = answerer.get_local_endpoint().await.unwrap();
offerer.set_remote_endpoint(&answer).await.unwrap();
(Stream::WebRTC(offerer), Stream::WebRTC(answerer))
})
.await
.expect("WebRTC setup timed out");
let reason = "Closed manually by the peer";
let message = misc_msg(|m| m.set_close_reason(reason.into()));
let ping = msg(|m| m.set_test_delay(TestDelay::new()));
controller.send(&ping).await.unwrap();
controlled.send(&message).await.unwrap();
let reader = tokio::spawn(async move {
time::sleep(Duration::from_millis(100)).await;
let frame = controller.next_timeout(3000).await.expect("close reason");
Message::parse_from_bytes(&frame.unwrap()).unwrap()
});
wait_for_peer_close(&mut controlled, false).await;
drop(controlled);
assert_eq!(reader.await.unwrap().misc().close_reason(), reason);
}
#[tokio::test]
async fn kcp_controller_receives_manual_disconnect_reason() {
let ((_controller_guard, mut controller), (controlled_guard, mut controlled)) =
crate::kcp_stream::tests::establish().await;
let reason = "Closed manually by the peer";
let sender = tokio::spawn(async move {
let message = misc_msg(|m| m.set_close_reason(reason.into()));
controlled.send(&message).await.unwrap();
wait_for_peer_close(&mut controlled, true).await;
drop(controlled);
drop(controlled_guard);
});
let frame = controller
.next_timeout(3000)
.await
.expect("close reason")
.unwrap();
let message = Message::parse_from_bytes(&frame).unwrap();
assert_eq!(message.misc().close_reason(), reason);
drop(controller);
sender.await.unwrap();
}
#[test]
fn test_ip_whitelist_entries_ignore_spaces_around_them() {
let entries = ip_whitelist_entries("192.168.1.0/24, 10.0.0.1 ");
@@ -7623,7 +7430,7 @@ mod test {
.await
.unwrap();
let host = listener.local_addr().unwrap().to_string();
let controller = hbb_common::socket_client::connect_tcp_local(host, None, 3000)
let controller = hbb_common::socket_client::connect_tcp(host, 3000)
.await
.unwrap();
let (accepted, addr) = listener.accept().await.unwrap();
-54
View File
@@ -1,54 +0,0 @@
use super::TerminalUserToken;
use hbb_common::ResultType;
pub(super) const LOG_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60);
const DESKTOP_REQUIRED: &str = "Remote terminal access requires an active desktop session";
pub(super) async fn fill_token(token: &mut Option<TerminalUserToken>) -> Option<&'static str> {
apply_session_check(token, crate::platform::linux::terminal::is_allowed().await)
}
fn apply_session_check(
token: &mut Option<TerminalUserToken>,
result: ResultType<bool>,
) -> Option<&'static str> {
let error = match result {
Ok(true) => None,
Ok(false) => Some(DESKTOP_REQUIRED),
Err(err) => {
hbb_common::throttled_log!(
LOG_INTERVAL,
warn,
"Could not verify the root terminal session: {err:#}"
);
Some("Failed to get user token.")
}
};
*token = error.is_none().then_some(TerminalUserToken::SelfUser);
error
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn only_an_allowed_session_gets_a_token() {
let mut token = None;
assert_eq!(apply_session_check(&mut token, Ok(true)), None);
assert!(matches!(token, Some(TerminalUserToken::SelfUser)));
assert_eq!(
apply_session_check(&mut token, Ok(false)),
Some(DESKTOP_REQUIRED)
);
assert!(token.is_none());
let mut token = Some(TerminalUserToken::SelfUser);
let fault = Err(hbb_common::anyhow::anyhow!("logind unavailable"));
assert_eq!(
apply_session_check(&mut token, fault),
Some("Failed to get user token.")
);
assert!(token.is_none());
}
}
+4 -4
View File
@@ -6,7 +6,7 @@ use crate::trusted_devices::{
};
use base::message_proto::LoginResponse;
impl Connection<'_> {
impl Connection {
pub(super) async fn begin_trusted_device(&mut self) -> bool {
if self.conn_audit_primary_auth != ConnAuditPrimaryAuth::PermanentPassword
|| (!self.stream.is_secured() && !crate::common::is_direct_ip_access(&self.lr.username))
@@ -36,7 +36,7 @@ impl Connection<'_> {
}
Ok(None) => true,
Err(error) => {
self.send_login_error_before_close(error).await;
self.send_login_error(error).await;
false
}
}
@@ -54,7 +54,7 @@ impl Connection<'_> {
return true;
}
self.trusted_device = None;
self.send_login_error_before_close(error).await;
self.send_login_error(error).await;
self.on_close("Trusted-device authentication failed", false)
.await;
return false;
@@ -91,7 +91,7 @@ impl Connection<'_> {
host::log_unavailable(&error);
return true;
}
self.send_login_error_before_close(error).await;
self.send_login_error(error).await;
self.on_close("Trusted-device enrollment failed", false)
.await;
false
+1 -1
View File
@@ -1,5 +1,5 @@
use super::*;
use hbb_common::anyhow;
use hbb_common::{allow_err, anyhow};
use base::platform::linux::DISTRO;
use scrap::{
is_cursor_embedded, set_map_err,
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff. Show more