Skip to content

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

Open
FrankHan052176 wants to merge 4 commits into
rustdesk:mainfrom
FrankHan052176:ohos/rebase
Open

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

Conversation

@FrankHan052176

@FrankHan052176 FrankHan052176 commented Aug 13, 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, networking, fingerprinting, and platform detection.
    • Added OpenHarmony-compatible Rustls support for proxy and WebSocket connections.
  • Bug Fixes

    • Prevented unsupported native TLS operations and fallbacks on OpenHarmony.
    • Improved platform-specific path, logging, IPC, and TLS cache handling.

@coderabbitai

coderabbitai Bot commented Aug 13, 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: af02c66f-039a-4efe-94a4-63d101c3b049

📥 Commits

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

📒 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

📝 Walkthrough

Walkthrough

The change adds OpenHarmony-specific dependency selection and conditional compilation. OHOS uses Rustls platform verification, excludes Linux-only integrations, disables native-tls proxy and WebSocket paths, and skips native-tls TLS cache entries.

Changes

OpenHarmony support

Layer / File(s) Summary
Target-specific TLS dependencies
Cargo.toml
OHOS uses Rustls-only Tungstenite dependencies. Other targets retain native-tls support. Linux dependencies exclude OHOS.
Platform configuration and identity guards
src/config.rs, src/fingerprint.rs, src/lib.rs, src/platform/mod.rs
OHOS now follows mobile path, identifier, fingerprint, export, and verifier guards. Linux-only configuration and platform modules exclude OHOS.
Proxy native-tls isolation
src/proxy.rs
OHOS excludes native-tls proxy APIs and returns an error instead of using native-tls fallback after Rustls failure.
WebSocket and TLS cache behavior
src/websocket.rs, src/tls.rs
OHOS excludes native-tls connectors, retries, and peer-address handling. Native-tls cache entries are ignored on OHOS.

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

Mergeability Score: 🔵 Low · up to 7785e

On OpenHarmony, the TLS verification export may rely on a backend that is unavailable, leaving the certificate-verification contract unclear; the PR is otherwise localized, but the owner should resolve or document this bounded risk before merging.

Sequence Diagram(s)

sequenceDiagram
  participant Proxy
  participant Rustls
  participant NativeTls
  Proxy->>Rustls: connect with Rustls
  alt non-OHOS Rustls failure
    Rustls-->>Proxy: connection error
    Proxy->>NativeTls: fallback connection
  else OHOS Rustls failure
    Rustls-->>Proxy: connection error
    Proxy-->>Proxy: log error and bail
  end
Loading

Possibly related PRs

Suggested reviewers: 21pages, fufesou, rustdesk

🚥 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 and concisely describes the main changes: isolating OpenHarmony platform paths and using Rustls-only TLS.
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.

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