Skip to content

fix(ohos): isolate platform paths and use rustls-only TLS - #577

Closed
FrankHan052176 wants to merge 4 commits into
rustdesk:mainfrom
FrankHan052176:ohos/rebased-pr-20260726
Closed

fix(ohos): isolate platform paths and use rustls-only TLS#577
FrankHan052176 wants to merge 4 commits into
rustdesk:mainfrom
FrankHan052176:ohos/rebased-pr-20260726

Conversation

@FrankHan052176

@FrankHan052176 FrankHan052176 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

This PR adds OpenHarmony-specific platform handling to hbb_common while keeping the existing behavior unchanged on Android, iOS, desktop Linux, macOS, and Windows.

The fork maintains two deliberate branches:

  • ohos/rebase is based on the latest upstream hbb_common/main and replays the OHOS commits. This PR follows that branch and currently points to 7785eb4.
  • ohos/core is the Core-consumption line. It is based on the hbb_common revision currently used by RustDesk Core (f124c0a5) and replays the same OHOS commits, currently at c264f97.

The branches are not interchangeable: ohos/rebase tracks upstream review, while ohos/core keeps the exact dependency history required by the RustDesk Core integration until the upstream changes are merged.

It contains two scoped commits:

  1. Isolate OpenHarmony mobile configuration and platform paths.
  2. Use rustls-only WebSocket and HTTPS proxy TLS on OpenHarmony.

Motivation

Rust OpenHarmony targets such as aarch64-unknown-linux-ohos report:

  • target_os = "linux"
  • target_env = "ohos"

As a result, code guarded only by target_os = "linux" incorrectly treats OpenHarmony as a desktop Linux environment.

OpenHarmony applications do not provide the same desktop Linux environment, filesystem layout, X11/Wayland stack, machine identity sources, or native TLS implementation. This causes unavailable dependencies and platform helpers to be compiled and makes configuration and IPC paths unsuitable for an application sandbox.

Changes

Platform and configuration isolation

  • Treat OpenHarmony as a mobile platform for application-provided home and configuration directories.
  • Store configuration and IPC files under the application-owned directory.
  • Use mobile-style automatic ID generation and fingerprint handling.
  • Exclude desktop Linux-only helpers and dependencies on OpenHarmony, including:
    • X11 and Smithay helpers
    • desktop user lookup
    • machine UID and MAC-address discovery
    • desktop Linux platform utilities
  • Keep the existing desktop Linux behavior unchanged.

TLS handling

  • Do not compile tokio-native-tls for OpenHarmony.
  • Enable rustls-backed tokio-tungstenite and tungstenite features on OpenHarmony.
  • Use rustls for WebSocket and HTTPS proxy connections.
  • Prevent caching or selecting NativeTls on OpenHarmony.
  • Return an explicit error if a NativeTls path is requested unexpectedly.
  • Do not fall back to native TLS after a rustls failure on OpenHarmony.
  • Preserve the existing native TLS and fallback behavior on all other platforms.

Compatibility

All behavioral changes are guarded by target_env = "ohos" or its inverse.

This PR does not change:

  • the network protocol;
  • public data structures;
  • behavior on existing supported platforms;
  • Flutter client behavior;
  • TLS selection on non-OpenHarmony targets.

Branch and dependency validation

  • ohos/rebase (7785eb4) is publicly fetchable and is the head of this PR.
  • ohos/core (c264f97) is publicly fetchable for the RustDesk Core submodule.
  • Both branches contain the same three OHOS changes, replayed on their respective bases.
  • The Core line is based on f124c0a5d49a4a13381902124b65364ff28fa541.

Validation

  • git diff --check upstream/main..HEAD
  • Upstream CI across existing platforms
  • OpenHarmony integration build

Related repository

The OpenHarmony client and integration work are maintained at:

https://github.com/FrankHan052176/rustdesk4ohos

Summary by CodeRabbit

  • New Features
    • Added OpenHarmony platform support across configuration, IPC, identification, fingerprinting, and networking.
    • OpenHarmony builds now use Rustls and platform-appropriate application directories.
  • Bug Fixes
    • Prevented Linux-only components from being enabled on OpenHarmony.
    • Disabled unsupported native-TLS proxy and WebSocket paths with clearer errors.
    • Updated TLS caching and connection handling for OpenHarmony compatibility.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 89eba114-b5ae-47d7-8768-86a8c943fc67

📥 Commits

Reviewing files that changed from the base of the PR and between dfa8060 and 7785eb4.

📒 Files selected for processing (2)
  • Cargo.toml
  • src/config.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • src/config.rs

📝 Walkthrough

Walkthrough

OpenHarmony-specific dependency selection and conditional compilation are added. Configuration, IPC, identity, exports, proxy TLS, WebSocket TLS, and TLS caching now use OpenHarmony-compatible paths and Rustls-only behavior.

Changes

OpenHarmony support

Layer / File(s) Summary
Target-specific TLS and Linux dependencies
Cargo.toml
TLS and WebSocket dependencies now use OpenHarmony Rustls features. Native-TLS and Linux dependencies exclude OpenHarmony builds.
Platform paths, exports, and identity
src/config.rs, src/fingerprint.rs, src/lib.rs, src/platform/mod.rs
OpenHarmony uses app-controlled configuration and IPC paths, mobile-style identifiers, adjusted fingerprints, and platform-specific exports.
OpenHarmony TLS and WebSocket behavior
src/proxy.rs, src/tls.rs, src/websocket.rs
Native-TLS paths are unavailable on OpenHarmony. Rustls connector handling, fallback errors, and TLS cache behavior are updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Mergeability Score: ⚪ Minimal · up to 7785e

This PR isolates OpenHarmony platform behavior and TLS handling without supplied evidence of a current-head correctness or compatibility issue; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant WsFramedStream
  participant Proxy
  participant Rustls
  WsFramedStream->>Rustls: Select OpenHarmony Rustls connector
  WsFramedStream->>Proxy: Attempt TLS/WebSocket connection
  Proxy->>Rustls: Connect without NativeTls fallback
  Rustls-->>Proxy: Return connection result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: OpenHarmony platform isolation and Rustls-only TLS handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/config.rs`:
- Around line 875-880: Update the cfg condition guarding the `/tmp` fallback
`path` declaration so OpenHarmony (`target_os = "linux", target_env = "ohos"`)
is excluded alongside Android, non-OHOS Linux, and macOS. Preserve the earlier
app-owned path declaration for OHOS and avoid introducing a shadowing fallback
there.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 82c32172-caa3-40bb-9add-8a6166aa4963

📥 Commits

Reviewing files that changed from the base of the PR and between 69cea8d and c30d817.

📒 Files selected for processing (8)
  • Cargo.toml
  • src/config.rs
  • src/fingerprint.rs
  • src/lib.rs
  • src/platform/mod.rs
  • src/proxy.rs
  • src/tls.rs
  • src/websocket.rs

Comment thread src/config.rs
@FrankHan052176
FrankHan052176 deleted the ohos/rebased-pr-20260726 branch August 13, 2026 14:13
@FrankHan052176
FrankHan052176 restored the ohos/rebased-pr-20260726 branch August 13, 2026 14:22
@FrankHan052176

Copy link
Copy Markdown
Author

该 PR 的 head 仍绑定旧分支 ohos/rebased-pr-20260726。为保留旧分支和历史不变,已按新的分支职责在 #583ohos/rebase 重新建立同内容 PR;请以后续 #583 为准。

@FrankHan052176
FrankHan052176 deleted the ohos/rebased-pr-20260726 branch August 13, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant