mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-10 06:21:02 +03:00
Compare commits
69 Commits
04b3e1f40b
...
c4df2e6da2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4df2e6da2 | ||
|
|
b473977aa8 | ||
|
|
81b55dff24 | ||
|
|
9eae353ee5 | ||
|
|
a02063ece8 | ||
|
|
e677fd510a | ||
|
|
7280238993 | ||
|
|
019dd20b30 | ||
|
|
98c0401134 | ||
|
|
3432b8bc30 | ||
|
|
fe1300584c | ||
|
|
6ffb506961 | ||
|
|
8f81561918 | ||
|
|
093790875b | ||
|
|
c99ccdcb0d | ||
|
|
e3ef5317c5 | ||
|
|
59b7987b1d | ||
|
|
00005f6af5 | ||
|
|
6926ad290f | ||
|
|
ef642ae329 | ||
|
|
fa48b3f88d | ||
|
|
d6a670e764 | ||
|
|
39a266cfd5 | ||
|
|
1e00d09f84 | ||
|
|
7a0705bdad | ||
|
|
bfd3a9d7d9 | ||
|
|
2786d12a28 | ||
|
|
cf9c94a677 | ||
|
|
db3830a781 | ||
|
|
2befaa5b6a | ||
|
|
b199024082 | ||
|
|
f578fa189f | ||
|
|
ed09f3cc76 | ||
|
|
2657143712 | ||
|
|
51bbaa3f17 | ||
|
|
09e27370a3 | ||
|
|
0412726a20 | ||
|
|
b319cef200 | ||
|
|
c81c85fb78 | ||
|
|
553d66035e | ||
|
|
4ed2a60e35 | ||
|
|
305b3e5e48 | ||
|
|
5a790443a8 | ||
|
|
47b2c05e1d | ||
|
|
120fc4f4c5 | ||
|
|
55cbd1a218 | ||
|
|
0e61153a94 | ||
|
|
65a819f9e2 | ||
|
|
3d5406aa1c | ||
|
|
c40cb2a93e | ||
|
|
c631cdcf22 | ||
|
|
2f8c8704bb | ||
|
|
b591eeaa76 | ||
|
|
21cdf4d0a1 | ||
|
|
5ce320d1cd | ||
|
|
32ee0c19e3 | ||
|
|
0a135e0fae | ||
|
|
d3d5690bbf | ||
|
|
7e80399689 | ||
|
|
777d6347e4 | ||
|
|
9a1c8da143 | ||
|
|
978c901f49 | ||
|
|
d453a19601 | ||
|
|
50c4e435de | ||
|
|
d5c6d0f6b7 | ||
|
|
b6ff62c74b | ||
|
|
ba6de7990f | ||
|
|
a59ad333fc | ||
|
|
82aa28f129 |
17
.github/workflows/flutter-build.yml
vendored
17
.github/workflows/flutter-build.yml
vendored
@@ -43,6 +43,7 @@ env:
|
||||
# https://github.com/rustdesk/rustdesk/actions/runs/14414119794/job/40427970174
|
||||
# 2. Update the `VCPKG_COMMIT_ID` in `ci.yml` and `playground.yml`.
|
||||
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.0"
|
||||
NDK_VERSION: "r28c"
|
||||
@@ -1536,7 +1537,6 @@ jobs:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set Swap Space
|
||||
if: ${{ matrix.job.arch == 'x86_64' }}
|
||||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
|
||||
with:
|
||||
swap-size-gb: 12
|
||||
@@ -1571,6 +1571,15 @@ jobs:
|
||||
name: bridge-artifact
|
||||
path: ./
|
||||
|
||||
# vcpkg 2026.07.29's SPDX scripts require CMake 4.3+, but this ARM64 runner selects CMake 3.31.
|
||||
- name: Install CMake for vcpkg on Linux ARM64
|
||||
if: matrix.job.arch == 'aarch64' && env.UPLOAD_ARTIFACT == 'true'
|
||||
run: |
|
||||
python3 -m pip install --user "cmake==${VCPKG_CMAKE_VERSION}"
|
||||
user_base="$(python3 -m site --user-base)"
|
||||
"${user_base}/bin/cmake" --version
|
||||
echo "${user_base}/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: Setup vcpkg with Github Actions binary cache
|
||||
if: matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true'
|
||||
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
|
||||
@@ -2141,6 +2150,12 @@ jobs:
|
||||
echo "Modified vcpkg.json for armv7 build:"
|
||||
grep -A 2 -B 2 '"baseline"' vcpkg.json
|
||||
|
||||
- name: Set Swap Space
|
||||
if: matrix.job.arch == 'armv7'
|
||||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
|
||||
with:
|
||||
swap-size-gb: 12
|
||||
|
||||
- name: Free Space
|
||||
run: |
|
||||
df -h
|
||||
|
||||
19
AGENTS.md
19
AGENTS.md
@@ -74,6 +74,25 @@
|
||||
* Accept a little duplication over a restructure. A new function that repeats a few lines of an existing one is a better diff than reshaping the original so both can share it.
|
||||
* Put new logic in self-contained functions in the module it belongs to (platform-specific logic in `src/platform/`, with `use` inside the function body to avoid churning shared import blocks). Call sites in shared files (`src/tray.rs`, `src/core_main.rs`, `src/server/connection.rs`, …) should be thin one-line hooks.
|
||||
|
||||
### Scope check before touching shared code
|
||||
|
||||
* Before changing a shared trait, a shared struct, or the signature of a widely used function, check whether the bug or feature is specific to one path. If it is, keep the change inside that path unless that is impossible, and say in the PR why it was.
|
||||
* If an unrelated caller needs `Default::default()`, `None`, or another placeholder solely to satisfy a signature you changed, the diff is too broad: stop and redesign.
|
||||
* The expected shape of a fix is a new function in the feature's own module, plus at most a new field or a thin hook in the shared code it needs. Feature-specific state belongs beside the feature's existing state, not in a new abstraction every caller has to learn.
|
||||
|
||||
### Mandatory regression-surface check
|
||||
|
||||
Before considering any implementation complete, perform a minimization pass over the final diff.
|
||||
|
||||
* Inspect every modified existing file and every modified existing code path. Each must be strictly necessary for the requested change. Revert changes that are merely cleanup, refactoring, consistency improvements, or fixes for pre-existing issues.
|
||||
* For new features, preserve the existing implementation path when the feature is disabled or unsupported whenever practical. `feature off` should run the old code, not a rewritten equivalent.
|
||||
* Do not route existing behavior through a new abstraction merely to share code with the new feature. Prefer a parallel new function or a small amount of duplication over changing a proven existing path.
|
||||
* Keep new implementation logic in new or feature-specific modules. Changes to shared/core files should normally be thin hooks, capability checks, or protocol plumbing.
|
||||
* Do not fix unrelated pre-existing bugs in the same PR. Put them in a separate change unless they directly block correctness or security of the requested work.
|
||||
* For submodule bumps, inspect the exact commit range and ensure unrelated changes are not being pulled into the parent PR.
|
||||
* Before finalizing, explicitly report the regression surface: list the existing files and existing runtime paths whose behavior changed, and explain why each change is unavoidable.
|
||||
* During review, treat an unnecessarily modified legacy path as a review finding even if tests pass and the rewritten behavior appears equivalent.
|
||||
|
||||
## Reviewing a PR
|
||||
|
||||
* Review only what the diff introduces. Verify ownership with `gh pr diff` before reporting a finding — if the offending lines are untouched context, it is a pre-existing problem, not this PR's.
|
||||
|
||||
302
Cargo.lock
generated
302
Cargo.lock
generated
@@ -753,24 +753,6 @@ dependencies = [
|
||||
"syn 2.0.98",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.71.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools 0.12.1",
|
||||
"proc-macro2 1.0.93",
|
||||
"quote 1.0.36",
|
||||
"regex",
|
||||
"rustc-hash 2.1.1",
|
||||
"shlex",
|
||||
"syn 2.0.98",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.72.1"
|
||||
@@ -1161,30 +1143,6 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "chacha20"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cipher",
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chacha20poly1305"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"chacha20",
|
||||
"cipher",
|
||||
"poly1305",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.41"
|
||||
@@ -1234,7 +1192,6 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"inout",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2324,7 +2281,7 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
|
||||
dependencies = [
|
||||
"libloading 0.8.4",
|
||||
"libloading 0.7.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2442,42 +2399,6 @@ dependencies = [
|
||||
"linux-raw-sys 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtls"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f531dd7c181beaf3cebab3716afa4d0d41ab888be85232583f56bbaf07ca208a"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"byteorder",
|
||||
"cbc",
|
||||
"ccm",
|
||||
"chacha20poly1305",
|
||||
"der-parser",
|
||||
"hmac",
|
||||
"log",
|
||||
"p256",
|
||||
"p384",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand_core 0.6.4",
|
||||
"rcgen",
|
||||
"ring",
|
||||
"rustls",
|
||||
"sec1",
|
||||
"serde 1.0.228",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"thiserror 1.0.61",
|
||||
"tokio",
|
||||
"webrtc-util",
|
||||
"x25519-dalek",
|
||||
"x509-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.8"
|
||||
@@ -2863,7 +2784,7 @@ dependencies = [
|
||||
"is-terminal",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"nu-ansi-term 0.49.0",
|
||||
"nu-ansi-term",
|
||||
"regex",
|
||||
"thiserror 1.0.61",
|
||||
]
|
||||
@@ -3766,6 +3687,7 @@ dependencies = [
|
||||
"mac_address",
|
||||
"machine-uid",
|
||||
"osascript",
|
||||
"percent-encoding",
|
||||
"protobuf",
|
||||
"protobuf-codegen",
|
||||
"rand 0.8.5",
|
||||
@@ -4177,16 +4099,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "interceptor"
|
||||
version = "0.15.0"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea51375727680dc15f06e8ad90fa31df75d79dd030100e8ad60eef1c27fe2c98"
|
||||
checksum = "1ac0781c825d602095113772e389ef0607afcb869ae0e68a590d8e0799cdcef8"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"futures",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"rtcp",
|
||||
"rtp",
|
||||
"thiserror 1.0.61",
|
||||
@@ -4338,11 +4259,11 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "kcp-sys"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rustdesk-org/kcp-sys#32a6c09fc6223f54aea83981a6aa8995931d29be"
|
||||
source = "git+https://github.com/rustdesk-org/kcp-sys?branch=rustdesk-patches#023a0065398968989f2ddfcf5cc72bb886d02675"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"auto_impl",
|
||||
"bindgen 0.71.1",
|
||||
"bindgen 0.72.1",
|
||||
"bitflags 2.9.1",
|
||||
"bytes",
|
||||
"cc",
|
||||
@@ -4353,8 +4274,6 @@ dependencies = [
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zerocopy 0.7.34",
|
||||
]
|
||||
|
||||
@@ -4488,7 +4407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"windows-targets 0.52.6",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5210,16 +5129,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.49.0"
|
||||
@@ -5883,12 +5792,6 @@ dependencies = [
|
||||
"serde_json 1.0.118",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "owned_ttf_parser"
|
||||
version = "0.25.1"
|
||||
@@ -6277,17 +6180,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "poly1305"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
"opaque-debug",
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polyval"
|
||||
version = "0.6.2"
|
||||
@@ -7094,9 +6986,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rtcp"
|
||||
version = "0.14.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81d30d1c4091644431c22acf9f8be6191b56805e0e977f15ca7104b4a6d6eaec"
|
||||
checksum = "e9689528bf3a9eb311fd938d05516dd546412f9ce4fffc8acfc1db27cc3dbf72"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"thiserror 1.0.61",
|
||||
@@ -7105,14 +6997,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rtp"
|
||||
version = "0.14.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f126f38ea84c02480e32e547c1459a939052f74fb92117ac3eef23fdac6b023"
|
||||
checksum = "c54733451a67d76caf9caa07a7a2cec6871ea9dda92a7847f98063d459200f4b"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"memchr",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"serde 1.0.228",
|
||||
"thiserror 1.0.61",
|
||||
"webrtc-util",
|
||||
@@ -7267,6 +7159,7 @@ dependencies = [
|
||||
"terminfo",
|
||||
"termios 0.3.3",
|
||||
"tiny-skia",
|
||||
"tokio",
|
||||
"totp-rs",
|
||||
"tray-icon",
|
||||
"ttf-parser",
|
||||
@@ -7547,11 +7440,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sdp"
|
||||
version = "0.10.0"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32c374dceda16965d541c8800ce9cc4e1c14acfd661ddf7952feeedc3411e5c6"
|
||||
checksum = "4cd277015eada44a0bb810a4b84d3bf6e810573fa62fb442f457edf6a1087a69"
|
||||
dependencies = [
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"substring",
|
||||
"thiserror 1.0.61",
|
||||
"url",
|
||||
@@ -7781,15 +7674,6 @@ dependencies = [
|
||||
"tzdb 0.5.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_library"
|
||||
version = "0.1.9"
|
||||
@@ -8129,15 +8013,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "stun"
|
||||
version = "0.9.0"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a512c5d501e3e3b5a4bb3e8e31462d56d54a66b95a28b8596e14422bf21c32b"
|
||||
checksum = "7dbc2bab375524093c143dc362a03fb6a1fb79e938391cdb21665688f88a088a"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"crc",
|
||||
"lazy_static",
|
||||
"md-5",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"ring",
|
||||
"subtle",
|
||||
"thiserror 1.0.61",
|
||||
@@ -8519,16 +8403,6 @@ dependencies = [
|
||||
"syn 2.0.98",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "threadpool"
|
||||
version = "1.8.1"
|
||||
@@ -8908,32 +8782,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||
dependencies = [
|
||||
"nu-ansi-term 0.46.0",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9048,9 +8896,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "turn"
|
||||
version = "0.11.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ed995882f66ab94238de77c62e5e778389698ab700afa4696f4754da8f457cb"
|
||||
checksum = "3f5aea1116456e1da71c45586b87c72e3b43164fbf435eb93ff6aa475416a9a4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -9058,7 +8906,7 @@ dependencies = [
|
||||
"log",
|
||||
"md-5",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"ring",
|
||||
"stun",
|
||||
"thiserror 1.0.61",
|
||||
@@ -9184,12 +9032,6 @@ dependencies = [
|
||||
"unic-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.15"
|
||||
@@ -9335,12 +9177,6 @@ dependencies = [
|
||||
"bindgen 0.65.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
@@ -9724,25 +9560,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc"
|
||||
version = "0.14.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08fd686c0920ac08f3a57eacc48e31f0e4ca1ffefba4478784606f78c14e83ad"
|
||||
checksum = "24bab7195998d605c862772f90a452ba655b90a2f463c850ac032038890e367a"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"dtls",
|
||||
"cfg-if 1.0.0",
|
||||
"hex",
|
||||
"interceptor",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"rcgen",
|
||||
"regex",
|
||||
"ring",
|
||||
"rtcp",
|
||||
"rtp",
|
||||
"rustls",
|
||||
"sdp",
|
||||
"serde 1.0.228",
|
||||
"serde_json 1.0.118",
|
||||
@@ -9750,12 +9587,13 @@ dependencies = [
|
||||
"smol_str",
|
||||
"stun",
|
||||
"thiserror 1.0.61",
|
||||
"time 0.3.36",
|
||||
"tokio",
|
||||
"turn",
|
||||
"unicase",
|
||||
"url",
|
||||
"waitgroup",
|
||||
"webrtc-data",
|
||||
"webrtc-dtls",
|
||||
"webrtc-ice",
|
||||
"webrtc-mdns",
|
||||
"webrtc-media",
|
||||
@@ -9766,9 +9604,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-data"
|
||||
version = "0.12.0"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "062a5438d63bb0756a221693d76cc0dd6119affee1dfdfe57abe3a2a8c8b3eea"
|
||||
checksum = "4e97b932854da633a767eff0cc805425a2222fc6481e96f463e57b015d949d1d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"log",
|
||||
@@ -9780,17 +9618,54 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-ice"
|
||||
version = "0.14.0"
|
||||
name = "webrtc-dtls"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cb13fd1a373e68addc4bba0c8ca058627518e54342583d024bdcbb8ae5d97d"
|
||||
checksum = "5ccbe4d9049390ab52695c3646c1395c877e16c15fb05d3bda8eee0c7351711c"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"byteorder",
|
||||
"cbc",
|
||||
"ccm",
|
||||
"der-parser",
|
||||
"hkdf",
|
||||
"hmac",
|
||||
"log",
|
||||
"p256",
|
||||
"p384",
|
||||
"portable-atomic",
|
||||
"rand 0.8.5",
|
||||
"rand_core 0.6.4",
|
||||
"rcgen",
|
||||
"ring",
|
||||
"rustls",
|
||||
"sec1",
|
||||
"serde 1.0.228",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"subtle",
|
||||
"thiserror 1.0.61",
|
||||
"tokio",
|
||||
"webrtc-util",
|
||||
"x25519-dalek",
|
||||
"x509-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-ice"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb51bde0d790f109a15bfe4d04f1b56fb51d567da231643cb3f21bb74d678997"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
"crc",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"serde 1.0.228",
|
||||
"serde_json 1.0.118",
|
||||
"stun",
|
||||
@@ -9806,9 +9681,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-mdns"
|
||||
version = "0.10.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a17279a067e75df72ce923fdeb7f04cd808f6f5aa4910dc6bcb4fbe66b396ace"
|
||||
checksum = "979cc85259c53b7b620803509d10d35e2546fa505d228850cbe3f08765ea6ea8"
|
||||
dependencies = [
|
||||
"log",
|
||||
"socket2 0.5.10",
|
||||
@@ -9819,22 +9694,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-media"
|
||||
version = "0.11.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94a84c910fec0848fd5a0d8a5651e0ddbdedaf25a7d3ae3f0b15f71ac73a1773"
|
||||
checksum = "80041211deccda758a3e19aa93d6b10bc1d37c9183b519054b40a83691d13810"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"rtp",
|
||||
"thiserror 1.0.61",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-sctp"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f985465467d8910c1f8ac4382cd64f83b1f6a1a75021a82b221546f6fb3b856f"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/rustdesk-org/webrtc?rev=825a0a4862818f74406d8e1cc25be72259228235#825a0a4862818f74406d8e1cc25be72259228235"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
@@ -9842,7 +9716,7 @@ dependencies = [
|
||||
"crc",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"thiserror 1.0.61",
|
||||
"tokio",
|
||||
"webrtc-util",
|
||||
@@ -9850,9 +9724,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-srtp"
|
||||
version = "0.16.0"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66d8cdc33413f1d0192670a80ce93d17cb78d57fe3a2414be30d6f6dff121123"
|
||||
checksum = "01e773f79b09b057ffbda6b03fe7b43403b012a240cf8d05d630674c3723b5bb"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"aes",
|
||||
@@ -9873,19 +9747,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webrtc-util"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1c0c7e0c8f280f2bbfae442701465777ac07adaf46ce0c5863cd58e13fe472a"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/rustdesk-org/webrtc?rev=825a0a4862818f74406d8e1cc25be72259228235#825a0a4862818f74406d8e1cc25be72259228235"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bitflags 1.3.2",
|
||||
"bytes",
|
||||
"ipnet",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"nix 0.26.4",
|
||||
"portable-atomic",
|
||||
"rand 0.9.2",
|
||||
"rand 0.8.5",
|
||||
"thiserror 1.0.61",
|
||||
"tokio",
|
||||
"winapi 0.3.9",
|
||||
|
||||
15
Cargo.toml
15
Cargo.toml
@@ -52,7 +52,7 @@ screencapturekit = ["cpal/screencapturekit"]
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
scrap = { path = "libs/scrap", features = ["wayland"] }
|
||||
hbb_common = { path = "libs/hbb_common" }
|
||||
hbb_common = { path = "libs/hbb_common", features = ["webrtc"] }
|
||||
serde_derive = "1.0"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
@@ -83,7 +83,7 @@ fon = "0.6"
|
||||
shutdown_hooks = "0.1"
|
||||
totp-rs = { version = "5.4", default-features = false, features = ["gen_secret", "otpauth"] }
|
||||
stunclient = "0.4"
|
||||
kcp-sys= { git = "https://github.com/rustdesk-org/kcp-sys"}
|
||||
kcp-sys= { git = "https://github.com/rustdesk-org/kcp-sys", branch = "rustdesk-patches" }
|
||||
reqwest = { version = "0.12", features = ["blocking", "socks", "json", "native-tls", "rustls-tls", "rustls-tls-native-roots", "gzip", "zstd"], default-features=false }
|
||||
|
||||
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
||||
@@ -215,6 +215,16 @@ exclude = ["vdi/host"]
|
||||
# This allows building and running on systems without libxdo installed (e.g., Wayland-only)
|
||||
[patch.crates-io]
|
||||
libxdo-sys = { path = "libs/libxdo-sys-stub" }
|
||||
# One branch off upstream v0.13.0, the tag whose crate versions match this stack.
|
||||
# webrtc-util: reads the Windows adapter list's IPv6 addresses as host-order u16 groups, so every
|
||||
# one comes out byte-swapped, fails to bind, and ICE gathers no IPv6 host candidate on Windows.
|
||||
# webrtc-sctp: RFC 4960's 1s RTO floor makes a single loss cost 1-3s on a link whose RTT is 24-64ms,
|
||||
# and fast retransmit cannot cover a request/response exchange; INITIAL_MTU 1228 also fragments on
|
||||
# IPv6; and its AIMD pins a lossy long-haul link to MSS/(RTT*sqrt(p)), so a switch sends without
|
||||
# a congestion window, as KCP does - on by default, `allow-webrtc-congestion-control` opts back in.
|
||||
# Pinned by rev, not branch: a fork branch can be rewritten out from under the lockfile.
|
||||
webrtc-util = { git = "https://github.com/rustdesk-org/webrtc", rev = "825a0a4862818f74406d8e1cc25be72259228235" }
|
||||
webrtc-sctp = { git = "https://github.com/rustdesk-org/webrtc", rev = "825a0a4862818f74406d8e1cc25be72259228235" }
|
||||
|
||||
[package.metadata.winres]
|
||||
LegalCopyright = "Copyright © 2026 Purslane Tech Pte. Ltd. All rights reserved."
|
||||
@@ -234,6 +244,7 @@ os-version = "0.2"
|
||||
[dev-dependencies]
|
||||
hound = "3.5"
|
||||
docopt = "1.1"
|
||||
tokio = { version = "1.44", features = ["test-util"] }
|
||||
|
||||
[package.metadata.bundle]
|
||||
name = "RustDesk"
|
||||
|
||||
12
build.rs
12
build.rs
@@ -43,6 +43,15 @@ fn build_manifest() {
|
||||
}
|
||||
}
|
||||
|
||||
// bionic only exports getifaddrs()/freeifaddrs() from API 24, while the jniLibs
|
||||
// are built against the API 21 sysroot (flutter/ndk_*.sh). webrtc-util calls
|
||||
// them, so without this the android link fails on undefined symbols.
|
||||
fn build_android_ifaddrs() {
|
||||
let file = "src/platform/android_ifaddrs.c";
|
||||
cc::Build::new().file(file).compile("android_ifaddrs");
|
||||
println!("cargo:rerun-if-changed={}", file);
|
||||
}
|
||||
|
||||
fn install_android_deps() {
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
if target_os != "android" {
|
||||
@@ -89,5 +98,8 @@ fn main() {
|
||||
build_mac();
|
||||
println!("cargo:rustc-link-lib=framework=ApplicationServices");
|
||||
}
|
||||
if target_os == "android" {
|
||||
build_android_ifaddrs();
|
||||
}
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
||||
@@ -1633,7 +1633,8 @@ String bool2option(String option, bool b) {
|
||||
String res;
|
||||
if (option.startsWith('enable-') &&
|
||||
option != kOptionEnableUdpPunch &&
|
||||
option != kOptionEnableIpv6Punch) {
|
||||
option != kOptionEnableIpv6Punch &&
|
||||
option != kOptionEnableWebrtc) {
|
||||
res = b ? defaultOptionYes : 'N';
|
||||
} else if (option.startsWith('allow-') ||
|
||||
option == kOptionStopService ||
|
||||
|
||||
@@ -606,6 +606,9 @@ class QualityMonitor extends StatelessWidget {
|
||||
_row(
|
||||
"Codec", qualityMonitorModel.data.codecFormat ?? '-'),
|
||||
_row("Chroma", qualityMonitorModel.data.chroma ?? '-'),
|
||||
if (qualityMonitorModel.webrtcTransport != null)
|
||||
_row("Transport",
|
||||
qualityMonitorModel.webrtcTransport!),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -166,10 +166,12 @@ const String kOptionAllowRemoveWallpaper = "allow-remove-wallpaper";
|
||||
const String kOptionStopService = "stop-service";
|
||||
const String kOptionDirectxCapture = "enable-directx-capture";
|
||||
const String kOptionAllowRemoteCmModification = "allow-remote-cm-modification";
|
||||
const String kOptionEnableTcpPunch = "enable-tcp-punch";
|
||||
const String kOptionEnableUdpPunch = "enable-udp-punch";
|
||||
const String kOptionEnableIpv6Punch = "enable-ipv6-punch";
|
||||
const String kOptionAllowSyncClipboardBetweenSessions =
|
||||
"allow-sync-clipboard-between-sessions";
|
||||
const String kOptionEnableWebrtc = "enable-webrtc";
|
||||
const String kOptionEnableTrustedDevices = "enable-trusted-devices";
|
||||
const String kOptionShowVirtualMouse = "show-virtual-mouse";
|
||||
const String kOptionVirtualMouseScale = "virtual-mouse-scale";
|
||||
|
||||
@@ -563,6 +563,12 @@ class _GeneralState extends State<_General> {
|
||||
kOptionDirectxCapture,
|
||||
),
|
||||
if (!isWeb && !incomingOnly) ...[
|
||||
_OptionCheckBox(
|
||||
context,
|
||||
'Enable TCP hole punching',
|
||||
kOptionEnableTcpPunch,
|
||||
isServer: false,
|
||||
),
|
||||
_OptionCheckBox(
|
||||
context,
|
||||
'Enable UDP hole punching',
|
||||
@@ -575,6 +581,15 @@ class _GeneralState extends State<_General> {
|
||||
kOptionEnableIpv6Punch,
|
||||
isServer: false,
|
||||
),
|
||||
],
|
||||
if (!incomingOnly)
|
||||
_OptionCheckBox(
|
||||
context,
|
||||
'Enable WebRTC P2P connection',
|
||||
kOptionEnableWebrtc,
|
||||
isServer: false,
|
||||
),
|
||||
if (!isWeb && !incomingOnly)
|
||||
Tooltip(
|
||||
message: translate('sync-clipboard-between-sessions-tip'),
|
||||
child: _OptionCheckBox(
|
||||
@@ -584,7 +599,6 @@ class _GeneralState extends State<_General> {
|
||||
isServer: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
// Add client-side wakelock option for desktop platforms
|
||||
|
||||
@@ -97,10 +97,12 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
var _hideNetwork = false;
|
||||
var _hideWebSocket = false;
|
||||
var _enableTrustedDevices = false;
|
||||
var _enableTcpPunch = false;
|
||||
var _enableUdpPunch = false;
|
||||
var _allowInsecureTlsFallback = false;
|
||||
var _disableUdp = false;
|
||||
var _enableIpv6Punch = false;
|
||||
var _enableWebrtc = false;
|
||||
var _isUsingPublicServer = false;
|
||||
var _allowAskForNoteAtEndOfConnection = false;
|
||||
var _preventSleepWhileConnected = true;
|
||||
@@ -141,8 +143,10 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
bind.mainGetBuildinOption(key: kOptionHideWebSocketSetting) == 'Y' ||
|
||||
isWeb;
|
||||
_enableTrustedDevices = mainGetBoolOptionSync(kOptionEnableTrustedDevices);
|
||||
_enableTcpPunch = mainGetLocalBoolOptionSync(kOptionEnableTcpPunch);
|
||||
_enableUdpPunch = mainGetLocalBoolOptionSync(kOptionEnableUdpPunch);
|
||||
_enableIpv6Punch = mainGetLocalBoolOptionSync(kOptionEnableIpv6Punch);
|
||||
_enableWebrtc = mainGetLocalBoolOptionSync(kOptionEnableWebrtc);
|
||||
_allowAskForNoteAtEndOfConnection =
|
||||
mainGetLocalBoolOptionSync(kOptionAllowAskForNoteAtEndOfConnection);
|
||||
_preventSleepWhileConnected =
|
||||
@@ -815,31 +819,65 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
});
|
||||
},
|
||||
),
|
||||
if (!incomingOnly)
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('Enable TCP hole punching')),
|
||||
initialValue: _enableTcpPunch,
|
||||
onToggle: isOptionFixed(kOptionEnableTcpPunch)
|
||||
? null
|
||||
: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableTcpPunch, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableTcpPunch);
|
||||
setState(() {
|
||||
_enableTcpPunch = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (!incomingOnly)
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('Enable UDP hole punching')),
|
||||
initialValue: _enableUdpPunch,
|
||||
onToggle: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableUdpPunch, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableUdpPunch);
|
||||
setState(() {
|
||||
_enableUdpPunch = newValue;
|
||||
});
|
||||
},
|
||||
onToggle: isOptionFixed(kOptionEnableUdpPunch)
|
||||
? null
|
||||
: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableUdpPunch, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableUdpPunch);
|
||||
setState(() {
|
||||
_enableUdpPunch = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (!incomingOnly)
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('Enable IPv6 P2P connection')),
|
||||
initialValue: _enableIpv6Punch,
|
||||
onToggle: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableIpv6Punch, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableIpv6Punch);
|
||||
setState(() {
|
||||
_enableIpv6Punch = newValue;
|
||||
});
|
||||
},
|
||||
onToggle: isOptionFixed(kOptionEnableIpv6Punch)
|
||||
? null
|
||||
: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableIpv6Punch, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableIpv6Punch);
|
||||
setState(() {
|
||||
_enableIpv6Punch = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (!incomingOnly)
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('Enable WebRTC P2P connection')),
|
||||
initialValue: _enableWebrtc,
|
||||
onToggle: isOptionFixed(kOptionEnableWebrtc)
|
||||
? null
|
||||
: (v) async {
|
||||
await mainSetLocalBoolOption(kOptionEnableWebrtc, v);
|
||||
final newValue =
|
||||
mainGetLocalBoolOptionSync(kOptionEnableWebrtc);
|
||||
setState(() {
|
||||
_enableWebrtc = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
SettingsTile(
|
||||
title: Text(translate('Language')),
|
||||
|
||||
@@ -3597,6 +3597,16 @@ class QualityMonitorModel with ChangeNotifier {
|
||||
bool get show => _show;
|
||||
QualityMonitorData get data => _data;
|
||||
|
||||
// Only a WebRTC session names its transport here: web has no session tab
|
||||
// to show it on, and WebRTC is the one path that can be direct or TURN.
|
||||
String? get webrtcTransport {
|
||||
final ffiModel = parent.target?.ffiModel;
|
||||
if (ffiModel == null) return null;
|
||||
final streamType = ffiModel.cachedPeerData.streamType;
|
||||
if (!streamType.startsWith('WebRTC')) return null;
|
||||
return ffiModel.direct == false ? '$streamType (TURN)' : streamType;
|
||||
}
|
||||
|
||||
checkShowQualityMonitor(SessionID sessionId) async {
|
||||
final show = await bind.sessionGetToggleOption(
|
||||
sessionId: sessionId, arg: 'show-quality-monitor') ==
|
||||
|
||||
Submodule libs/hbb_common updated: 05ed68fed8...470612bdfb
@@ -143,7 +143,7 @@ fn test_vpx(
|
||||
println!(
|
||||
"{:?} encode: {:?}, {} byte",
|
||||
codec_id,
|
||||
time_sum / yuv_count as _,
|
||||
time_sum / yuv_count as u32,
|
||||
size / yuv_count
|
||||
);
|
||||
|
||||
@@ -156,7 +156,7 @@ fn test_vpx(
|
||||
println!(
|
||||
"{:?} decode: {:?}",
|
||||
codec_id,
|
||||
start.elapsed() / yuv_count as _
|
||||
start.elapsed() / yuv_count as u32
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ fn test_av1(
|
||||
assert_eq!(av1s.len(), yuv_count);
|
||||
println!(
|
||||
"AV1 encode: {:?}, {} byte",
|
||||
time_sum / yuv_count as _,
|
||||
time_sum / yuv_count as u32,
|
||||
size / yuv_count
|
||||
);
|
||||
let mut decoder = AomDecoder::new().unwrap();
|
||||
@@ -221,7 +221,7 @@ fn test_av1(
|
||||
let _ = decoder.decode(&av1);
|
||||
let _ = decoder.flush();
|
||||
}
|
||||
println!("AV1 decode: {:?}", start.elapsed() / yuv_count as _);
|
||||
println!("AV1 decode: {:?}", start.elapsed() / yuv_count as u32);
|
||||
}
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
|
||||
@@ -87,7 +87,7 @@ if(VCPKG_HOST_IS_WINDOWS)
|
||||
vcpkg_acquire_msys(MSYS_ROOT PACKAGES automake1.16)
|
||||
set(SHELL "${MSYS_ROOT}/usr/bin/bash.exe")
|
||||
vcpkg_add_to_path("${MSYS_ROOT}/usr/share/automake-1.16")
|
||||
string(APPEND OPTIONS " --pkg-config=${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf/pkgconf${VCPKG_HOST_EXECUTABLE_SUFFIX}")
|
||||
string(APPEND OPTIONS " --pkg-config=${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf/pkgconf${VCPKG_HOST_EXECUTABLE_SUFFIX} ")
|
||||
else()
|
||||
find_program(SHELL bash)
|
||||
endif()
|
||||
|
||||
1328
src/client.rs
1328
src/client.rs
File diff suppressed because it is too large
Load Diff
@@ -185,6 +185,14 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
.unwrap()
|
||||
.set_connected();
|
||||
let is_secured = peer.is_secured();
|
||||
// Only WebRTC needs refining: its label names the transport that won the race,
|
||||
// not the family ICE ended up nominating, and it is the one path where the two
|
||||
// can disagree with the address the rendezvous observed.
|
||||
let stream_type = if peer.webrtc_remote_ipv6().await.unwrap_or(false) {
|
||||
"WebRTC/IPv6"
|
||||
} else {
|
||||
stream_type
|
||||
};
|
||||
self.handler
|
||||
.set_connection_type(is_secured, direct, stream_type); // flutter -> connection_ready
|
||||
if !is_secured
|
||||
|
||||
259
src/common.rs
259
src/common.rs
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
future::Future,
|
||||
net::{SocketAddr, ToSocketAddrs},
|
||||
net::SocketAddr,
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
task::Poll,
|
||||
};
|
||||
@@ -1153,6 +1153,13 @@ pub fn is_public(url: &str) -> bool {
|
||||
host == "rustdesk.com" || host.ends_with(".rustdesk.com")
|
||||
}
|
||||
|
||||
pub fn get_tcp_punch_enabled() -> bool {
|
||||
config::option2bool(
|
||||
keys::OPTION_ENABLE_TCP_PUNCH,
|
||||
&get_local_option(keys::OPTION_ENABLE_TCP_PUNCH),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_udp_punch_enabled() -> bool {
|
||||
config::option2bool(
|
||||
keys::OPTION_ENABLE_UDP_PUNCH,
|
||||
@@ -1167,9 +1174,19 @@ pub fn get_ipv6_punch_enabled() -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_webrtc_enabled() -> bool {
|
||||
config::option2bool(
|
||||
keys::OPTION_ENABLE_WEBRTC,
|
||||
&get_local_option(keys::OPTION_ENABLE_WEBRTC),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_local_option(key: &str) -> String {
|
||||
let v = LocalConfig::get_option(key);
|
||||
if key == keys::OPTION_ENABLE_UDP_PUNCH || key == keys::OPTION_ENABLE_IPV6_PUNCH {
|
||||
if key == keys::OPTION_ENABLE_UDP_PUNCH
|
||||
|| key == keys::OPTION_ENABLE_IPV6_PUNCH
|
||||
|| key == keys::OPTION_ENABLE_WEBRTC
|
||||
{
|
||||
if v.is_empty() {
|
||||
if !is_public(&Config::get_rendezvous_server()) {
|
||||
return "N".to_owned();
|
||||
@@ -2126,11 +2143,21 @@ pub fn get_rs_pk(str_base64: &str) -> Option<sign::PublicKey> {
|
||||
}
|
||||
|
||||
pub fn decode_id_pk(signed: &[u8], key: &sign::PublicKey) -> ResultType<(String, [u8; 32])> {
|
||||
let (id, pk, _) = decode_id_pk_dtls(signed, key)?;
|
||||
Ok((id, pk))
|
||||
}
|
||||
|
||||
/// Like [`decode_id_pk`] but also returns the signed DTLS certificate fingerprint (empty string
|
||||
/// for non-WebRTC peers), used to bind a WebRTC DTLS channel to the verified peer identity.
|
||||
pub fn decode_id_pk_dtls(
|
||||
signed: &[u8],
|
||||
key: &sign::PublicKey,
|
||||
) -> ResultType<(String, [u8; 32], String)> {
|
||||
let res = IdPk::parse_from_bytes(
|
||||
&sign::verify(signed, key).map_err(|_| anyhow!("Signature mismatch"))?,
|
||||
)?;
|
||||
if let Some(pk) = get_pk(&res.pk) {
|
||||
Ok((res.id, pk))
|
||||
Ok((res.id, pk, res.dtls_fingerprint))
|
||||
} else {
|
||||
bail!("Wrong their public length");
|
||||
}
|
||||
@@ -2432,16 +2459,26 @@ pub fn is_udp_disabled() -> bool {
|
||||
Config::get_option(keys::OPTION_DISABLE_UDP) == "Y"
|
||||
}
|
||||
|
||||
/// Run KCP with its congestion window (nc=0) instead of the turbo profile it has always shipped.
|
||||
///
|
||||
/// Opt-in: which profile wins depends on why packets are lost — nc=1 deepens real congestion,
|
||||
/// while nc=0 reads random loss as congestion and its RTO backoff drops cwnd to 1. Undecidable
|
||||
/// without a shaped link, so keep what users run today.
|
||||
#[inline]
|
||||
pub fn get_kcp_cc_enabled() -> bool {
|
||||
let k = keys::OPTION_ALLOW_KCP_CC;
|
||||
config::option2bool(k, &Config::get_option(k))
|
||||
}
|
||||
|
||||
// this crate https://github.com/yoshd/stun-client supports nat type
|
||||
async fn stun_ipv6_test(stun_server: &str) -> ResultType<(SocketAddr, String)> {
|
||||
use std::net::ToSocketAddrs;
|
||||
async fn stun_ipv6_test(stun_server: String) -> ResultType<(SocketAddr, String)> {
|
||||
use stunclient::StunClient;
|
||||
let local_addr = SocketAddr::from(([0u16; 8], 0)); // [::]:0
|
||||
let socket = UdpSocket::bind(&local_addr).await?;
|
||||
let Some(stun_addr) = stun_server
|
||||
.to_socket_addrs()?
|
||||
.filter(|x| x.is_ipv6())
|
||||
.next()
|
||||
// Resolve via tokio so DNS never blocks the async runtime worker.
|
||||
let Some(stun_addr) = tokio::net::lookup_host(&stun_server)
|
||||
.await?
|
||||
.find(|x| x.is_ipv6())
|
||||
else {
|
||||
bail!(
|
||||
"Failed to resolve STUN ipv6 server address: {}",
|
||||
@@ -2451,81 +2488,36 @@ async fn stun_ipv6_test(stun_server: &str) -> ResultType<(SocketAddr, String)> {
|
||||
let client = StunClient::new(stun_addr);
|
||||
let addr = client.query_external_address_async(&socket).await?;
|
||||
Ok(if addr.ip().is_ipv6() {
|
||||
(addr, stun_server.to_owned())
|
||||
(addr, stun_server)
|
||||
} else {
|
||||
bail!("STUN server returned non-IPv6 address: {}", addr)
|
||||
})
|
||||
}
|
||||
|
||||
async fn stun_ipv4_test(stun_server: &str) -> ResultType<(SocketAddr, String)> {
|
||||
use std::net::ToSocketAddrs;
|
||||
use stunclient::StunClient;
|
||||
let local_addr = SocketAddr::from(([0u8; 4], 0));
|
||||
let socket = UdpSocket::bind(&local_addr).await?;
|
||||
let Some(stun_addr) = stun_server
|
||||
.to_socket_addrs()?
|
||||
.filter(|x| x.is_ipv4())
|
||||
.next()
|
||||
else {
|
||||
bail!(
|
||||
"Failed to resolve STUN ipv4 server address: {}",
|
||||
stun_server
|
||||
);
|
||||
};
|
||||
let client = StunClient::new(stun_addr);
|
||||
let addr = client.query_external_address_async(&socket).await?;
|
||||
Ok(if addr.ip().is_ipv4() {
|
||||
(addr, stun_server.to_owned())
|
||||
} else {
|
||||
bail!("STUN server returned non-IPv6 address: {}", addr)
|
||||
})
|
||||
}
|
||||
|
||||
static STUNS_V4: [&str; 3] = [
|
||||
"stun.l.google.com:19302",
|
||||
"stun.cloudflare.com:3478",
|
||||
"stun.nextcloud.com:3478",
|
||||
];
|
||||
|
||||
static STUNS_V6: [&str; 3] = [
|
||||
"stun.l.google.com:19302",
|
||||
"stun.cloudflare.com:3478",
|
||||
"stun.nextcloud.com:3478",
|
||||
];
|
||||
|
||||
pub async fn test_nat_ipv4() -> ResultType<(SocketAddr, String)> {
|
||||
use hbb_common::futures::future::{select_ok, FutureExt};
|
||||
let tests = STUNS_V4
|
||||
.iter()
|
||||
.map(|&stun| stun_ipv4_test(stun).boxed())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
match select_ok(tests).await {
|
||||
Ok(res) => {
|
||||
return Ok(res.0);
|
||||
}
|
||||
Err(e) => {
|
||||
bail!(
|
||||
"Failed to get public IPv4 address via public STUN servers: {}",
|
||||
e
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async fn test_bind_ipv6() -> ResultType<SocketAddr> {
|
||||
use hbb_common::futures::future::FutureExt;
|
||||
let local_addr = SocketAddr::from(([0u16; 8], 0)); // [::]:0
|
||||
let socket = UdpSocket::bind(local_addr).await?;
|
||||
let addr = STUNS_V6[0]
|
||||
.to_socket_addrs()?
|
||||
.filter(|x| x.is_ipv6())
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"Failed to resolve STUN ipv6 server address: {}",
|
||||
STUNS_V6[0]
|
||||
)
|
||||
})?;
|
||||
// Nothing is sent - `connect` only makes the kernel pick a route and a source address - so any
|
||||
// resolvable target answers equally and the whole cost is DNS. Race the lookups rather than
|
||||
// walk them: this is awaited inline on the connection path, not every STUN host publishes a
|
||||
// AAAA, and one resolver that hangs must not decide whether this host has v6.
|
||||
let lookups = hbb_common::webrtc::WebRTCStream::default_stun_servers()
|
||||
.into_iter()
|
||||
.map(|stun| {
|
||||
(async move {
|
||||
let addr = tokio::net::lookup_host(&stun)
|
||||
.await?
|
||||
.find(|x| x.is_ipv6())
|
||||
.ok_or_else(|| {
|
||||
anyhow!("Failed to resolve STUN ipv6 server address: {}", stun)
|
||||
})?;
|
||||
Ok::<SocketAddr, hbb_common::anyhow::Error>(addr)
|
||||
})
|
||||
.boxed()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let (addr, _) = hbb_common::futures::future::select_ok(lookups).await?;
|
||||
socket.connect(addr).await?;
|
||||
Ok(socket.local_addr()?)
|
||||
}
|
||||
@@ -2592,9 +2584,9 @@ pub async fn test_ipv6() -> Option<tokio::task::JoinHandle<()>> {
|
||||
|
||||
Some(tokio::spawn(async {
|
||||
use hbb_common::futures::future::{select_ok, FutureExt};
|
||||
let tests = STUNS_V6
|
||||
.iter()
|
||||
.map(|&stun| stun_ipv6_test(stun).boxed())
|
||||
let tests = hbb_common::webrtc::WebRTCStream::default_stun_servers()
|
||||
.into_iter()
|
||||
.map(|stun| stun_ipv6_test(stun).boxed())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
match select_ok(tests).await {
|
||||
@@ -2615,51 +2607,114 @@ pub async fn test_ipv6() -> Option<tokio::task::JoinHandle<()>> {
|
||||
}))
|
||||
}
|
||||
|
||||
// A punch packet carries a magic and a transaction id so a reply can be *proven* to answer this
|
||||
// probe. The punch it replaces sent a zero-length datagram and called the hole open on whatever
|
||||
// arrived next - which the rendezvous NAT test's own leftover replies satisfied instantly, so the
|
||||
// retry loop below never actually ran and its success meant nothing.
|
||||
const PUNCH_PROBE: [u8; 4] = *b"RDP?";
|
||||
const PUNCH_ACK: [u8; 4] = *b"RDP!";
|
||||
const PUNCH_PACKET_LEN: usize = 12;
|
||||
|
||||
fn punch_packet(tag: &[u8; 4], tid: u64) -> [u8; PUNCH_PACKET_LEN] {
|
||||
let mut packet = [0u8; PUNCH_PACKET_LEN];
|
||||
packet[..4].copy_from_slice(tag);
|
||||
packet[4..].copy_from_slice(&tid.to_le_bytes());
|
||||
packet
|
||||
}
|
||||
|
||||
fn punch_tid(packet: &[u8], tag: &[u8; 4]) -> Option<u64> {
|
||||
if packet.len() != PUNCH_PACKET_LEN || packet[..4] != tag[..] {
|
||||
return None;
|
||||
}
|
||||
packet[4..].try_into().ok().map(u64::from_le_bytes)
|
||||
}
|
||||
|
||||
/// Punch until one of our own probes is acknowledged. Both ends run this identically - each
|
||||
/// probes, each answers the other's probes - and each returns only once a reply carrying its own
|
||||
/// transaction id comes back, the one thing that proves the pair carries traffic both ways.
|
||||
///
|
||||
/// Returning is therefore a fact rather than a guess, which is what lets the caller stop instead
|
||||
/// of handing a dead socket to a transport whose only way to discover the truth is to time out.
|
||||
///
|
||||
/// A datagram that is neither probe nor acknowledgement is returned rather than dropped: it means
|
||||
/// the peer finished first and is already speaking KCP, whose SYN is never retransmitted.
|
||||
///
|
||||
/// Only the connector stops on its own acknowledgement, because only it has something to send
|
||||
/// next. An acknowledgement proves our probe came back, not that the peer's probe was answered -
|
||||
/// and after this returns nothing answers probes any more, since KCP's io loop drops anything
|
||||
/// shorter than its header. A listener that stopped here would go mute while a peer whose own
|
||||
/// probe or answer was lost - the normal state of a hole that is still opening - kept probing an
|
||||
/// endpoint that works, until it timed out. So the listener stops on the peer's first real packet.
|
||||
pub async fn punch_udp(
|
||||
socket: Arc<UdpSocket>,
|
||||
listen: bool,
|
||||
) -> ResultType<Option<bytes::BytesMut>> {
|
||||
let tid = ((hbb_common::time_based_rand() as u64) << 32) | hbb_common::time_based_rand() as u64;
|
||||
let probe = punch_packet(&PUNCH_PROBE, tid);
|
||||
let mut data = [0u8; 1500];
|
||||
// `connect` does not flush the receive queue, so the NAT test's extra replies are still in it.
|
||||
while socket.try_recv(&mut data).is_ok() {}
|
||||
|
||||
let mut retry_interval = Duration::from_millis(20);
|
||||
const MAX_INTERVAL: Duration = Duration::from_millis(200);
|
||||
const MAX_TIME: Duration = Duration::from_secs(20);
|
||||
let mut packets_sent = 0;
|
||||
socket.send(&[]).await.ok();
|
||||
packets_sent += 1;
|
||||
// Both ends start within one rendezvous round trip of each other and the acknowledgement is
|
||||
// one peer round trip, so a pair that has not answered in this long is not going to. The old
|
||||
// 20s came from having no way to tell "not yet" from "never".
|
||||
const MAX_TIME: Duration = Duration::from_secs(3);
|
||||
let mut probes_sent = 0u32;
|
||||
let mut probes_seen = 0u32;
|
||||
let mut acked = false;
|
||||
let mut recv_errors = 0u32;
|
||||
socket.send(&probe).await.ok();
|
||||
probes_sent += 1;
|
||||
let mut last_send_time = Instant::now();
|
||||
let tm = Instant::now();
|
||||
let mut data = [0u8; 1500];
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = hbb_common::sleep(retry_interval.as_secs_f32()) => {
|
||||
if tm.elapsed() > MAX_TIME {
|
||||
bail!("UDP punch is timed out, stop sending packets after {:?} packets", packets_sent);
|
||||
bail!("UDP punch is timed out, {probes_sent} probes sent, {probes_seen} probes received, acked: {acked}, {recv_errors} recv errors absorbed");
|
||||
}
|
||||
let elapsed = last_send_time.elapsed();
|
||||
|
||||
if elapsed >= retry_interval {
|
||||
socket.send(&[]).await.ok();
|
||||
packets_sent += 1;
|
||||
|
||||
// Exponentially increase interval to reduce network pressure
|
||||
retry_interval = std::cmp::min(
|
||||
Duration::from_millis((retry_interval.as_millis() as f64 * 1.5) as u64),
|
||||
MAX_INTERVAL
|
||||
);
|
||||
if last_send_time.elapsed() >= retry_interval {
|
||||
socket.send(&probe).await.ok();
|
||||
probes_sent += 1;
|
||||
retry_interval = std::cmp::min(retry_interval.mul_f64(1.5), MAX_INTERVAL);
|
||||
last_send_time = Instant::now();
|
||||
}
|
||||
}
|
||||
res = socket.recv(&mut data) => match res {
|
||||
Err(e) => bail!("UDP punch failed, {packets_sent} packets sent: {e}"),
|
||||
Err(e) => {
|
||||
// ICMP unreachable from the peer's NAT is expected while the hole forms and
|
||||
// surfaces here as ConnectionReset/Refused; treat it as loss, MAX_TIME bounds
|
||||
// the attempt. Log only the first - this retries every 10ms.
|
||||
recv_errors += 1;
|
||||
if recv_errors == 1 {
|
||||
log::debug!("UDP punch recv error (treated as loss): {e}");
|
||||
}
|
||||
hbb_common::sleep(0.01).await;
|
||||
}
|
||||
Ok(n) => {
|
||||
// log::debug!("UDP punch succeeded after sending {} packets after {:?}", packets_sent, tm.elapsed());
|
||||
if listen {
|
||||
if n == 0 {
|
||||
continue;
|
||||
let ack = punch_tid(&data[..n], &PUNCH_ACK);
|
||||
if ack == Some(tid) {
|
||||
if !listen {
|
||||
log::debug!(
|
||||
"UDP punch confirmed in {:?}, {probes_sent} probes sent, {probes_seen} received",
|
||||
tm.elapsed()
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
acked = true;
|
||||
} else if let Some(peer_tid) = punch_tid(&data[..n], &PUNCH_PROBE) {
|
||||
probes_seen += 1;
|
||||
socket.send(&punch_packet(&PUNCH_ACK, peer_tid)).await.ok();
|
||||
} else if ack.is_none() && n > 0 {
|
||||
log::debug!(
|
||||
"UDP punch confirmed by {n} bytes of peer data in {:?}, {probes_sent} probes sent",
|
||||
tm.elapsed()
|
||||
);
|
||||
return Ok(Some(bytes::BytesMut::from(&data[..n])));
|
||||
}
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
129
src/ipc/auth.rs
129
src/ipc/auth.rs
@@ -24,7 +24,6 @@ use std::os::windows::io::AsRawHandle;
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
sync::{Mutex, OnceLock},
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use windows::Win32::{Foundation::HANDLE, System::Pipes::GetNamedPipeClientProcessId};
|
||||
@@ -520,66 +519,17 @@ pub(crate) fn ensure_peer_executable_matches_current_by_fd(
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
const UNAUTHORIZED_IPC_LOG_INTERVAL: std::time::Duration = std::time::Duration::from_secs(5);
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
#[derive(Default)]
|
||||
struct UnauthorizedIpcLogThrottle {
|
||||
last_log_at: Option<std::time::Instant>,
|
||||
suppressed: u64,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
impl UnauthorizedIpcLogThrottle {
|
||||
#[inline]
|
||||
fn on_reject(&mut self, now: std::time::Instant) -> Option<u64> {
|
||||
if let Some(last) = self.last_log_at {
|
||||
if now.saturating_duration_since(last) < UNAUTHORIZED_IPC_LOG_INTERVAL {
|
||||
self.suppressed += 1;
|
||||
return None;
|
||||
}
|
||||
}
|
||||
self.last_log_at = Some(now);
|
||||
Some(std::mem::take(&mut self.suppressed))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
#[inline]
|
||||
fn throttled_unauthorized_ipc_log(
|
||||
throttle_cell: &OnceLock<Mutex<UnauthorizedIpcLogThrottle>>,
|
||||
emit: impl FnOnce(u64),
|
||||
) {
|
||||
let throttle = throttle_cell.get_or_init(|| Mutex::new(UnauthorizedIpcLogThrottle::default()));
|
||||
let should_log = match throttle.lock() {
|
||||
Ok(mut throttle) => throttle.on_reject(std::time::Instant::now()),
|
||||
Err(_) => Some(0),
|
||||
};
|
||||
if let Some(suppressed) = should_log {
|
||||
emit(suppressed);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[inline]
|
||||
fn log_rejected_service_connection(postfix: &str, peer_uid: Option<u32>, active_uid: Option<u32>) {
|
||||
static LOG_THROTTLE: OnceLock<Mutex<UnauthorizedIpcLogThrottle>> = OnceLock::new();
|
||||
throttled_unauthorized_ipc_log(&LOG_THROTTLE, |suppressed| {
|
||||
if suppressed > 0 {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on protected service-scoped IPC channel: postfix={}, peer_uid={:?}, active_uid={:?} (suppressed {} similar events)",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid,
|
||||
suppressed
|
||||
);
|
||||
} else {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on protected service-scoped IPC channel: postfix={}, peer_uid={:?}, active_uid={:?}",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid
|
||||
);
|
||||
}
|
||||
});
|
||||
hbb_common::throttled_log!(
|
||||
UNAUTHORIZED_IPC_LOG_INTERVAL,
|
||||
warn,
|
||||
"Rejected unauthorized connection on protected service-scoped IPC channel: postfix={}, peer_uid={:?}, active_uid={:?}",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -589,25 +539,14 @@ pub(crate) fn log_rejected_uinput_connection(
|
||||
peer_uid: Option<u32>,
|
||||
active_uid: Option<u32>,
|
||||
) {
|
||||
static LOG_THROTTLE: OnceLock<Mutex<UnauthorizedIpcLogThrottle>> = OnceLock::new();
|
||||
throttled_unauthorized_ipc_log(&LOG_THROTTLE, |suppressed| {
|
||||
if suppressed > 0 {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on uinput ipc channel: postfix={}, peer_uid={:?}, active_uid={:?} (suppressed {} similar events)",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid,
|
||||
suppressed
|
||||
);
|
||||
} else {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on uinput ipc channel: postfix={}, peer_uid={:?}, active_uid={:?}",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid
|
||||
);
|
||||
}
|
||||
});
|
||||
hbb_common::throttled_log!(
|
||||
UNAUTHORIZED_IPC_LOG_INTERVAL,
|
||||
warn,
|
||||
"Rejected unauthorized connection on uinput ipc channel: postfix={}, peer_uid={:?}, active_uid={:?}",
|
||||
postfix,
|
||||
peer_uid,
|
||||
active_uid
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -620,31 +559,17 @@ pub(crate) fn log_rejected_windows_ipc_connection(
|
||||
peer_is_system: Option<bool>,
|
||||
peer_is_elevated: Option<bool>,
|
||||
) {
|
||||
static LOG_THROTTLE: OnceLock<Mutex<UnauthorizedIpcLogThrottle>> = OnceLock::new();
|
||||
throttled_unauthorized_ipc_log(&LOG_THROTTLE, |suppressed| {
|
||||
if suppressed > 0 {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on ipc channel: postfix={}, peer_pid={:?}, peer_session_id={:?}, expected_session_id={:?}, peer_is_system={:?}, peer_is_elevated={:?} (suppressed {} similar events)",
|
||||
postfix,
|
||||
peer_pid,
|
||||
peer_session_id,
|
||||
expected_session_id,
|
||||
peer_is_system,
|
||||
peer_is_elevated,
|
||||
suppressed
|
||||
);
|
||||
} else {
|
||||
log::warn!(
|
||||
"Rejected unauthorized connection on ipc channel: postfix={}, peer_pid={:?}, peer_session_id={:?}, expected_session_id={:?}, peer_is_system={:?}, peer_is_elevated={:?}",
|
||||
postfix,
|
||||
peer_pid,
|
||||
peer_session_id,
|
||||
expected_session_id,
|
||||
peer_is_system,
|
||||
peer_is_elevated
|
||||
);
|
||||
}
|
||||
});
|
||||
hbb_common::throttled_log!(
|
||||
UNAUTHORIZED_IPC_LOG_INTERVAL,
|
||||
warn,
|
||||
"Rejected unauthorized connection on ipc channel: postfix={}, peer_pid={:?}, peer_session_id={:?}, expected_session_id={:?}, peer_is_system={:?}, peer_is_elevated={:?}",
|
||||
postfix,
|
||||
peer_pid,
|
||||
peer_session_id,
|
||||
expected_session_id,
|
||||
peer_is_system,
|
||||
peer_is_elevated
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
|
||||
@@ -19,7 +19,28 @@ pub struct KcpStream {
|
||||
stop_sender: Option<oneshot::Sender<()>>,
|
||||
}
|
||||
|
||||
const KCP_IO_ERR_LOG_INTERVAL: std::time::Duration = std::time::Duration::from_secs(5);
|
||||
static KCP_SEND_ERR_LOG: hbb_common::log_throttle::LogThrottle =
|
||||
hbb_common::log_throttle::LogThrottle::new(KCP_IO_ERR_LOG_INTERVAL);
|
||||
static KCP_RECV_ERR_LOG: hbb_common::log_throttle::LogThrottle =
|
||||
hbb_common::log_throttle::LogThrottle::new(KCP_IO_ERR_LOG_INTERVAL);
|
||||
|
||||
impl KcpStream {
|
||||
// Opt in to KCP's built-in congestion window (nc=0) instead of the pure turbo profile
|
||||
// (nc=1) that has always shipped; see `get_kcp_cc_enabled` for why this is not the default.
|
||||
// Sender-side only, so no wire negotiation is needed and either peer may run either profile.
|
||||
// Requires kcp-sys from the `rustdesk-patches` branch, which wires the config factory into
|
||||
// connection setup (on older revs the factory was stored but never consulted).
|
||||
fn apply_kcp_config(endpoint: &mut KcpEndpoint) {
|
||||
if crate::get_kcp_cc_enabled() {
|
||||
endpoint.set_kcp_config_factory(Box::new(|conv| {
|
||||
let mut config = kcp_sys::ffi_safe::KcpConfig::new_turbo(conv);
|
||||
config.nc = Some(0);
|
||||
config
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
fn create_framed(stream: stream::KcpStream, local_addr: Option<SocketAddr>) -> Stream {
|
||||
Stream::Tcp(FramedStream(
|
||||
tokio_util::codec::Framed::new(DynTcpStream(Box::new(stream)), BytesCodec::new()),
|
||||
@@ -35,6 +56,7 @@ impl KcpStream {
|
||||
init_packet: Option<BytesMut>,
|
||||
) -> ResultType<(Self, Stream)> {
|
||||
let mut endpoint = KcpEndpoint::new();
|
||||
Self::apply_kcp_config(&mut endpoint);
|
||||
endpoint.run().await;
|
||||
|
||||
let (input, output) = (
|
||||
@@ -70,6 +92,7 @@ impl KcpStream {
|
||||
timeout: std::time::Duration,
|
||||
) -> ResultType<(Self, Stream)> {
|
||||
let mut endpoint = KcpEndpoint::new();
|
||||
Self::apply_kcp_config(&mut endpoint);
|
||||
endpoint.run().await;
|
||||
|
||||
let (input, output) = (
|
||||
@@ -104,6 +127,10 @@ impl KcpStream {
|
||||
let udp = udp_socket.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut buf = vec![0; 1500];
|
||||
// Socket errors are ICMP unreachable on a connected UDP socket — advisory, and
|
||||
// routine while a hole forms — so treat them as loss and let KCP's pong timeout reap
|
||||
// a link that is really dead. One throttle PER DIRECTION: the error is reported once
|
||||
// and cleared, so send-ok/recv-err alternates and a shared counter never fires.
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = &mut stop_receiver => {
|
||||
@@ -112,8 +139,10 @@ impl KcpStream {
|
||||
}
|
||||
Some(data) = output.recv() => {
|
||||
if let Err(e) = udp.send(&data.inner()).await {
|
||||
log::debug!("KCP send error: {:?}", e);
|
||||
break;
|
||||
if let Some(n) = KCP_SEND_ERR_LOG.due() {
|
||||
log::debug!("KCP send error x{n} (treated as loss), last: {e}");
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
||||
}
|
||||
}
|
||||
result = udp.recv_from(&mut buf) => {
|
||||
@@ -127,8 +156,10 @@ impl KcpStream {
|
||||
.await.ok();
|
||||
}
|
||||
Err(e) => {
|
||||
log::debug!("KCP recv_from error: {:?}", e);
|
||||
break;
|
||||
if let Some(n) = KCP_RECV_ERR_LOG.due() {
|
||||
log::debug!("KCP recv error x{n} (treated as loss), last: {e}");
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,3 +180,124 @@ impl Drop for KcpStream {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::time::Duration;
|
||||
|
||||
async fn connected_pair() -> (Arc<UdpSocket>, Arc<UdpSocket>) {
|
||||
let a = UdpSocket::bind("127.0.0.1:0").await.unwrap();
|
||||
let b = UdpSocket::bind("127.0.0.1:0").await.unwrap();
|
||||
a.connect(b.local_addr().unwrap()).await.unwrap();
|
||||
b.connect(a.local_addr().unwrap()).await.unwrap();
|
||||
(Arc::new(a), Arc::new(b))
|
||||
}
|
||||
|
||||
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),
|
||||
KcpStream::connect(a, Duration::from_secs(5))
|
||||
);
|
||||
(
|
||||
connect_res.expect("connect over loopback"),
|
||||
accept_res.expect("accept over loopback"),
|
||||
)
|
||||
}
|
||||
|
||||
// The full client path over real loopback sockets: handshake through the kcp_io
|
||||
// pumps, framed data both ways, then a graceful close. The endpoint guard stays
|
||||
// alive across the stream drop so the FIN can go out, and the peer's framed
|
||||
// stream must end (BrokenPipe from the kcp reader) instead of hanging.
|
||||
#[tokio::test]
|
||||
async fn test_kcp_stream_loopback_roundtrip_and_close() {
|
||||
let ((_guard_a, mut stream_a), (_guard_b, mut stream_b)) = establish().await;
|
||||
|
||||
stream_a
|
||||
.send_bytes(Bytes::from_static(b"ping"))
|
||||
.await
|
||||
.unwrap();
|
||||
let got = stream_b.next_timeout(5000).await.unwrap().unwrap();
|
||||
assert_eq!(&got[..], b"ping");
|
||||
|
||||
stream_b
|
||||
.send_bytes(Bytes::from_static(b"pong"))
|
||||
.await
|
||||
.unwrap();
|
||||
let got = stream_a.next_timeout(5000).await.unwrap().unwrap();
|
||||
assert_eq!(&got[..], b"pong");
|
||||
|
||||
drop(stream_a);
|
||||
match stream_b.next_timeout(10_000).await {
|
||||
None | Some(Err(_)) => {}
|
||||
Some(Ok(data)) => panic!("unexpected data after close: {:?}", data),
|
||||
}
|
||||
}
|
||||
|
||||
// A writer that queues many frames and closes immediately must not cost the
|
||||
// reader any of them: every frame arrives intact, in order, before end-of-stream.
|
||||
// This is the client-side pin for the kcp-sys close-tail-drain semantics, through
|
||||
// the real BytesCodec framing rustdesk sessions use.
|
||||
#[tokio::test]
|
||||
async fn test_kcp_stream_close_delivers_all_frames() {
|
||||
let ((_guard_a, mut tx), (_guard_b, mut rx)) = establish().await;
|
||||
|
||||
const N: usize = 50;
|
||||
let payload = vec![7u8; 32 * 1024];
|
||||
for _ in 0..N {
|
||||
tx.send_bytes(Bytes::from(payload.clone())).await.unwrap();
|
||||
}
|
||||
drop(tx);
|
||||
|
||||
let mut got = 0usize;
|
||||
loop {
|
||||
match rx.next_timeout(10_000).await {
|
||||
Some(Ok(data)) => {
|
||||
assert_eq!(data.len(), payload.len(), "frame boundary broken");
|
||||
assert!(data.iter().all(|&b| b == 7), "frame content corrupted");
|
||||
got += 1;
|
||||
}
|
||||
// BrokenPipe (kcp reader end) or timeout-None both end the stream.
|
||||
None | Some(Err(_)) => break,
|
||||
}
|
||||
}
|
||||
assert_eq!(got, N, "graceful close lost frames");
|
||||
}
|
||||
|
||||
// Socket errors on the connected UDP socket (ICMP unreachable after the peer
|
||||
// vanishes) are advisory: the io loop must treat them as loss - keep accepting
|
||||
// writes, keep running - rather than tearing the session down. Whether the OS
|
||||
// actually surfaces ECONNREFUSED here is platform-dependent; either way the
|
||||
// session must stay alive for this window.
|
||||
#[tokio::test]
|
||||
async fn test_kcp_io_treats_socket_errors_as_loss() {
|
||||
let ((_guard_a, mut stream_a), (guard_b, stream_b)) = establish().await;
|
||||
|
||||
// Kill the peer entirely: endpoint stops, socket closes.
|
||||
drop(stream_b);
|
||||
drop(guard_b);
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
|
||||
for _ in 0..10 {
|
||||
stream_a
|
||||
.send_bytes(Bytes::from_static(b"into the void"))
|
||||
.await
|
||||
.expect("socket errors must be treated as loss, not stream failure");
|
||||
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||
}
|
||||
}
|
||||
|
||||
// The connect deadline must hold when nothing answers: no hang, prompt error.
|
||||
#[tokio::test]
|
||||
async fn test_kcp_connect_timeout_without_peer() {
|
||||
let (a, _b) = connected_pair().await;
|
||||
let start = tokio::time::Instant::now();
|
||||
let res = KcpStream::connect(a, Duration::from_millis(600)).await;
|
||||
assert!(res.is_err(), "connect must fail with no peer endpoint");
|
||||
assert!(
|
||||
start.elapsed() < Duration::from_secs(5),
|
||||
"connect did not honor its deadline"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "قفل اللوحة"),
|
||||
("Sync clipboard between sessions", "مزامنة الحافظة بين الجلسات"),
|
||||
("sync-clipboard-between-sessions-tip", "النص أو الصور المنسوخة في جلسة بعيدة واحدة تُرسَل أيضًا إلى حافظة جلساتك المتصلة الأخرى."),
|
||||
("Enable WebRTC P2P connection", "تمكين اتصال نظير إلى نظير عبر WebRTC"),
|
||||
("Enable TCP hole punching", "تمكين تقنية حفر الثغرات عبر TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Заблакіраваць палатно"),
|
||||
("Sync clipboard between sessions", "Сінхранізаваць буфер абмену паміж сеансамі"),
|
||||
("sync-clipboard-between-sessions-tip", "Тэкст або відарысы, скапіяваныя ў адным аддаленым сеансе, таксама адпраўляюцца ў буфер абмену іншых вашых падключаных сеансаў."),
|
||||
("Enable WebRTC P2P connection", "Выкарыстоўваць падключэнне WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Выкарыстоўваць TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Заключване на платното"),
|
||||
("Sync clipboard between sessions", "Синхронизиране на клипборда между сесиите"),
|
||||
("sync-clipboard-between-sessions-tip", "Текст или изображения, копирани в една отдалечена сесия, се изпращат и към клипборда на другите ви свързани сесии."),
|
||||
("Enable WebRTC P2P connection", "Позволяване на WebRTC P2P връзка"),
|
||||
("Enable TCP hole punching", "Позволяване на TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloca el llenç"),
|
||||
("Sync clipboard between sessions", "Sincronitza el porta-retalls entre sessions"),
|
||||
("sync-clipboard-between-sessions-tip", "El text o les imatges copiats en una sessió remota també s'envien al porta-retalls de les altres sessions connectades."),
|
||||
("Enable WebRTC P2P connection", "Habilita la connexió WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Activa la perforació TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "锁定画布"),
|
||||
("Sync clipboard between sessions", "在会话间同步剪贴板"),
|
||||
("sync-clipboard-between-sessions-tip", "在一个远程会话中复制的文本或图片也会发送到其他已连接会话的剪贴板。"),
|
||||
("Enable WebRTC P2P connection", "启用 WebRTC P2P 连接"),
|
||||
("Enable TCP hole punching", "启用 TCP 打洞"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Zamknout zobrazení"),
|
||||
("Sync clipboard between sessions", "Synchronizovat schránku mezi relacemi"),
|
||||
("sync-clipboard-between-sessions-tip", "Text nebo obrázky zkopírované v jedné vzdálené relaci se odešlou i do schránky ostatních připojených relací."),
|
||||
("Enable WebRTC P2P connection", "Povolit připojení WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Povolit TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Lås lærred"),
|
||||
("Sync clipboard between sessions", "Synkroniser udklipsholder mellem sessioner"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst eller billeder, der kopieres i én fjernsession, sendes også til udklipsholderen i dine andre forbundne sessioner."),
|
||||
("Enable WebRTC P2P connection", "Aktivér WebRTC P2P-forbindelse"),
|
||||
("Enable TCP hole punching", "Aktivér TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Sichtfeld sperren"),
|
||||
("Sync clipboard between sessions", "Zwischenablage zwischen Sitzungen synchronisieren"),
|
||||
("sync-clipboard-between-sessions-tip", "In einer Remote-Sitzung kopierter Text oder kopierte Bilder werden auch an die Zwischenablage Ihrer anderen verbundenen Sitzungen gesendet."),
|
||||
("Enable WebRTC P2P connection", "WebRTC-P2P-Verbindung aktivieren"),
|
||||
("Enable TCP hole punching", "TCP-Hole-Punching aktivieren"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Κλείδωμα καμβά"),
|
||||
("Sync clipboard between sessions", "Συγχρονισμός προχείρου μεταξύ συνεδριών"),
|
||||
("sync-clipboard-between-sessions-tip", "Κείμενο ή εικόνες που αντιγράφονται σε μία απομακρυσμένη συνεδρία αποστέλλονται και στο πρόχειρο των άλλων συνδεδεμένων συνεδριών σας."),
|
||||
("Enable WebRTC P2P connection", "Ενεργοποίηση σύνδεσης WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Ενεργοποίηση διάτρησης οπών TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Ŝlosi kanvason"),
|
||||
("Sync clipboard between sessions", "Sinkronigi poŝon inter seancoj"),
|
||||
("sync-clipboard-between-sessions-tip", "Teksto aŭ bildoj kopiitaj en unu fora seanco ankaŭ sendiĝas al la poŝo de viaj aliaj konektitaj seancoj."),
|
||||
("Enable WebRTC P2P connection", "Ebligi WebRTC P2P-konekton"),
|
||||
("Enable TCP hole punching", "Ebligi TCP-trapikadon"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloquear lienzo"),
|
||||
("Sync clipboard between sessions", "Sincronizar portapapeles entre sesiones"),
|
||||
("sync-clipboard-between-sessions-tip", "El texto o las imágenes copiados en una sesión remota también se envían al portapapeles de tus otras sesiones conectadas."),
|
||||
("Enable WebRTC P2P connection", "Habilitar conexión WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Habilitar perforación de agujero TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Lukusta lõuend"),
|
||||
("Sync clipboard between sessions", "Sünkrooni lõikelaud seansside vahel"),
|
||||
("sync-clipboard-between-sessions-tip", "Ühes kaugseansis kopeeritud tekst või pildid saadetakse ka teiste ühendatud seansside lõikelauale."),
|
||||
("Enable WebRTC P2P connection", "Luba WebRTC P2P-ühendus"),
|
||||
("Enable TCP hole punching", "Luba TCP-augustamine"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Blokeatu oihala"),
|
||||
("Sync clipboard between sessions", "Sinkronizatu arbela saioen artean"),
|
||||
("sync-clipboard-between-sessions-tip", "Urruneko saio batean kopiatutako testua edo irudiak konektatutako beste saioen arbelera ere bidaltzen dira."),
|
||||
("Enable WebRTC P2P connection", "Gaitu WebRTC P2P konexioa"),
|
||||
("Enable TCP hole punching", "Gaitu TCP zulo-egitea"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "قفل کردن صفحه"),
|
||||
("Sync clipboard between sessions", "همگامسازی کلیپبورد بین نشستها"),
|
||||
("sync-clipboard-between-sessions-tip", "متن یا تصاویری که در یک نشست راه دور کپی میشوند به کلیپبورد سایر نشستهای متصل شما نیز ارسال میشوند."),
|
||||
("Enable WebRTC P2P connection", "فعالسازی اتصال همتابههمتای WebRTC"),
|
||||
("Enable TCP hole punching", "فعالسازی تکنیک TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Lukitse näkymä"),
|
||||
("Sync clipboard between sessions", "Synkronoi leikepöytä istuntojen välillä"),
|
||||
("sync-clipboard-between-sessions-tip", "Yhdessä etäistunnossa kopioitu teksti tai kuvat lähetetään myös muiden yhdistettyjen istuntojen leikepöydälle."),
|
||||
("Enable WebRTC P2P connection", "Ota WebRTC P2P yhteys käyttöön"),
|
||||
("Enable TCP hole punching", "Ota käyttöön TCP hole punching tekniikka"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Verrouiller la vue"),
|
||||
("Sync clipboard between sessions", "Synchroniser le presse-papiers entre les sessions"),
|
||||
("sync-clipboard-between-sessions-tip", "Le texte ou les images copiés dans une session distante sont également envoyés au presse-papiers de vos autres sessions connectées."),
|
||||
("Enable WebRTC P2P connection", "Activer la connexion P2P WebRTC"),
|
||||
("Enable TCP hole punching", "Activer le « hole punching » TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "ტილოს დაბლოკვა"),
|
||||
("Sync clipboard between sessions", "გაცვლის ბუფერის სინქრონიზაცია სესიებს შორის"),
|
||||
("sync-clipboard-between-sessions-tip", "ერთ დაშორებულ სესიაში დაკოპირებული ტექსტი ან სურათები ასევე იგზავნება თქვენი სხვა დაკავშირებული სესიების გაცვლის ბუფერში."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P კავშირის ჩართვა"),
|
||||
("Enable TCP hole punching", "TCP hole punching-ის ჩართვა"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "કેનવાસ લોક કરો"),
|
||||
("Sync clipboard between sessions", "સત્રો વચ્ચે ક્લિપબોર્ડ સિંક કરો"),
|
||||
("sync-clipboard-between-sessions-tip", "એક રિમોટ સત્રમાં કૉપિ કરેલ ટેક્સ્ટ કે છબીઓ તમારા અન્ય જોડાયેલા સત્રોના ક્લિપબોર્ડ પર પણ મોકલવામાં આવે છે."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P કનેક્શન સક્ષમ કરો"),
|
||||
("Enable TCP hole punching", "TCP હોલ પંચિંગ સક્ષમ કરો"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "נעל לוח ציור"),
|
||||
("Sync clipboard between sessions", "סנכרן לוח בין סשנים"),
|
||||
("sync-clipboard-between-sessions-tip", "טקסט או תמונות שהועתקו בסשן מרוחק אחד נשלחים גם ללוח של שאר הסשנים המחוברים שלך."),
|
||||
("Enable WebRTC P2P connection", "אפשר חיבור WebRTC P2P"),
|
||||
("Enable TCP hole punching", "אפשר TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "कैनवास लॉक करें"),
|
||||
("Sync clipboard between sessions", "सत्रों के बीच क्लिपबोर्ड सिंक करें"),
|
||||
("sync-clipboard-between-sessions-tip", "एक रिमोट सत्र में कॉपी किए गए टेक्स्ट या चित्र आपके अन्य जुड़े सत्रों के क्लिपबोर्ड पर भी भेजे जाते हैं।"),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P कनेक्शन सक्षम करें"),
|
||||
("Enable TCP hole punching", "TCP होल पंचिंग सक्षम करें"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Zaključaj pozadinu"),
|
||||
("Sync clipboard between sessions", "Sinkroniziraj međuspremnik između sesija"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst ili slike kopirani u jednoj udaljenoj sesiji šalju se i u međuspremnik vaših ostalih povezanih sesija."),
|
||||
("Enable WebRTC P2P connection", "Omogući WebRTC P2P vezu"),
|
||||
("Enable TCP hole punching", "Omogući TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Nézet zárolása"),
|
||||
("Sync clipboard between sessions", "Vágólap szinkronizálása a munkamenetek között"),
|
||||
("sync-clipboard-between-sessions-tip", "Az egyik távoli munkamenetben másolt szöveg vagy kép a többi csatlakoztatott munkamenet vágólapjára is elküldésre kerül."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P kapcsolat engedélyezése"),
|
||||
("Enable TCP hole punching", "TCP résszűrés engedélyezése"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Kunci kanvas"),
|
||||
("Sync clipboard between sessions", "Sinkronkan papan klip antar sesi"),
|
||||
("sync-clipboard-between-sessions-tip", "Teks atau gambar yang disalin di satu sesi jarak jauh juga dikirim ke papan klip sesi terhubung Anda yang lain."),
|
||||
("Enable WebRTC P2P connection", "Aktifkan koneksi P2P WebRTC"),
|
||||
("Enable TCP hole punching", "Aktifkan TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Blocca tela"),
|
||||
("Sync clipboard between sessions", "Sincronizza gli appunti tra le sessioni"),
|
||||
("sync-clipboard-between-sessions-tip", "Il testo o le immagini copiati in una sessione remota vengono inviati anche agli appunti delle altre sessioni connesse."),
|
||||
("Enable WebRTC P2P connection", "Abilita connessione P2P WebRTC"),
|
||||
("Enable TCP hole punching", "Abilita hole punching TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "キャンバスをロック"),
|
||||
("Sync clipboard between sessions", "セッション間でクリップボードを同期"),
|
||||
("sync-clipboard-between-sessions-tip", "1つのリモートセッションでコピーしたテキストや画像は、接続中の他のセッションのクリップボードにも送信されます。"),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P 接続を有効化する"),
|
||||
("Enable TCP hole punching", "TCP ホールパンチを有効化する"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "캔버스 잠금"),
|
||||
("Sync clipboard between sessions", "세션 간 클립보드 동기화"),
|
||||
("sync-clipboard-between-sessions-tip", "하나의 원격 세션에서 복사한 텍스트나 이미지는 연결된 다른 세션의 클립보드에도 전송됩니다."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P 연결 사용"),
|
||||
("Enable TCP hole punching", "TCP 홀 펀칭 사용"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Кенепті құлыптау"),
|
||||
("Sync clipboard between sessions", "Сеанстар арасында көшіру-тақтасын синхрондау"),
|
||||
("sync-clipboard-between-sessions-tip", "Бір қашықтағы сеанста көшірілген мәтін немесе суреттер басқа қосылған сеанстардың көшіру-тақтасына да жіберіледі."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P қосылымын іске қосу"),
|
||||
("Enable TCP hole punching", "TCP hole punching'ті іске қосу"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Užrakinti drobę"),
|
||||
("Sync clipboard between sessions", "Sinchronizuoti iškarpinę tarp seansų"),
|
||||
("sync-clipboard-between-sessions-tip", "Viename nuotoliniame seanse nukopijuotas tekstas ar vaizdai taip pat siunčiami į kitų prijungtų seansų iškarpinę."),
|
||||
("Enable WebRTC P2P connection", "Įgalinti WebRTC P2P ryšį"),
|
||||
("Enable TCP hole punching", "Įgalinti TCP gręžimą (hole punching)"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloķēt audeklu"),
|
||||
("Sync clipboard between sessions", "Sinhronizēt starpliktuvi starp sesijām"),
|
||||
("sync-clipboard-between-sessions-tip", "Vienā attālajā sesijā nokopētais teksts vai attēli tiek nosūtīti arī uz pārējo pievienoto sesiju starpliktuvi."),
|
||||
("Enable WebRTC P2P connection", "Iespējot WebRTC P2P savienojumu"),
|
||||
("Enable TCP hole punching", "Iespējot TCP caurumu veidošanu"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "ക്യാൻവാസ് ലോക്ക് ചെയ്യുക"),
|
||||
("Sync clipboard between sessions", "സെഷനുകൾക്കിടയിൽ ക്ലിപ്പ്ബോർഡ് സമന്വയിപ്പിക്കുക"),
|
||||
("sync-clipboard-between-sessions-tip", "ഒരു റിമോട്ട് സെഷനിൽ പകർത്തിയ ടെക്സ്റ്റോ ചിത്രങ്ങളോ നിങ്ങളുടെ മറ്റ് കണക്റ്റുചെയ്ത സെഷനുകളുടെ ക്ലിപ്പ്ബോർഡിലേക്കും അയയ്ക്കപ്പെടും."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P കണക്ഷൻ അനുവദിക്കുക"),
|
||||
("Enable TCP hole punching", "TCP ഹോൾ പഞ്ചിംഗ് അനുവദിക്കുക"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Lås lerret"),
|
||||
("Sync clipboard between sessions", "Synkroniser utklippstavlen mellom økter"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst eller bilder som kopieres i én ekstern økt, sendes også til utklippstavlen i de andre tilkoblede øktene dine."),
|
||||
("Enable WebRTC P2P connection", "Aktiver WebRTC P2P-tilkobling"),
|
||||
("Enable TCP hole punching", "Aktiver TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Canvas vergrendelen"),
|
||||
("Sync clipboard between sessions", "Klembord synchroniseren tussen sessies"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst of afbeeldingen die in één externe sessie worden gekopieerd, worden ook naar het klembord van uw andere verbonden sessies gestuurd."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P-verbinding inschakelen"),
|
||||
("Enable TCP hole punching", "TCP-hole punching inschakelen"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Zablokuj ekran"),
|
||||
("Sync clipboard between sessions", "Synchronizuj schowek między sesjami"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst lub obrazy skopiowane w jednej sesji zdalnej są wysyłane także do schowka pozostałych połączonych sesji."),
|
||||
("Enable WebRTC P2P connection", "Włącz połączenie P2P WebRTC"),
|
||||
("Enable TCP hole punching", "Włącz tworzenie tunelu TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloquear tela"),
|
||||
("Sync clipboard between sessions", "Sincronizar área de transferência entre sessões"),
|
||||
("sync-clipboard-between-sessions-tip", "O texto ou as imagens copiados numa sessão remota também são enviados para a área de transferência das suas outras sessões ligadas."),
|
||||
("Enable WebRTC P2P connection", "Ativar ligação P2P por WebRTC"),
|
||||
("Enable TCP hole punching", "Ativar TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloquear tela"),
|
||||
("Sync clipboard between sessions", "Sincronizar área de transferência entre sessões"),
|
||||
("sync-clipboard-between-sessions-tip", "Texto ou imagens copiados em uma sessão remota também são enviados para a área de transferência das suas outras sessões conectadas."),
|
||||
("Enable WebRTC P2P connection", "Habilitar conexão WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Habilitar TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Blochează ecranul"),
|
||||
("Sync clipboard between sessions", "Sincronizează clipboardul între sesiuni"),
|
||||
("sync-clipboard-between-sessions-tip", "Textul sau imaginile copiate într-o sesiune la distanță sunt trimise și în clipboardul celorlalte sesiuni conectate."),
|
||||
("Enable WebRTC P2P connection", "Activează conexiunea P2P prin WebRTC"),
|
||||
("Enable TCP hole punching", "Activează traversarea TCP (hole punching)"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Заблокировать холст"),
|
||||
("Sync clipboard between sessions", "Синхронизировать буфер обмена между сеансами"),
|
||||
("sync-clipboard-between-sessions-tip", "Текст или изображения, скопированные в одном удалённом сеансе, также отправляются в буфер обмена других подключённых сеансов."),
|
||||
("Enable WebRTC P2P connection", "Использовать подключение WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Использовать TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Bloca sa tela"),
|
||||
("Sync clipboard between sessions", "Sincroniza sa punta de billete intre is sessiones"),
|
||||
("sync-clipboard-between-sessions-tip", "Su testu o is immàgines copiadas in una sessione remota sunt imbiadas fintzas a sa punta de billete de is àteras sessiones connètidas."),
|
||||
("Enable WebRTC P2P connection", "Abìlita connessione P2P WebRTC"),
|
||||
("Enable TCP hole punching", "Abìlita s'istampadura TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Uzamknúť zobrazenie"),
|
||||
("Sync clipboard between sessions", "Synchronizovať schránku medzi reláciami"),
|
||||
("sync-clipboard-between-sessions-tip", "Text alebo obrázky skopírované v jednej vzdialenej relácii sa odošlú aj do schránky ostatných pripojených relácií."),
|
||||
("Enable WebRTC P2P connection", "Povoliť pripojenie WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Povoliť TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Zakleni platno"),
|
||||
("Sync clipboard between sessions", "Sinhroniziraj odložišče med sejami"),
|
||||
("sync-clipboard-between-sessions-tip", "Besedilo ali slike, kopirane v eni oddaljeni seji, se pošljejo tudi v odložišče vaših drugih povezanih sej."),
|
||||
("Enable WebRTC P2P connection", "Omogoči povezavo WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Omogoči preboj lukenj TCP"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Kyç canvas"),
|
||||
("Sync clipboard between sessions", "Sinkronizo clipboard-in midis sesioneve"),
|
||||
("sync-clipboard-between-sessions-tip", "Teksti ose imazhet e kopjuara në një sesion të largët dërgohen edhe në clipboard-in e sesioneve të tjera të lidhura."),
|
||||
("Enable WebRTC P2P connection", "Aktivizo lidhjen WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Aktivizo TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Zaključaj pozadinu"),
|
||||
("Sync clipboard between sessions", "Sinhronizuj klipbord između sesija"),
|
||||
("sync-clipboard-between-sessions-tip", "Tekst ili slike kopirane u jednoj udaljenoj sesiji šalju se i u klipbord vaših ostalih povezanih sesija."),
|
||||
("Enable WebRTC P2P connection", "Omogući WebRTC P2P konekciju"),
|
||||
("Enable TCP hole punching", "Omogući TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -659,9 +659,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("screenshot-merged-screen-not-supported-tip", "Sammanslagning av skärmdumpar från flera skärmar stöds för närvarande inte. Byt till en enda skärm och försök igen."),
|
||||
("screenshot-action-tip", "Välj hur du vill fortsätta med skärmdumpen."),
|
||||
("Save as", "Spara som"),
|
||||
("Export", ""),
|
||||
("Export Logs", ""),
|
||||
("Import Folder", ""),
|
||||
("Export", "Exportera"),
|
||||
("Export Logs", "Exportera loggar"),
|
||||
("Import Folder", "Importera mapp"),
|
||||
("Copy to clipboard", "Kppiera till urklipp"),
|
||||
("Enable remote printer", "Aktivera fjärrskrivare"),
|
||||
("Downloading {}", "Laddar ner {}"),
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Lås canvas"),
|
||||
("Sync clipboard between sessions", "Synkronisera urklipp mellan sessioner"),
|
||||
("sync-clipboard-between-sessions-tip", "Text eller bilder som kopieras i en fjärrsession skickas även till urklipp i dina andra anslutna sessioner."),
|
||||
("Enable WebRTC P2P connection", "Aktivera WebRTC P2P anslutning"),
|
||||
("Enable TCP hole punching", "Aktivera TCP hålslagning"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "கேன்வாஸைப் பூட்டு"),
|
||||
("Sync clipboard between sessions", "அமர்வுகளுக்கு இடையே கிளிப்போர்டை ஒத்திசைக்கவும்"),
|
||||
("sync-clipboard-between-sessions-tip", "ஒரு தொலை அமர்வில் நகலெடுக்கப்பட்ட உரை அல்லது படங்கள் உங்கள் பிற இணைக்கப்பட்ட அமர்வுகளின் கிளிப்போர்டுக்கும் அனுப்பப்படும்."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P இணைப்பு இயக்கு"),
|
||||
("Enable TCP hole punching", "TCP hole punching இயக்கு"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", ""),
|
||||
("Sync clipboard between sessions", ""),
|
||||
("sync-clipboard-between-sessions-tip", ""),
|
||||
("Enable WebRTC P2P connection", ""),
|
||||
("Enable TCP hole punching", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "ล็อคแคนวาส"),
|
||||
("Sync clipboard between sessions", "ซิงค์คลิปบอร์ดระหว่างเซสชัน"),
|
||||
("sync-clipboard-between-sessions-tip", "ข้อความหรือรูปภาพที่คัดลอกในเซสชันระยะไกลหนึ่งจะถูกส่งไปยังคลิปบอร์ดของเซสชันอื่นที่เชื่อมต่ออยู่ด้วย"),
|
||||
("Enable WebRTC P2P connection", "เปิดใช้งานการเชื่อมต่อ P2P แบบ WebRTC"),
|
||||
("Enable TCP hole punching", "เปิดใช้งาน TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Tuvali kilitle"),
|
||||
("Sync clipboard between sessions", "Oturumlar arasında panoyu senkronize et"),
|
||||
("sync-clipboard-between-sessions-tip", "Bir uzak oturumda kopyalanan metin veya görseller, bağlı diğer oturumlarınızın panosuna da gönderilir."),
|
||||
("Enable WebRTC P2P connection", "WebRTC P2P bağlantısını etkinleştir"),
|
||||
("Enable TCP hole punching", "TCP delik açmayı etkinleştir"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "鎖定畫布"),
|
||||
("Sync clipboard between sessions", "在工作階段間同步剪貼簿"),
|
||||
("sync-clipboard-between-sessions-tip", "在一個遠端工作階段中複製的文字或圖片也會傳送到其他已連線工作階段的剪貼簿。"),
|
||||
("Enable WebRTC P2P connection", "啟用 WebRTC P2P 連線"),
|
||||
("Enable TCP hole punching", "啟用 TCP 打洞"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Блокування полотна"),
|
||||
("Sync clipboard between sessions", "Синхронізувати буфер обміну між сеансами"),
|
||||
("sync-clipboard-between-sessions-tip", "Текст або зображення, скопійовані в одному віддаленому сеансі, також надсилаються до буфера обміну інших підключених сеансів."),
|
||||
("Enable WebRTC P2P connection", "Увімкнути P2P-підключення через WebRTC"),
|
||||
("Enable TCP hole punching", "Увімкнути TCP hole punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -763,5 +763,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Lock canvas", "Khóa khung hình"),
|
||||
("Sync clipboard between sessions", "Đồng bộ clipboard giữa các phiên"),
|
||||
("sync-clipboard-between-sessions-tip", "Văn bản hoặc hình ảnh được sao chép trong một phiên từ xa cũng được gửi đến clipboard của các phiên đã kết nối khác."),
|
||||
("Enable WebRTC P2P connection", "Cho phép kết nối WebRTC P2P"),
|
||||
("Enable TCP hole punching", "Bật TCP Hole Punching"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
404
src/platform/android_ifaddrs.c
Normal file
404
src/platform/android_ifaddrs.c
Normal file
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* getifaddrs()/freeifaddrs() for Android: bionic only exports them from API 24,
|
||||
* while the jniLibs are built against the API 21 sysroot (flutter/ndk_*.sh) and
|
||||
* webrtc-util calls them whenever WebRTC gathers ICE candidates.
|
||||
*
|
||||
* Only AF_INET and AF_INET6 entries are reported; the AF_PACKET ones the real
|
||||
* getifaddrs() also returns have no reader in this build.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
/* Refuse a single netlink datagram larger than this rather than grow forever. */
|
||||
#define RD_NL_MAX_BUF (1024 * 1024)
|
||||
/* A dump that never terminates must not hang the caller. */
|
||||
#define RD_NL_MAX_DATAGRAMS 4096
|
||||
|
||||
typedef int (*rd_nl_cb)(struct nlmsghdr *nlh, void *ctx);
|
||||
|
||||
struct rd_link_info {
|
||||
unsigned int index;
|
||||
unsigned int flags;
|
||||
char name[IFNAMSIZ + 1];
|
||||
};
|
||||
|
||||
struct rd_link_table {
|
||||
struct rd_link_info *items;
|
||||
size_t len;
|
||||
size_t cap;
|
||||
};
|
||||
|
||||
/* One allocation per reported address; `ifa` first so freeifaddrs() can free
|
||||
* the node it is handed. */
|
||||
struct rd_ifaddrs_storage {
|
||||
struct ifaddrs ifa;
|
||||
struct sockaddr_storage addr;
|
||||
struct sockaddr_storage netmask;
|
||||
struct sockaddr_storage ifu;
|
||||
char name[IFNAMSIZ + 1];
|
||||
};
|
||||
|
||||
struct rd_addr_ctx {
|
||||
const struct rd_link_table *links;
|
||||
struct ifaddrs *head;
|
||||
struct ifaddrs *tail;
|
||||
};
|
||||
|
||||
static void rd_parse_rtattr(struct rtattr *rta, int len, struct rtattr **tb, int max)
|
||||
{
|
||||
memset(tb, 0, sizeof(*tb) * ((size_t)max + 1));
|
||||
for (; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
|
||||
if (rta->rta_type <= (unsigned short)max && tb[rta->rta_type] == NULL)
|
||||
tb[rta->rta_type] = rta;
|
||||
}
|
||||
}
|
||||
|
||||
/* `len` must stay signed: NLMSG_NEXT subtracts the *aligned* length, which
|
||||
* overshoots on an unaligned trailing message, and only a negative remainder
|
||||
* stops NLMSG_OK from reading past the buffer. */
|
||||
static int rd_nl_parse(char *buf, int len, unsigned short reply_type, unsigned int seq,
|
||||
rd_nl_cb cb, void *ctx, int *done)
|
||||
{
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
|
||||
|
||||
for (; NLMSG_OK(nlh, len); nlh = NLMSG_NEXT(nlh, len)) {
|
||||
if (nlh->nlmsg_seq != seq)
|
||||
continue;
|
||||
if (nlh->nlmsg_type == NLMSG_DONE) {
|
||||
*done = 1;
|
||||
return 0;
|
||||
}
|
||||
if (nlh->nlmsg_type == NLMSG_ERROR) {
|
||||
struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(nlh);
|
||||
if (nlh->nlmsg_len >= NLMSG_LENGTH(sizeof(*err)) && err->error != 0)
|
||||
errno = -err->error;
|
||||
else
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
if (nlh->nlmsg_type != reply_type)
|
||||
continue;
|
||||
if (cb(nlh, ctx) != 0)
|
||||
return -1;
|
||||
/* A non-multipart reply is the whole answer; nothing follows it. */
|
||||
if ((nlh->nlmsg_flags & NLM_F_MULTI) == 0) {
|
||||
*done = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rd_nl_dump(int fd, unsigned short request_type, unsigned short reply_type,
|
||||
unsigned int seq, rd_nl_cb cb, void *ctx)
|
||||
{
|
||||
struct {
|
||||
struct nlmsghdr nlh;
|
||||
struct rtgenmsg gen;
|
||||
} req;
|
||||
struct sockaddr_nl kernel;
|
||||
char *buf;
|
||||
size_t cap = 8192;
|
||||
int datagrams = 0;
|
||||
int done = 0;
|
||||
int rc = -1;
|
||||
int saved;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(req.gen));
|
||||
req.nlh.nlmsg_type = request_type;
|
||||
req.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
|
||||
req.nlh.nlmsg_seq = seq;
|
||||
req.gen.rtgen_family = AF_UNSPEC;
|
||||
|
||||
memset(&kernel, 0, sizeof(kernel));
|
||||
kernel.nl_family = AF_NETLINK;
|
||||
|
||||
for (;;) {
|
||||
if (sendto(fd, &req, req.nlh.nlmsg_len, 0, (struct sockaddr *)&kernel,
|
||||
sizeof(kernel)) >= 0)
|
||||
break;
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = (char *)malloc(cap);
|
||||
if (buf == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (!done) {
|
||||
/* MSG_PEEK|MSG_TRUNC reports the datagram's real size, so an
|
||||
* undersized buffer costs a resize instead of a silent truncation. */
|
||||
ssize_t n = recv(fd, buf, cap, MSG_PEEK | MSG_TRUNC);
|
||||
if (n < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
goto out;
|
||||
}
|
||||
if ((size_t)n > cap) {
|
||||
char *grown;
|
||||
if ((size_t)n > RD_NL_MAX_BUF) {
|
||||
errno = EMSGSIZE;
|
||||
goto out;
|
||||
}
|
||||
grown = (char *)realloc(buf, (size_t)n);
|
||||
if (grown == NULL) {
|
||||
errno = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
buf = grown;
|
||||
cap = (size_t)n;
|
||||
continue;
|
||||
}
|
||||
n = recv(fd, buf, cap, 0);
|
||||
if (n < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
goto out;
|
||||
}
|
||||
if (n == 0 || ++datagrams > RD_NL_MAX_DATAGRAMS) {
|
||||
errno = EIO;
|
||||
goto out;
|
||||
}
|
||||
if (rd_nl_parse(buf, (int)n, reply_type, seq, cb, ctx, &done) != 0)
|
||||
goto out;
|
||||
}
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
saved = errno;
|
||||
free(buf);
|
||||
errno = saved;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int rd_link_cb(struct nlmsghdr *nlh, void *ctx)
|
||||
{
|
||||
struct rd_link_table *t = (struct rd_link_table *)ctx;
|
||||
struct ifinfomsg *ifi;
|
||||
struct rtattr *tb[IFLA_IFNAME + 1];
|
||||
struct rd_link_info *slot;
|
||||
int payload;
|
||||
int namelen;
|
||||
|
||||
if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*ifi)))
|
||||
return 0;
|
||||
ifi = (struct ifinfomsg *)NLMSG_DATA(nlh);
|
||||
payload = (int)nlh->nlmsg_len - (int)NLMSG_SPACE(sizeof(*ifi));
|
||||
if (payload < 0)
|
||||
payload = 0;
|
||||
rd_parse_rtattr(IFLA_RTA(ifi), payload, tb, IFLA_IFNAME);
|
||||
|
||||
/* An interface we cannot name is of no use: callers dereference ifa_name. */
|
||||
if (tb[IFLA_IFNAME] == NULL || (int)RTA_PAYLOAD(tb[IFLA_IFNAME]) <= 0)
|
||||
return 0;
|
||||
|
||||
if (t->len == t->cap) {
|
||||
size_t ncap = t->cap ? t->cap * 2 : 16;
|
||||
struct rd_link_info *items =
|
||||
(struct rd_link_info *)realloc(t->items, ncap * sizeof(*items));
|
||||
if (items == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
t->items = items;
|
||||
t->cap = ncap;
|
||||
}
|
||||
|
||||
slot = &t->items[t->len];
|
||||
memset(slot, 0, sizeof(*slot));
|
||||
slot->index = (unsigned int)ifi->ifi_index;
|
||||
slot->flags = ifi->ifi_flags;
|
||||
namelen = (int)RTA_PAYLOAD(tb[IFLA_IFNAME]);
|
||||
if (namelen > IFNAMSIZ)
|
||||
namelen = IFNAMSIZ;
|
||||
memcpy(slot->name, RTA_DATA(tb[IFLA_IFNAME]), (size_t)namelen);
|
||||
slot->name[namelen] = '\0';
|
||||
t->len++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct rd_link_info *rd_link_find(const struct rd_link_table *t,
|
||||
unsigned int index)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < t->len; i++) {
|
||||
if (t->items[i].index == index)
|
||||
return &t->items[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void rd_fill_mask(unsigned char *out, int len, unsigned int prefix)
|
||||
{
|
||||
int i;
|
||||
if (prefix > (unsigned int)len * 8)
|
||||
prefix = (unsigned int)len * 8;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (prefix >= 8) {
|
||||
out[i] = 0xff;
|
||||
prefix -= 8;
|
||||
} else if (prefix > 0) {
|
||||
out[i] = (unsigned char)(0xff << (8 - prefix));
|
||||
prefix = 0;
|
||||
} else {
|
||||
out[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rd_set_in(struct sockaddr_storage *ss, const void *addr)
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)ss;
|
||||
sin->sin_family = AF_INET;
|
||||
memcpy(&sin->sin_addr, addr, 4);
|
||||
}
|
||||
|
||||
static int rd_addr_cb(struct nlmsghdr *nlh, void *ctx)
|
||||
{
|
||||
struct rd_addr_ctx *c = (struct rd_addr_ctx *)ctx;
|
||||
struct ifaddrmsg *ifa;
|
||||
struct rtattr *tb[IFA_BROADCAST + 1];
|
||||
struct rtattr *ra;
|
||||
const struct rd_link_info *link;
|
||||
struct rd_ifaddrs_storage *st;
|
||||
int payload;
|
||||
|
||||
if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*ifa)))
|
||||
return 0;
|
||||
ifa = (struct ifaddrmsg *)NLMSG_DATA(nlh);
|
||||
if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6)
|
||||
return 0;
|
||||
|
||||
/* Without the link entry there is no name, and callers deref ifa_name. */
|
||||
link = rd_link_find(c->links, ifa->ifa_index);
|
||||
if (link == NULL)
|
||||
return 0;
|
||||
|
||||
payload = (int)nlh->nlmsg_len - (int)NLMSG_SPACE(sizeof(*ifa));
|
||||
if (payload < 0)
|
||||
payload = 0;
|
||||
rd_parse_rtattr(IFA_RTA(ifa), payload, tb, IFA_BROADCAST);
|
||||
|
||||
/* On a point-to-point link IFA_ADDRESS holds the peer and IFA_LOCAL the
|
||||
* local address; ipv6 only ever sets IFA_ADDRESS. */
|
||||
if (ifa->ifa_family == AF_INET)
|
||||
ra = tb[IFA_LOCAL] ? tb[IFA_LOCAL] : tb[IFA_ADDRESS];
|
||||
else
|
||||
ra = tb[IFA_ADDRESS] ? tb[IFA_ADDRESS] : tb[IFA_LOCAL];
|
||||
if (ra == NULL)
|
||||
return 0;
|
||||
if ((int)RTA_PAYLOAD(ra) < (ifa->ifa_family == AF_INET ? 4 : 16))
|
||||
return 0;
|
||||
|
||||
st = (struct rd_ifaddrs_storage *)calloc(1, sizeof(*st));
|
||||
if (st == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(st->name, link->name, sizeof(st->name));
|
||||
st->ifa.ifa_name = st->name;
|
||||
st->ifa.ifa_flags = link->flags;
|
||||
st->ifa.ifa_addr = (struct sockaddr *)&st->addr;
|
||||
st->ifa.ifa_netmask = (struct sockaddr *)&st->netmask;
|
||||
|
||||
if (ifa->ifa_family == AF_INET) {
|
||||
struct sockaddr_in *mask = (struct sockaddr_in *)&st->netmask;
|
||||
|
||||
rd_set_in(&st->addr, RTA_DATA(ra));
|
||||
mask->sin_family = AF_INET;
|
||||
rd_fill_mask((unsigned char *)&mask->sin_addr, 4, ifa->ifa_prefixlen);
|
||||
|
||||
if ((link->flags & IFF_POINTOPOINT) && tb[IFA_ADDRESS] && tb[IFA_LOCAL] &&
|
||||
(int)RTA_PAYLOAD(tb[IFA_ADDRESS]) >= 4 &&
|
||||
memcmp(RTA_DATA(tb[IFA_ADDRESS]), RTA_DATA(tb[IFA_LOCAL]), 4) != 0) {
|
||||
rd_set_in(&st->ifu, RTA_DATA(tb[IFA_ADDRESS]));
|
||||
st->ifa.ifa_dstaddr = (struct sockaddr *)&st->ifu;
|
||||
} else if (tb[IFA_BROADCAST] && (int)RTA_PAYLOAD(tb[IFA_BROADCAST]) >= 4) {
|
||||
rd_set_in(&st->ifu, RTA_DATA(tb[IFA_BROADCAST]));
|
||||
st->ifa.ifa_broadaddr = (struct sockaddr *)&st->ifu;
|
||||
}
|
||||
} else {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&st->addr;
|
||||
struct sockaddr_in6 *mask = (struct sockaddr_in6 *)&st->netmask;
|
||||
|
||||
sin6->sin6_family = AF_INET6;
|
||||
memcpy(&sin6->sin6_addr, RTA_DATA(ra), 16);
|
||||
/* A link-local address is not routable without its scope id. */
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
|
||||
IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
|
||||
sin6->sin6_scope_id = ifa->ifa_index;
|
||||
mask->sin6_family = AF_INET6;
|
||||
rd_fill_mask((unsigned char *)&mask->sin6_addr, 16, ifa->ifa_prefixlen);
|
||||
}
|
||||
|
||||
if (c->tail != NULL)
|
||||
c->tail->ifa_next = &st->ifa;
|
||||
else
|
||||
c->head = &st->ifa;
|
||||
c->tail = &st->ifa;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freeifaddrs(struct ifaddrs *ifa)
|
||||
{
|
||||
while (ifa != NULL) {
|
||||
struct ifaddrs *next = ifa->ifa_next;
|
||||
free(ifa);
|
||||
ifa = next;
|
||||
}
|
||||
}
|
||||
|
||||
int getifaddrs(struct ifaddrs **ifap)
|
||||
{
|
||||
struct rd_link_table links;
|
||||
struct rd_addr_ctx ctx;
|
||||
int fd;
|
||||
int saved;
|
||||
|
||||
if (ifap == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*ifap = NULL;
|
||||
|
||||
memset(&links, 0, sizeof(links));
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.links = &links;
|
||||
|
||||
fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
if (rd_nl_dump(fd, RTM_GETLINK, RTM_NEWLINK, 1, rd_link_cb, &links) != 0)
|
||||
goto fail;
|
||||
if (rd_nl_dump(fd, RTM_GETADDR, RTM_NEWADDR, 2, rd_addr_cb, &ctx) != 0)
|
||||
goto fail;
|
||||
|
||||
close(fd);
|
||||
free(links.items);
|
||||
*ifap = ctx.head;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
saved = errno;
|
||||
close(fd);
|
||||
free(links.items);
|
||||
freeifaddrs(ctx.head);
|
||||
errno = saved;
|
||||
return -1;
|
||||
}
|
||||
@@ -1496,8 +1496,8 @@ pub fn rename_exe_cmd(src_exe: &str, path: &str) -> ResultType<String> {
|
||||
.ok_or(anyhow!("Can't get file name of {src_exe}"))?
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let app_name = crate::get_app_name().to_lowercase();
|
||||
if src_exe_filename.to_lowercase() == format!("{app_name}.exe") {
|
||||
let app_name = crate::get_app_name();
|
||||
if src_exe_filename == format!("{app_name}.exe") {
|
||||
Ok("".to_owned())
|
||||
} else {
|
||||
Ok(format!(
|
||||
|
||||
@@ -92,12 +92,11 @@ pub async fn listen(
|
||||
tokio::select! {
|
||||
Ok((forward, addr)) = listener.accept() => {
|
||||
log::info!("new connection from {:?}", addr);
|
||||
lc.write().unwrap().port_forward = (remote_host.clone(), remote_port);
|
||||
let id = id.clone();
|
||||
let password = password.clone();
|
||||
let mut forward = Framed::new(forward, BytesCodec::new());
|
||||
let mut close_port_forward = false;
|
||||
match connect_and_login(&id, &password, &mut ui_receiver, interface.clone(), &mut forward, key, token, is_rdp, &mut close_port_forward).await {
|
||||
match connect_and_login(&id, &password, &mut ui_receiver, interface.clone(), &mut forward, key, token, is_rdp, &mut close_port_forward, &remote_host, remote_port).await {
|
||||
Ok(Some(stream)) => {
|
||||
let interface = interface.clone();
|
||||
tokio::spawn(async move {
|
||||
@@ -143,6 +142,8 @@ async fn connect_and_login(
|
||||
token: &str,
|
||||
is_rdp: bool,
|
||||
close_port_forward: &mut bool,
|
||||
remote_host: &str,
|
||||
remote_port: i32,
|
||||
) -> ResultType<Option<Stream>> {
|
||||
let conn_type = if is_rdp {
|
||||
ConnType::RDP
|
||||
@@ -160,6 +161,8 @@ async fn connect_and_login(
|
||||
}
|
||||
let mut buffer = Vec::new();
|
||||
let mut received = false;
|
||||
let mut challenge = None;
|
||||
let mut pending_login = None;
|
||||
|
||||
let _keep_it = hc_connection(feedback, rendezvous_server, token).await;
|
||||
|
||||
@@ -177,7 +180,8 @@ async fn connect_and_login(
|
||||
let msg_in = Message::parse_from_bytes(&bytes)?;
|
||||
match msg_in.union {
|
||||
Some(message::Union::Hash(hash)) => {
|
||||
if !interface.handle_hash(password, hash, &mut stream).await {
|
||||
challenge = Some(hash.clone());
|
||||
if !hash_arrived(&interface, password, hash, pending_login.take(), remote_host, remote_port, &mut stream).await {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
@@ -208,9 +212,10 @@ async fn connect_and_login(
|
||||
},
|
||||
d = ui_receiver.recv() => {
|
||||
match d {
|
||||
Some(Data::Login((os_username, os_password, password, remember))) => {
|
||||
interface.handle_login_from_ui(os_username, os_password, password, remember, &mut stream).await;
|
||||
}
|
||||
Some(Data::Login(login)) => match &challenge {
|
||||
Some(hash) => login_from_ui(&interface, hash, login, remote_host, remote_port, &mut stream).await,
|
||||
None => pending_login = Some(login),
|
||||
},
|
||||
Some(Data::Message(msg)) => {
|
||||
allow_err!(stream.send(&msg).await);
|
||||
}
|
||||
@@ -233,6 +238,76 @@ async fn connect_and_login(
|
||||
Ok(Some(stream))
|
||||
}
|
||||
|
||||
|
||||
/// A mapping's login is built from the window's shared handler:
|
||||
/// `create_login_msg` reads `port_forward` and `handle_login_from_ui` reads
|
||||
/// `hash`. Mappings log in concurrently, so each fills them and sends under
|
||||
/// the window's turn lock, or one login carried another mapping's target or
|
||||
/// answered another's challenge.
|
||||
async fn login_with_hash(
|
||||
interface: &impl Interface,
|
||||
password: &str,
|
||||
hash: Hash,
|
||||
remote_host: &str,
|
||||
remote_port: i32,
|
||||
stream: &mut Stream,
|
||||
) -> bool {
|
||||
let lc = interface.get_lch();
|
||||
let turn = lc.read().unwrap().port_forward_login_turn.clone();
|
||||
let _turn = turn.lock().await;
|
||||
lc.write().unwrap().port_forward = (remote_host.to_owned(), remote_port);
|
||||
interface.handle_hash(password, hash, stream).await
|
||||
}
|
||||
|
||||
type UiLogin = (String, String, String, bool);
|
||||
|
||||
/// This connection's `Hash`. The window's password prompt is broadcast to
|
||||
/// every mapping and can reach this one first, so a password typed while
|
||||
/// the `Hash` was on its way is kept and answers it now, rather than being
|
||||
/// dropped in the hope that the mapping which prompted has already stored
|
||||
/// it in the shared handler.
|
||||
async fn hash_arrived(
|
||||
interface: &impl Interface,
|
||||
password: &str,
|
||||
hash: Hash,
|
||||
pending_login: Option<UiLogin>,
|
||||
remote_host: &str,
|
||||
remote_port: i32,
|
||||
stream: &mut Stream,
|
||||
) -> bool {
|
||||
match pending_login {
|
||||
Some(login) => {
|
||||
login_from_ui(interface, &hash, login, remote_host, remote_port, stream).await;
|
||||
true
|
||||
}
|
||||
None => login_with_hash(interface, password, hash, remote_host, remote_port, stream).await,
|
||||
}
|
||||
}
|
||||
|
||||
/// The window's password prompt is broadcast to every mapping; this one
|
||||
/// answers it with its own challenge.
|
||||
async fn login_from_ui(
|
||||
interface: &impl Interface,
|
||||
hash: &Hash,
|
||||
login: UiLogin,
|
||||
remote_host: &str,
|
||||
remote_port: i32,
|
||||
stream: &mut Stream,
|
||||
) {
|
||||
let lc = interface.get_lch();
|
||||
let turn = lc.read().unwrap().port_forward_login_turn.clone();
|
||||
let _turn = turn.lock().await;
|
||||
{
|
||||
let mut lc = lc.write().unwrap();
|
||||
lc.port_forward = (remote_host.to_owned(), remote_port);
|
||||
lc.set_hash(hash.clone());
|
||||
}
|
||||
let (os_username, os_password, password, remember) = login;
|
||||
interface
|
||||
.handle_login_from_ui(os_username, os_password, password, remember, stream)
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn run_forward(forward: Framed<TcpStream, BytesCodec>, stream: Stream) -> ResultType<()> {
|
||||
log::info!("new port forwarding connection started");
|
||||
let mut forward = forward;
|
||||
@@ -257,3 +332,172 @@ async fn run_forward(forward: Framed<TcpStream, BytesCodec>, stream: Stream) ->
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod login_tests {
|
||||
use super::*;
|
||||
use async_trait::async_trait;
|
||||
use hbb_common::{
|
||||
tcp::FramedStream,
|
||||
tokio::time::{sleep, Duration},
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
/// A window's interface over its shared handler. `handle_hash` can pause
|
||||
/// before building the login, where the real one looks passwords up.
|
||||
#[derive(Clone)]
|
||||
struct Ui {
|
||||
lc: Arc<RwLock<LoginConfigHandler>>,
|
||||
pause: Duration,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Interface for Ui {
|
||||
fn send(&self, _data: Data) {}
|
||||
fn msgbox(&self, _msgtype: &str, _title: &str, _text: &str, _link: &str) {}
|
||||
fn handle_login_error(&self, _err: &str) -> bool {
|
||||
false
|
||||
}
|
||||
fn handle_peer_info(&self, _pi: PeerInfo) {}
|
||||
fn set_multiple_windows_session(&self, _sessions: Vec<WindowsSession>) {}
|
||||
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) -> bool {
|
||||
sleep(self.pause).await;
|
||||
crate::client::handle_hash(self.lc.clone(), pass, hash, self, peer).await
|
||||
}
|
||||
async fn handle_login_from_ui(
|
||||
&self,
|
||||
os_username: String,
|
||||
os_password: String,
|
||||
password: String,
|
||||
remember: bool,
|
||||
peer: &mut Stream,
|
||||
) {
|
||||
crate::client::handle_login_from_ui(
|
||||
self.lc.clone(),
|
||||
os_username,
|
||||
os_password,
|
||||
password,
|
||||
remember,
|
||||
peer,
|
||||
)
|
||||
.await
|
||||
}
|
||||
async fn handle_test_delay(&self, _t: TestDelay, _peer: &mut Stream) {}
|
||||
fn get_lch(&self) -> Arc<RwLock<LoginConfigHandler>> {
|
||||
self.lc.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn window() -> Ui {
|
||||
let mut lc = LoginConfigHandler::default();
|
||||
lc.conn_type = ConnType::PORT_FORWARD;
|
||||
Ui {
|
||||
lc: Arc::new(RwLock::new(lc)),
|
||||
pause: Duration::ZERO,
|
||||
}
|
||||
}
|
||||
|
||||
/// (our end, the peer's end) of one connection.
|
||||
async fn loopback() -> (Stream, Stream) {
|
||||
let l = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let addr = l.local_addr().unwrap();
|
||||
let client = tokio::net::TcpStream::connect(addr).await.unwrap();
|
||||
let (server, _) = l.accept().await.unwrap();
|
||||
(
|
||||
Stream::Tcp(FramedStream::from(client, addr)),
|
||||
Stream::Tcp(FramedStream::from(server, addr)),
|
||||
)
|
||||
}
|
||||
|
||||
async fn login_at(peer: &mut Stream) -> LoginRequest {
|
||||
let bytes = peer.next().await.unwrap().unwrap();
|
||||
Message::parse_from_bytes(&bytes)
|
||||
.unwrap()
|
||||
.login_request()
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn target(lr: &LoginRequest) -> (String, i32) {
|
||||
(lr.port_forward().host.clone(), lr.port_forward().port)
|
||||
}
|
||||
|
||||
fn hash(challenge: &str) -> Hash {
|
||||
Hash {
|
||||
salt: "salt".to_owned(),
|
||||
challenge: challenge.to_owned(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// What the peer expects for password `pw` under `hash(challenge)`.
|
||||
fn digest(challenge: &str) -> Vec<u8> {
|
||||
let mut h = Sha256::new();
|
||||
h.update("pw");
|
||||
h.update("salt");
|
||||
let salted = h.finalize();
|
||||
let mut h2 = Sha256::new();
|
||||
h2.update(&salted[..]);
|
||||
h2.update(challenge);
|
||||
h2.finalize()[..].to_vec()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mappings_logging_in_at_once_each_carry_their_own_target() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {
|
||||
let mut ui = window();
|
||||
ui.pause = Duration::from_millis(50);
|
||||
let (mut a, mut a_peer) = loopback().await;
|
||||
let (mut b, mut b_peer) = loopback().await;
|
||||
tokio::join!(
|
||||
login_with_hash(&ui, "pw", hash("a"), "a", 1, &mut a),
|
||||
login_with_hash(&ui, "pw", hash("b"), "b", 2, &mut b),
|
||||
);
|
||||
assert_eq!(target(&login_at(&mut a_peer).await), ("a".to_owned(), 1));
|
||||
assert_eq!(target(&login_at(&mut b_peer).await), ("b".to_owned(), 2));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mapping_answers_the_prompt_with_its_own_challenge() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {
|
||||
let ui = window();
|
||||
let (mut a, mut a_peer) = loopback().await;
|
||||
let (mut b, mut b_peer) = loopback().await;
|
||||
// A's hash arrived last, so it is the one the handler holds.
|
||||
assert!(login_with_hash(&ui, "pw", hash("a"), "a", 1, &mut a).await);
|
||||
login_at(&mut a_peer).await;
|
||||
let typed = (String::new(), String::new(), "pw".to_owned(), false);
|
||||
login_from_ui(&ui, &hash("b"), typed, "b", 2, &mut b).await;
|
||||
let lr = login_at(&mut b_peer).await;
|
||||
assert_eq!(lr.password, digest("b"));
|
||||
assert_eq!(target(&lr), ("b".to_owned(), 2));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_password_typed_before_this_connections_hash_answers_it_when_it_comes() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {
|
||||
let ui = window();
|
||||
let (mut b, mut b_peer) = loopback().await;
|
||||
// The prompt's password reached B before its hash, and no other
|
||||
// mapping has stored it in the handler yet.
|
||||
let typed = (String::new(), String::new(), "pw".to_owned(), false);
|
||||
assert!(hash_arrived(&ui, "", hash("b"), Some(typed), "b", 2, &mut b).await);
|
||||
let lr = login_at(&mut b_peer).await;
|
||||
assert_eq!(lr.password, digest("b"));
|
||||
assert_eq!(target(&lr), ("b".to_owned(), 2));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use std::{
|
||||
collections::{hash_map::RandomState, HashMap, VecDeque},
|
||||
hash::BuildHasher,
|
||||
net::SocketAddr,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
@@ -21,8 +23,13 @@ use hbb_common::{
|
||||
rendezvous_proto::*,
|
||||
sleep,
|
||||
socket_client::{self, connect_tcp, is_ipv4, new_direct_udp_for, new_udp_for},
|
||||
tokio::{self, select, sync::Mutex, time::interval},
|
||||
tokio::{
|
||||
self, select,
|
||||
sync::{mpsc, Mutex},
|
||||
time::interval,
|
||||
},
|
||||
udp::FramedSocket,
|
||||
webrtc::WebRTCStream,
|
||||
AddrMangle, IntoTargetAddr, ResultType, Stream, TargetAddr,
|
||||
};
|
||||
|
||||
@@ -47,7 +54,66 @@ lazy_static::lazy_static! {
|
||||
static ref SOLVING_PK_MISMATCH: Mutex<String> = Default::default();
|
||||
static ref LAST_MSG: Mutex<(SocketAddr, Instant)> = Mutex::new((SocketAddr::new([0; 4].into(), 0), Instant::now()));
|
||||
static ref LAST_RELAY_MSG: Mutex<(SocketAddr, Instant)> = Mutex::new((SocketAddr::new([0; 4].into(), 0), Instant::now()));
|
||||
static ref WEBRTC_ICE_TXS: Mutex<HashMap<String, IceRoute>> = Default::default();
|
||||
static ref ICE_DIGEST_STATE: RandomState = Default::default();
|
||||
}
|
||||
/// Remote ICE candidates buffered per session while the answerer applies them. Same depth as the
|
||||
/// controller's own buffer (`Client::MAX_PENDING_WEBRTC_ICE`), though that one evicts its oldest
|
||||
/// where a full channel here refuses the newest.
|
||||
const MAX_PENDING_REMOTE_ICE: usize = 64;
|
||||
/// Queued candidates remembered so the controller's re-send is skipped instead of taking a slot
|
||||
/// of its own. Far more than an honest peer gathers, at eight bytes each.
|
||||
const ICE_DEDUP_WINDOW: usize = 256;
|
||||
// The rendezvous ICE route is reachable without a prior punch and the peer decides how many
|
||||
// candidates it sends, so these sites would let someone else set how much this machine writes to
|
||||
// its log file. One line a minute each, carrying the suppressed count.
|
||||
const ICE_LOG_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60);
|
||||
static UNKNOWN_ICE_SESSION_LOG: hbb_common::log_throttle::LogThrottle =
|
||||
hbb_common::log_throttle::LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
static REJECTED_REMOTE_ICE_LOG: hbb_common::log_throttle::LogThrottle =
|
||||
hbb_common::log_throttle::LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
static FULL_ICE_QUEUE_LOG: hbb_common::log_throttle::LogThrottle =
|
||||
hbb_common::log_throttle::LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
|
||||
struct IceRoute {
|
||||
tx: mpsc::Sender<String>,
|
||||
recent: VecDeque<u64>,
|
||||
}
|
||||
|
||||
impl IceRoute {
|
||||
fn new(tx: mpsc::Sender<String>) -> Self {
|
||||
Self {
|
||||
tx,
|
||||
recent: VecDeque::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Keeps `queue` the only way onto the channel, so nothing reaches it unrecorded.
|
||||
fn is_same_channel(&self, other: &mpsc::Sender<String>) -> bool {
|
||||
self.tx.same_channel(other)
|
||||
}
|
||||
|
||||
/// Skip the controller's re-send of a candidate already queued: the ICE agent that dedups
|
||||
/// repeats is downstream of this queue, so the copy would spend a slot of its own.
|
||||
/// False means the candidate was dropped.
|
||||
fn queue(&mut self, candidate: String) -> bool {
|
||||
let digest = ICE_DIGEST_STATE.hash_one(candidate.as_str());
|
||||
if self.recent.contains(&digest) {
|
||||
// Only honest about the drop if the route is still alive to have taken it.
|
||||
return !self.tx.is_closed();
|
||||
}
|
||||
// Recorded once queued, never before: a refused candidate stays repairable by the re-send.
|
||||
if self.tx.try_send(candidate).is_err() {
|
||||
return false;
|
||||
}
|
||||
if self.recent.len() >= ICE_DEDUP_WINDOW {
|
||||
self.recent.pop_front();
|
||||
}
|
||||
self.recent.push_back(digest);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
static SHOULD_EXIT: AtomicBool = AtomicBool::new(false);
|
||||
static MANUAL_RESTARTED: AtomicBool = AtomicBool::new(false);
|
||||
static SENT_REGISTER_PK: AtomicBool = AtomicBool::new(false);
|
||||
@@ -399,6 +465,30 @@ impl RendezvousMediator {
|
||||
allow_err!(rz.handle_intranet(fla, server).await);
|
||||
});
|
||||
}
|
||||
Some(rendezvous_message::Union::IceCandidate(ice)) => {
|
||||
let queued = {
|
||||
let mut txs = WEBRTC_ICE_TXS.lock().await;
|
||||
txs.get_mut(&ice.session_key)
|
||||
.map(|route| route.queue(ice.candidate))
|
||||
};
|
||||
match queued {
|
||||
Some(false) => {
|
||||
if let Some(n) = FULL_ICE_QUEUE_LOG.due() {
|
||||
log::debug!("dropped {} ICE candidate(s): queue full or closed", n);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(n) = UNKNOWN_ICE_SESSION_LOG.due() {
|
||||
log::debug!(
|
||||
"dropped {} ICE candidate(s) for unknown WebRTC session key, last: {}",
|
||||
n,
|
||||
ice.session_key
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Some(rendezvous_message::Union::ConfigureUpdate(cu)) => {
|
||||
let v0 = Config::get_rendezvous_servers();
|
||||
Config::set_option(
|
||||
@@ -508,6 +598,7 @@ impl RendezvousMediator {
|
||||
rr.secure,
|
||||
false,
|
||||
Default::default(),
|
||||
String::new(),
|
||||
meta,
|
||||
)
|
||||
.await
|
||||
@@ -522,6 +613,7 @@ impl RendezvousMediator {
|
||||
secure: bool,
|
||||
initiate: bool,
|
||||
socket_addr_v6: bytes::Bytes,
|
||||
webrtc_sdp_answer: String,
|
||||
meta: ConnectionMeta,
|
||||
) -> ResultType<()> {
|
||||
let peer_addr = AddrMangle::decode(&socket_addr);
|
||||
@@ -540,6 +632,7 @@ impl RendezvousMediator {
|
||||
socket_addr: socket_addr.into(),
|
||||
version: crate::VERSION.to_owned(),
|
||||
socket_addr_v6,
|
||||
webrtc_sdp_answer,
|
||||
..Default::default()
|
||||
};
|
||||
if initiate {
|
||||
@@ -606,6 +699,7 @@ impl RendezvousMediator {
|
||||
true,
|
||||
true,
|
||||
socket_addr_v6,
|
||||
String::new(),
|
||||
meta,
|
||||
)
|
||||
.await
|
||||
@@ -642,6 +736,163 @@ impl RendezvousMediator {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Build the WebRTC answerer for a punch-hole offer and return the SDP answer that rides in
|
||||
/// the punch reply (PunchHoleSent / RelayResponse).
|
||||
///
|
||||
/// Awaited inline on the punch-reply path, which only holds because everything here is local
|
||||
/// (pc + keygen + SDP; trickle means the answer carries no candidates). Keep network I/O out
|
||||
/// — connection setup belongs in the detached task below.
|
||||
async fn spawn_webrtc_answerer(
|
||||
&self,
|
||||
ph: &PunchHole,
|
||||
relay_only_ice: bool,
|
||||
server: ServerPtr,
|
||||
peer_addr: SocketAddr,
|
||||
meta: ConnectionMeta,
|
||||
) -> ResultType<String> {
|
||||
let mut stream =
|
||||
WebRTCStream::new(&ph.webrtc_sdp_offer, relay_only_ice, CONNECT_TIMEOUT).await?;
|
||||
let answer = stream.local_endpoint().to_owned();
|
||||
let session_key = stream.session_key().to_owned();
|
||||
let return_route = ph.socket_addr.clone();
|
||||
|
||||
// A duplicate PunchHole (the offerer re-sends the same request across punch attempts)
|
||||
// resolves to the SESSIONS-cached stream. `take_local_ice_rx` yields the receiver
|
||||
// exactly once per stream instance, so `None` here means an answerer was already
|
||||
// spawned for this offer: return the (identical) cached answer without spawning a
|
||||
// second connect task. Otherwise two `create_tcp_connection` tasks would detach and
|
||||
// read the same data channel, interleaving the handshake and corrupting the session.
|
||||
let Some(mut local_ice_rx) = stream.take_local_ice_rx() else {
|
||||
return Ok(answer);
|
||||
};
|
||||
|
||||
// Bounded: how many candidates arrive is the sender's choice, while draining one costs a
|
||||
// JSON parse and the ICE agent's lock, so an unbounded queue lets whoever can reach this
|
||||
// session's route grow it without limit inside a long-lived service process. A full queue
|
||||
// drops the newest candidate, and the controller re-sends it once — the digests beside the
|
||||
// sender are what keep that re-send from spending a slot of its own.
|
||||
let (remote_ice_tx, mut remote_ice_rx) = mpsc::channel::<String>(MAX_PENDING_REMOTE_ICE);
|
||||
let own_ice_tx = remote_ice_tx.clone();
|
||||
WEBRTC_ICE_TXS
|
||||
.lock()
|
||||
.await
|
||||
.insert(session_key.clone(), IceRoute::new(remote_ice_tx));
|
||||
|
||||
let stream_for_remote_ice = stream.clone();
|
||||
tokio::spawn(async move {
|
||||
while let Some(candidate) = remote_ice_rx.recv().await {
|
||||
if let Err(err) = stream_for_remote_ice.add_remote_ice_candidate(&candidate).await
|
||||
{
|
||||
if let Some(n) = REJECTED_REMOTE_ICE_LOG.due() {
|
||||
log::warn!(
|
||||
"failed to add {} remote WebRTC ICE candidate(s), last: {}",
|
||||
n,
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
let host = self.host.clone();
|
||||
let socket_addr = return_route.clone();
|
||||
let session_key_for_ice = session_key.clone();
|
||||
tokio::spawn(async move {
|
||||
// Candidates ride a dedicated TCP connection to the rendezvous server, like
|
||||
// the answer, NOT the mediator channel: that channel is UDP in the default
|
||||
// setup, and target deployments front hbbs with websocket/TCP only, where
|
||||
// its UDP port is unreachable. The server keeps candidate-carrying TCP
|
||||
// connections open, so one lazily-opened connection serves the whole
|
||||
// trickle, and TCP reliability replaces the old 400ms duplicate re-send
|
||||
// (the controller keeps its own re-send for the server->peer UDP downlink).
|
||||
let mut conn = None;
|
||||
while let Some(candidate) = local_ice_rx.recv().await {
|
||||
let mut msg = Message::new();
|
||||
msg.set_ice_candidate(IceCandidate {
|
||||
socket_addr: socket_addr.clone(),
|
||||
session_key: session_key_for_ice.clone(),
|
||||
candidate,
|
||||
..Default::default()
|
||||
});
|
||||
// One reconnect attempt per candidate: the first send after an hbbs
|
||||
// restart or an idle-killed connection fails on the stale stream.
|
||||
for _ in 0..2 {
|
||||
if conn.is_none() {
|
||||
match connect_tcp(&*host, CONNECT_TIMEOUT).await {
|
||||
Ok(s) => conn = Some(s),
|
||||
Err(err) => {
|
||||
log::warn!(
|
||||
"failed to connect for WebRTC ICE candidate: {}",
|
||||
err
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(s) = conn.as_mut() {
|
||||
match s.send(&msg).await {
|
||||
Ok(()) => break,
|
||||
Err(err) => {
|
||||
log::debug!(
|
||||
"WebRTC ICE candidate send failed, reconnecting: {}",
|
||||
err
|
||||
);
|
||||
conn = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let session_key_for_cleanup = session_key.clone();
|
||||
tokio::spawn(async move {
|
||||
let result = stream.wait_connected(CONNECT_TIMEOUT).await;
|
||||
// Only evict our own route. The key is the offer's DTLS fingerprint, identical across
|
||||
// the controller's punch retries, so a retry that built a fresh answerer has already
|
||||
// replaced this entry — removing it blindly would delete the live session's sender and
|
||||
// leave it receiving no candidates at all.
|
||||
{
|
||||
let mut txs = WEBRTC_ICE_TXS.lock().await;
|
||||
if txs
|
||||
.get(&session_key_for_cleanup)
|
||||
.is_some_and(|route| route.is_same_channel(&own_ice_tx))
|
||||
{
|
||||
txs.remove(&session_key_for_cleanup);
|
||||
}
|
||||
}
|
||||
if let Err(err) = result {
|
||||
log::warn!("webrtc wait_connected failed: {}", err);
|
||||
// Release the pc now rather than waiting for the ICE agent to time out into a
|
||||
// terminal state (~30s); this also drops the SESSIONS entry promptly.
|
||||
stream.close().await;
|
||||
return;
|
||||
}
|
||||
// create_tcp_connection takes ownership of the stream; keep a handle to close the pc
|
||||
// once the session returns. It runs the whole session and returns Ok on normal end,
|
||||
// Err on setup failure — either way the pc must be closed, else it lingers forever in
|
||||
// SESSIONS (its state handler only fires on a terminal ICE state, which a cleanly
|
||||
// closed session may never reach) leaking the pc, channels, and socket fds.
|
||||
let stream_for_cleanup = stream.clone();
|
||||
if let Err(err) = crate::server::create_tcp_connection(
|
||||
server,
|
||||
Stream::WebRTC(stream),
|
||||
peer_addr,
|
||||
true,
|
||||
meta,
|
||||
)
|
||||
.await
|
||||
{
|
||||
log::warn!("failed to create WebRTC server connection: {}", err);
|
||||
}
|
||||
stream_for_cleanup.close().await;
|
||||
});
|
||||
|
||||
Ok(answer)
|
||||
}
|
||||
|
||||
async fn handle_punch_hole(&self, ph: PunchHole, server: ServerPtr) -> ResultType<()> {
|
||||
let mut peer_addr = AddrMangle::decode(&ph.socket_addr);
|
||||
let last = *LAST_MSG.lock().await;
|
||||
@@ -651,12 +902,41 @@ impl RendezvousMediator {
|
||||
return Ok(());
|
||||
}
|
||||
let peer_addr_v6 = hbb_common::AddrMangle::decode(&ph.socket_addr_v6);
|
||||
let relay = use_ws() || Config::is_proxy() || ph.force_relay;
|
||||
let local_proxy = use_ws() || Config::is_proxy();
|
||||
let relay = local_proxy || ph.force_relay;
|
||||
let mut socket_addr_v6 = Default::default();
|
||||
let meta = connection_meta(
|
||||
ph.control_permissions.into_option(),
|
||||
ph.controlled_context.into_option(),
|
||||
ph.control_permissions.clone().into_option(),
|
||||
ph.controlled_context.clone().into_option(),
|
||||
);
|
||||
// The controller's force_relay alone does not say whether ICE must be Relay-only; its
|
||||
// offer envelope does. `ice_policy: "all"` means the relay was forced by the transport
|
||||
// (ws), so answer with full ICE and let a direct pair form.
|
||||
let webrtc_relay_only =
|
||||
ph.force_relay && !WebRTCStream::endpoint_declares_all_ice(&ph.webrtc_sdp_offer);
|
||||
// No enable-webrtc check here: it is LocalConfig, which the UI process writes and never
|
||||
// syncs over IPC, so this (server) process would read the private-server default of "N"
|
||||
// and refuse to answer in exactly the self-hosted deployments the transport is for.
|
||||
// A proxy still rules it out — ICE would bypass it and leak the real IP.
|
||||
let webrtc_viable = !ph.webrtc_sdp_offer.is_empty()
|
||||
&& !Config::is_proxy()
|
||||
&& (!webrtc_relay_only || WebRTCStream::has_turn_server());
|
||||
let webrtc_sdp_answer = if webrtc_viable {
|
||||
self.spawn_webrtc_answerer(
|
||||
&ph,
|
||||
webrtc_relay_only,
|
||||
server.clone(),
|
||||
peer_addr,
|
||||
meta.clone(),
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|err| {
|
||||
log::warn!("failed to create WebRTC answer: {}", err);
|
||||
String::new()
|
||||
})
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
if peer_addr_v6.port() > 0 && !relay {
|
||||
socket_addr_v6 =
|
||||
start_ipv6(peer_addr_v6, peer_addr, server.clone(), meta.clone()).await;
|
||||
@@ -678,6 +958,7 @@ impl RendezvousMediator {
|
||||
true,
|
||||
true,
|
||||
socket_addr_v6.clone(),
|
||||
webrtc_sdp_answer.clone(),
|
||||
meta,
|
||||
)
|
||||
.await;
|
||||
@@ -691,6 +972,7 @@ impl RendezvousMediator {
|
||||
nat_type: nat_type.into(),
|
||||
version: crate::VERSION.to_owned(),
|
||||
socket_addr_v6,
|
||||
webrtc_sdp_answer,
|
||||
..Default::default()
|
||||
};
|
||||
if ph.udp_port > 0 {
|
||||
@@ -699,12 +981,25 @@ impl RendezvousMediator {
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
if !ph.webrtc_sdp_offer.is_empty() {
|
||||
// Return the answer over its own short-lived TCP connection rather than the mediator
|
||||
// channel: that channel is UDP by default, and hbbs applies UDP-punch semantics
|
||||
// (source-address observation) to a PunchHoleSent that arrives on it. No TCP punch
|
||||
// is made — the controller keeps its request socket for trickled ICE.
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_punch_hole_sent(msg_punch);
|
||||
let mut socket = connect_tcp(&*self.host, CONNECT_TIMEOUT).await?;
|
||||
socket.send(&msg_out).await?;
|
||||
return Ok(());
|
||||
}
|
||||
log::debug!("Punch tcp hole to {:?}", peer_addr);
|
||||
let mut socket = {
|
||||
let socket = connect_tcp(&*self.host, CONNECT_TIMEOUT).await?;
|
||||
let local_addr = socket.local_addr();
|
||||
// key important here for punch hole to tell my gateway incoming peer is safe.
|
||||
// it can not be async here, because local_addr can not be reused, we must close the connection before use it again.
|
||||
// Awaited rather than spawned so the mapping exists before `PunchHoleSent` goes out;
|
||||
// `local_addr` itself is shared, not exclusive - every socket here binds it with the
|
||||
// reuse flags `new_socket` sets.
|
||||
allow_err!(socket_client::connect_tcp_local(peer_addr, Some(local_addr), 30).await);
|
||||
socket
|
||||
};
|
||||
@@ -712,7 +1007,10 @@ impl RendezvousMediator {
|
||||
msg_out.set_punch_hole_sent(msg_punch);
|
||||
let bytes = msg_out.write_to_bytes()?;
|
||||
socket.send_raw(bytes).await?;
|
||||
crate::accept_connection(server.clone(), socket, peer_addr, true, meta).await;
|
||||
let local_addr = socket.local_addr();
|
||||
// The listener inside takes this address over, so the mediator's socket goes first.
|
||||
drop(socket);
|
||||
punch_tcp_until_connected(server, peer_addr, local_addr, meta).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -951,11 +1249,11 @@ async fn udp_nat_listen(
|
||||
let socket_cloned = socket.clone();
|
||||
let func = async {
|
||||
socket.connect(peer_addr).await?;
|
||||
let res = crate::punch_udp(socket.clone(), true).await?;
|
||||
let init_packet = crate::punch_udp(socket.clone(), true).await?;
|
||||
let stream = crate::kcp_stream::KcpStream::accept(
|
||||
socket,
|
||||
Duration::from_millis(CONNECT_TIMEOUT as _),
|
||||
res,
|
||||
init_packet,
|
||||
)
|
||||
.await?;
|
||||
crate::server::create_tcp_connection(server, stream.1, peer_addr_v4, true, meta).await?;
|
||||
@@ -971,6 +1269,194 @@ async fn udp_nat_listen(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Where the repeats start, and the factor they slow by. The controller's SYN arrives once, at an
|
||||
/// instant we are never told, inside a window we are not told either: `Client::connect` sizes its
|
||||
/// dial only after our PunchHoleSent, from its own rendezvous time and the direct failures it has
|
||||
/// recorded for us - `CONNECT_TIMEOUT` between two known-asymmetric NATs that never failed, as
|
||||
/// little as a second once one has. So the repeats cover our own ceiling instead, `CONNECT_TIMEOUT`,
|
||||
/// which is as long as the accept below has always been willing to take a connection, and back
|
||||
/// off across it: dense at the start, where every window begins and the short ones end, sparse
|
||||
/// afterwards, which is `punch_udp`'s shape for the same reason.
|
||||
const PUNCH_INTERVAL: f32 = 0.15;
|
||||
const PUNCH_BACKOFF: f32 = 1.5;
|
||||
const PUNCH_MAX_INTERVAL: f32 = 2.0;
|
||||
/// How long a punch in flight may run past the deadline, and the only timer it runs on. A punch
|
||||
/// is cancel-safe while it is still in SYN_SENT and not once the controller's SYN has crossed it:
|
||||
/// the socket is then half way through a handshake, and dropping it there cuts the connection the
|
||||
/// controller is opening - which its `connect` has already returned, so that attempt fails
|
||||
/// outright rather than falling back to relay. A timer cannot tell the two states apart, so no
|
||||
/// punch is cut on a schedule of its own, and none needs to be. A gateway that answers with RST
|
||||
/// fails the connect at once, and the loop punches again. One that drops the SYN in silence
|
||||
/// leaves the socket in SYN_SENT, where it holds the mapping open and the kernel re-sends the
|
||||
/// SYN, and any SYN of the controller's that arrives crosses it - a second punch has nothing to
|
||||
/// add. That leaves the deadline, and this much past it lets a crossing begun just before it
|
||||
/// complete; Windows gives a SYN up at about 21s anyway.
|
||||
const PUNCH_GRACE: u64 = 3000;
|
||||
|
||||
/// The punch above leaves before hbbs has told the controller where to dial, so it is never in
|
||||
/// flight at the same time as the controller's SYN: it opens our NAT, meets nothing, and a gateway
|
||||
/// that answers it with RST takes the mapping down with it - leaving the listener below waiting on
|
||||
/// a hole that no longer exists. Punching again across the window in which the controller dials
|
||||
/// rebuilds it, and once the controller sits in SYN_SENT one of those punches meets its SYN and
|
||||
/// completes as a simultaneous open: a second way in, which a single punch never had.
|
||||
async fn punch_tcp_until_connected(
|
||||
server: ServerPtr,
|
||||
peer_addr: SocketAddr,
|
||||
local_addr: SocketAddr,
|
||||
meta: ConnectionMeta,
|
||||
) {
|
||||
use hbb_common::tcp::new_listener;
|
||||
// Shadows the module's `std::time::Instant`: the deadline is held against tokio's sleeps and
|
||||
// timeouts, so it runs on their clock.
|
||||
use hbb_common::tokio::time::Instant;
|
||||
|
||||
// Not fatal on its own - the punch below can still meet the controller's SYN without it, and
|
||||
// that half is the one a listener the OS refused to bind could not have covered anyway.
|
||||
let listener = match new_listener(local_addr, true).await {
|
||||
Ok(listener) => {
|
||||
log::info!("Server listening on: {local_addr}");
|
||||
Some(listener)
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("Failed to listen on {local_addr} after punching: {err}");
|
||||
None
|
||||
}
|
||||
};
|
||||
// Bounds both halves: the punch keeps the mapping open only while the accept is still
|
||||
// willing to take a connection through it.
|
||||
let until = Instant::now() + Duration::from_millis(CONNECT_TIMEOUT);
|
||||
let punch = punch_until(until, peer_addr, |ms| {
|
||||
socket_client::connect_tcp_local(peer_addr, Some(local_addr), ms)
|
||||
});
|
||||
let Some(listener) = listener else {
|
||||
if let Some(stream) = punch.await {
|
||||
serve_punched(server, stream, peer_addr, meta).await;
|
||||
}
|
||||
return;
|
||||
};
|
||||
// Accepting in a loop, not once: a transient `accept` error must not spend the whole window
|
||||
// the controller still has to arrive in.
|
||||
let accept = async {
|
||||
loop {
|
||||
let left = until.saturating_duration_since(Instant::now()).as_millis() as u64;
|
||||
if left == 0 {
|
||||
break;
|
||||
}
|
||||
match hbb_common::timeout(left, listener.accept()).await {
|
||||
// Not filtered by address, as `accept_connection` never did: hbbs saw the
|
||||
// controller through one mapping and a NAT that pools its external addresses may
|
||||
// dial us from another, and what keeps `meta`'s control permissions from a second
|
||||
// peer is the handshake, plus that exactly one connection is ever served.
|
||||
Ok(Ok(accepted)) => return Some(accepted),
|
||||
Ok(Err(err)) => {
|
||||
log::warn!("Failed to accept from {peer_addr}: {err}");
|
||||
// One that persists - EMFILE, say - would otherwise spin here for the window.
|
||||
sleep(1.).await;
|
||||
}
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
log::info!("Nothing connected to the hole punched to {peer_addr}");
|
||||
None
|
||||
};
|
||||
// Only the accept races the punch. Racing `accept_connection` instead would race the whole
|
||||
// session it goes on to run, so a punch landing mid-session would tear that session down.
|
||||
//
|
||||
// Whichever arrives first is the one connection this request produces. Serving the loser too
|
||||
// would give a second peer the control permissions hbbs granted for this one controller, and
|
||||
// no test on the connection itself can tell the two apart before `create_tcp_connection` has
|
||||
// spoken to it - so the invariant is kept here, by there being no second serve.
|
||||
let punched = select! {
|
||||
// Both ready at once is two connections, not one seen twice - a crossing carries the
|
||||
// punch's four-tuple, which the listener never matches - and the punch is the one kept:
|
||||
// it is known to have met something at the address hbbs gave, where the accept takes
|
||||
// any address, and dropping it would reset the connection the controller is opening.
|
||||
biased;
|
||||
Some(stream) = punch => stream,
|
||||
Some((stream, addr)) = accept => {
|
||||
return accept_punched_connection(server, stream, addr, meta).await;
|
||||
}
|
||||
else => return,
|
||||
};
|
||||
serve_punched(server, punched, peer_addr, meta).await;
|
||||
}
|
||||
|
||||
/// The repeats of `punch_tcp_until_connected`, over any punch rather than `connect_tcp_local`
|
||||
/// alone, so that a test can run the schedule against a paused clock - which no socket can be.
|
||||
async fn punch_until<T, F, Fut>(
|
||||
until: tokio::time::Instant,
|
||||
peer_addr: SocketAddr,
|
||||
mut punch: F,
|
||||
) -> Option<T>
|
||||
where
|
||||
F: FnMut(u64) -> Fut,
|
||||
Fut: std::future::Future<Output = ResultType<T>>,
|
||||
{
|
||||
use hbb_common::tokio::time::Instant;
|
||||
|
||||
let mut interval = PUNCH_INTERVAL;
|
||||
let mut round = 0;
|
||||
loop {
|
||||
// The deadline decides whether another punch starts, never how long one already in
|
||||
// flight may take: that one runs to PUNCH_GRACE past it.
|
||||
let left = until.saturating_duration_since(Instant::now());
|
||||
if left.is_zero() {
|
||||
log::debug!("None of {round} punches to {peer_addr} was met");
|
||||
return None;
|
||||
}
|
||||
// Cut at the deadline rather than slept out past it, so the window ends on a punch and
|
||||
// not on a gap of up to PUNCH_MAX_INTERVAL: the controller's window opened after ours,
|
||||
// on the PunchHoleSent hbbs relayed, so one as long as ours is still open through our tail.
|
||||
tokio::time::sleep(Duration::from_secs_f32(interval).min(left)).await;
|
||||
interval = (interval * PUNCH_BACKOFF).min(PUNCH_MAX_INTERVAL);
|
||||
let ms = until.saturating_duration_since(Instant::now()).as_millis() as u64 + PUNCH_GRACE;
|
||||
match punch(ms).await {
|
||||
// The controller's SYN crossed this punch, so the stream is the connection it
|
||||
// dialed, not a spare one: dropping it would reset that connection.
|
||||
Ok(stream) => return Some(stream),
|
||||
// Not logged one by one, but the count says which gateway it was: RST fails a
|
||||
// punch at once and fits a dozen into the window, a silent drop holds the one
|
||||
// punch for the whole of it. `connect_tcp_local` keeps no errno anyway.
|
||||
Err(_) => round += 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn serve_punched(
|
||||
server: ServerPtr,
|
||||
stream: Stream,
|
||||
peer_addr: SocketAddr,
|
||||
meta: ConnectionMeta,
|
||||
) {
|
||||
log::info!("Punched tcp hole to {peer_addr}, connected on the punch itself");
|
||||
if let Err(err) =
|
||||
crate::server::create_tcp_connection(server, stream, peer_addr, true, meta).await
|
||||
{
|
||||
log::warn!("Failed to serve the connection punched to {peer_addr}: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The accept half of `accept_connection`, kept here because only the accept may race the punch.
|
||||
async fn accept_punched_connection(
|
||||
server: ServerPtr,
|
||||
stream: tokio::net::TcpStream,
|
||||
addr: SocketAddr,
|
||||
meta: ConnectionMeta,
|
||||
) {
|
||||
use crate::server::create_tcp_connection;
|
||||
|
||||
stream.set_nodelay(true).ok();
|
||||
match stream.local_addr() {
|
||||
Ok(stream_addr) => {
|
||||
let stream = Stream::from(stream, stream_addr);
|
||||
if let Err(err) = create_tcp_connection(server, stream, addr, true, meta).await {
|
||||
log::warn!("Failed to serve the connection from {addr}: {err}");
|
||||
}
|
||||
}
|
||||
Err(err) => log::warn!("Failed to read the address accepted from {addr}: {err}"),
|
||||
}
|
||||
}
|
||||
|
||||
// When config is not yet synced from root, register_pk may have already been sent with a new generated pk.
|
||||
// After config sync completes, the pk may change. This struct detects pk changes and triggers
|
||||
// a re-registration by setting key_confirmed to false.
|
||||
@@ -995,3 +1481,255 @@ impl Drop for CheckIfResendPk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{mpsc, socket_client, tokio, IceRoute, ICE_DEDUP_WINDOW, MAX_PENDING_REMOTE_ICE};
|
||||
use hbb_common::tcp::new_listener;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
// A SOCKS proxy makes `connect_tcp_local` dial the proxy and ignore the local address, so
|
||||
// nothing these two assert can hold. Read once, from the same global config production reads.
|
||||
fn proxied() -> bool {
|
||||
hbb_common::config::Config::get_socks().is_some()
|
||||
}
|
||||
|
||||
/// Both held while their addresses are read, so the pair cannot be the same port - which
|
||||
/// `SO_REUSEPORT` would let bind twice rather than refuse, leaving the tests degenerate.
|
||||
async fn free_loopback_pair() -> (SocketAddr, SocketAddr) {
|
||||
let (a, b) = (
|
||||
tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(),
|
||||
tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(),
|
||||
);
|
||||
(a.local_addr().unwrap(), b.local_addr().unwrap())
|
||||
}
|
||||
|
||||
fn queue(route: &mut IceRoute, candidate: &str) -> bool {
|
||||
route.queue(candidate.to_owned())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_re_sent_copy_does_not_spend_a_queue_slot() {
|
||||
// Two slots, three sends: without the dedup the re-send takes the second and "relay",
|
||||
// the one that traverses NAT, is the one refused.
|
||||
let (tx, mut rx) = mpsc::channel::<String>(2);
|
||||
let mut route = IceRoute::new(tx);
|
||||
for _ in 0..2 {
|
||||
assert!(queue(&mut route, "host"));
|
||||
}
|
||||
assert!(queue(&mut route, "relay"));
|
||||
let mut queued = Vec::new();
|
||||
while let Ok(candidate) = rx.try_recv() {
|
||||
queued.push(candidate);
|
||||
}
|
||||
assert_eq!(queued, vec!["host".to_owned(), "relay".to_owned()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_candidate_the_full_queue_refused_is_not_remembered() {
|
||||
let (tx, mut rx) = mpsc::channel::<String>(1);
|
||||
let mut route = IceRoute::new(tx);
|
||||
assert!(queue(&mut route, "host"));
|
||||
assert!(!queue(&mut route, "relay"));
|
||||
// The re-send is the only repair for a refused candidate; remembering it would swallow it.
|
||||
assert_eq!(rx.try_recv().ok(), Some("host".to_owned()));
|
||||
assert!(queue(&mut route, "relay"));
|
||||
assert_eq!(rx.try_recv().ok(), Some("relay".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_re_send_is_skipped_while_the_original_is_still_queued() {
|
||||
let (tx, mut rx) = mpsc::channel::<String>(MAX_PENDING_REMOTE_ICE);
|
||||
let mut route = IceRoute::new(tx);
|
||||
for i in 0..MAX_PENDING_REMOTE_ICE {
|
||||
assert!(queue(&mut route, &format!("candidate-{}", i)));
|
||||
}
|
||||
assert!(queue(&mut route, "candidate-0"));
|
||||
let mut queued = 0;
|
||||
while rx.try_recv().is_ok() {
|
||||
queued += 1;
|
||||
}
|
||||
assert_eq!(queued, MAX_PENDING_REMOTE_ICE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_window_forgets_in_arrival_order() {
|
||||
let (tx, mut rx) = mpsc::channel::<String>(MAX_PENDING_REMOTE_ICE);
|
||||
let mut route = IceRoute::new(tx);
|
||||
for i in 0..=ICE_DEDUP_WINDOW {
|
||||
assert!(queue(&mut route, &format!("candidate-{}", i)));
|
||||
assert!(rx.try_recv().is_ok());
|
||||
}
|
||||
// The oldest digest made room for the newest, so its re-send is admitted again.
|
||||
assert!(queue(&mut route, "candidate-0"));
|
||||
assert!(rx.try_recv().is_ok());
|
||||
// A recent one is still skipped.
|
||||
let recent = format!("candidate-{}", ICE_DEDUP_WINDOW);
|
||||
assert!(queue(&mut route, &recent));
|
||||
assert!(rx.try_recv().is_err());
|
||||
}
|
||||
|
||||
// The second way in that the repeat punch opens: a punch reaching a peer already in SYN_SENT
|
||||
// is answered by that socket rather than reset, and the two ends come up on one connection.
|
||||
// A punch that misses the crossing is reset outright here, loopback having no NAT to absorb
|
||||
// it and no round trip to hide behind - so a single punch lands only by luck, and repeating
|
||||
// is what makes it land at all. That is the premise of the repeat, asserted directly. A round
|
||||
// that misses costs one loopback RST, so rounds are cheap and there are many.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn a_punch_that_meets_the_peers_syn_connects_both_ends() {
|
||||
// The crossing needs both connects genuinely in flight at once. Loopback answers a SYN to
|
||||
// a port nobody is listening on with an instant RST, so on one CPU the first connect runs
|
||||
// to completion before the second is scheduled and no round can ever cross - a property of
|
||||
// the box, which this test cannot tell apart from a broken punch.
|
||||
if proxied() || std::thread::available_parallelism().map_or(true, |cpus| cpus.get() < 2) {
|
||||
return;
|
||||
}
|
||||
for _ in 0..256 {
|
||||
let (a, b) = free_loopback_pair().await;
|
||||
// Held for the whole crossing, because production always has one here and the design
|
||||
// rests on which of the two the kernel hands the connection to: the punch and the
|
||||
// peer's SYN share a four-tuple exactly, the listener only matches the address, and
|
||||
// the punch has to win that or every crossing would be swallowed as a plain accept.
|
||||
let listener = new_listener(a, true).await.unwrap();
|
||||
let to_b = tokio::spawn(socket_client::connect_tcp_local(b, Some(a), 3000));
|
||||
let to_a = tokio::spawn(socket_client::connect_tcp_local(a, Some(b), 3000));
|
||||
let (at_a, at_b) = tokio::join!(to_b, to_a);
|
||||
let (Ok(Ok(mut at_a)), Ok(Ok(mut at_b))) = (at_a, at_b) else {
|
||||
continue;
|
||||
};
|
||||
at_a.send_bytes(bytes::Bytes::from_static(b"punch"))
|
||||
.await
|
||||
.unwrap();
|
||||
let got = at_b.next_timeout(3000).await.unwrap().unwrap();
|
||||
assert_eq!(&got[..], b"punch", "both ends must share one connection");
|
||||
assert!(
|
||||
hbb_common::timeout(200, listener.accept()).await.is_err(),
|
||||
"the crossing must reach the punch, not be accepted as an inbound connection"
|
||||
);
|
||||
return;
|
||||
}
|
||||
panic!("no punch met the peer's SYN in 256 rounds on a machine that can cross them");
|
||||
}
|
||||
|
||||
// The punch binds the address the listener already holds, so it has to go through the same
|
||||
// `connect_tcp_local` production uses - a punch built by hand here would still pass if
|
||||
// `new_socket` ever stopped setting the reuse flags, while every real punch failed to bind.
|
||||
// The peer's view of the source port is what proves the bind took: a fallback to an ephemeral
|
||||
// one would connect just as happily.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn a_punch_binds_the_address_the_listener_holds() {
|
||||
if proxied() {
|
||||
return;
|
||||
}
|
||||
// `free_loopback_pair` hands back ports it no longer holds, so another process can take
|
||||
// one in between; retry rather than fail for something the punch had no part in.
|
||||
for _ in 0..8 {
|
||||
let (local, peer_addr) = free_loopback_pair().await;
|
||||
let (Ok(listener), Ok(peer)) = (
|
||||
new_listener(local, true).await,
|
||||
new_listener(peer_addr, true).await,
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
let punch = tokio::spawn(socket_client::connect_tcp_local(
|
||||
peer_addr,
|
||||
Some(local),
|
||||
1500,
|
||||
));
|
||||
let (_peer_side, seen_as) = hbb_common::timeout(3000, peer.accept())
|
||||
.await
|
||||
.expect("the punch must reach the peer")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
seen_as.port(),
|
||||
local.port(),
|
||||
"the punch must leave from the address the listener holds, not an ephemeral one"
|
||||
);
|
||||
// Held, not asserted and dropped: the coexistence below is only exercised while this
|
||||
// socket is still on the address, which is the state production spends its window in.
|
||||
let _punched = punch.await.unwrap().expect("the punch must connect");
|
||||
|
||||
let dialed = tokio::spawn(tokio::net::TcpStream::connect(local));
|
||||
let accepted = hbb_common::timeout(3000, listener.accept()).await;
|
||||
assert!(
|
||||
matches!(accepted, Ok(Ok(_))),
|
||||
"the listener must still take connections while a punch shares its address: {accepted:?}"
|
||||
);
|
||||
assert!(dialed.await.unwrap().is_ok());
|
||||
return;
|
||||
}
|
||||
panic!("could not hold two free loopback addresses in 8 tries");
|
||||
}
|
||||
|
||||
// The schedule on its own, against a paused clock: the window is CONNECT_TIMEOUT long, and
|
||||
// what these pin is where inside it the punches fall, which no socket could show.
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn the_punches_end_on_one_at_the_deadline() {
|
||||
use super::{punch_until, PUNCH_GRACE, PUNCH_INTERVAL, PUNCH_MAX_INTERVAL};
|
||||
use hbb_common::{anyhow::anyhow, config::CONNECT_TIMEOUT};
|
||||
use std::time::Duration;
|
||||
use tokio::time::Instant;
|
||||
|
||||
let peer: SocketAddr = "127.0.0.1:1".parse().unwrap();
|
||||
let start = Instant::now();
|
||||
let until = start + Duration::from_millis(CONNECT_TIMEOUT);
|
||||
let mut punches = Vec::new();
|
||||
// A gateway that answers with RST: every punch fails the moment it is made.
|
||||
let met = punch_until::<(), _, _>(until, peer, |ms| {
|
||||
punches.push((Instant::now(), ms));
|
||||
async { Err(anyhow!("RST")) }
|
||||
})
|
||||
.await;
|
||||
assert!(met.is_none());
|
||||
assert_eq!(
|
||||
Instant::now(),
|
||||
until,
|
||||
"must return the moment the window closes, not a backoff later"
|
||||
);
|
||||
// Tokio rounds every sleep up to the next millisecond.
|
||||
let slack = Duration::from_millis(1);
|
||||
assert!(punches[0].0 - start <= Duration::from_secs_f32(PUNCH_INTERVAL) + slack);
|
||||
for pair in punches.windows(2) {
|
||||
assert!(
|
||||
pair[1].0 - pair[0].0 <= Duration::from_secs_f32(PUNCH_MAX_INTERVAL) + slack,
|
||||
"no gap in the window may exceed the backoff ceiling: {pair:?}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
*punches.last().unwrap(),
|
||||
(until, PUNCH_GRACE),
|
||||
"the window must end on a punch, given the whole grace"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn a_punch_in_flight_runs_the_grace_past_the_deadline_and_no_further() {
|
||||
use super::{punch_until, PUNCH_GRACE};
|
||||
use hbb_common::{anyhow::anyhow, config::CONNECT_TIMEOUT};
|
||||
use std::time::Duration;
|
||||
use tokio::time::Instant;
|
||||
|
||||
let peer: SocketAddr = "127.0.0.1:1".parse().unwrap();
|
||||
let until = Instant::now() + Duration::from_millis(CONNECT_TIMEOUT);
|
||||
let mut punches = 0;
|
||||
// A gateway that drops the SYN in silence: the punch sits in SYN_SENT for all it is given.
|
||||
let met = punch_until::<(), _, _>(until, peer, |ms| {
|
||||
punches += 1;
|
||||
async move {
|
||||
tokio::time::sleep(Duration::from_millis(ms)).await;
|
||||
Err(anyhow!("timed out"))
|
||||
}
|
||||
})
|
||||
.await;
|
||||
assert!(met.is_none());
|
||||
assert_eq!(
|
||||
punches, 1,
|
||||
"a punch held in SYN_SENT is the only one the window needs"
|
||||
);
|
||||
assert_eq!(
|
||||
Instant::now(),
|
||||
until + Duration::from_millis(PUNCH_GRACE),
|
||||
"must return when the grace runs out, not a backoff later"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +211,21 @@ pub async fn create_tcp_connection(
|
||||
let sk = sign::SecretKey(sk_);
|
||||
let mut msg_out = Message::new();
|
||||
let (our_pk_b, our_sk_b) = box_::gen_keypair();
|
||||
// On a WebRTC transport, bind our DTLS certificate fingerprint to our signed identity so
|
||||
// the controller can verify the DTLS channel it negotiated actually terminates at us
|
||||
// (not a rendezvous/relay that swapped the SDP fingerprint). Empty on other transports.
|
||||
// Fail immediately on WebRTC if the local fingerprint is unavailable: signing "" would
|
||||
// only make the client fail-closed after a wasted round-trip.
|
||||
let dtls_fingerprint = stream.dtls_fingerprint(true).await.unwrap_or_default();
|
||||
if stream.is_webrtc() && dtls_fingerprint.is_empty() {
|
||||
bail!("WebRTC local DTLS fingerprint unavailable");
|
||||
}
|
||||
msg_out.set_signed_id(SignedId {
|
||||
id: sign::sign(
|
||||
&IdPk {
|
||||
id: Config::get_id(),
|
||||
pk: Bytes::from(our_pk_b.0.to_vec()),
|
||||
dtls_fingerprint,
|
||||
..Default::default()
|
||||
}
|
||||
.write_to_bytes()
|
||||
|
||||
@@ -585,13 +585,9 @@ impl Connection {
|
||||
crate::rustdesk_interval(time::interval_at(Instant::now(), TEST_DELAY_TIMEOUT));
|
||||
let mut last_recv_time = Instant::now();
|
||||
|
||||
conn.stream.set_send_timeout(
|
||||
if conn.file_transfer.is_some() || conn.port_forward_socket.is_some() || conn.terminal {
|
||||
SEND_TIMEOUT_OTHER
|
||||
} else {
|
||||
SEND_TIMEOUT_VIDEO
|
||||
},
|
||||
);
|
||||
// The connection type is not known until the login request arrives;
|
||||
// `on_message` picks the type-specific timeout then.
|
||||
conn.stream.set_send_timeout(SEND_TIMEOUT_VIDEO);
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
std::thread::spawn(move || Self::handle_input(_rx_input, tx_cloned));
|
||||
@@ -2580,11 +2576,13 @@ impl Connection {
|
||||
let PortForward {
|
||||
host,
|
||||
port,
|
||||
multiplex,
|
||||
special_fields: _,
|
||||
} = pf;
|
||||
push(b"port_forward");
|
||||
push(host.as_bytes());
|
||||
push(&port.to_le_bytes());
|
||||
push(&[*multiplex as u8]);
|
||||
}
|
||||
// Variants this build does not know execute as remote, so they latch as remote.
|
||||
None | Some(_) => push(b"remote"),
|
||||
@@ -2766,6 +2764,17 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
|
||||
self.stream.set_send_timeout(
|
||||
if self.file_transfer.is_some()
|
||||
|| self.terminal
|
||||
|| matches!(self.lr.union, Some(login_request::Union::PortForward(_)))
|
||||
{
|
||||
SEND_TIMEOUT_OTHER
|
||||
} else {
|
||||
SEND_TIMEOUT_VIDEO
|
||||
},
|
||||
);
|
||||
|
||||
if !crate::common::is_direct_ip_access(&lr.username) && lr.username != Config::get_id()
|
||||
{
|
||||
self.send_login_error(crate::client::LOGIN_MSG_OFFLINE)
|
||||
|
||||
@@ -1294,7 +1294,13 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
|
||||
// override only if true
|
||||
if true == force_relay {
|
||||
self.lc.write().unwrap().force_relay = true;
|
||||
let mut lc = self.lc.write().unwrap();
|
||||
lc.force_relay = true;
|
||||
// An explicit retry-via-relay is a decision about this peer, not transport
|
||||
// necessity: Relay-only ICE for this round like any force-always-relay session,
|
||||
// and it is the one kind of relay that belongs in the peer's saved config.
|
||||
lc.policy_relay = true;
|
||||
lc.peer_relay = true;
|
||||
}
|
||||
self.lc.write().unwrap().peer_info = None;
|
||||
self.reconnect_count.fetch_add(1, Ordering::SeqCst);
|
||||
|
||||
Reference in New Issue
Block a user