Skip to content

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

Open
FrankHan052176 wants to merge 3 commits into
rustdesk:mainfrom
FrankHan052176:ohos/rebased-pr-20260726
Open

fix(ohos): isolate platform paths and use rustls-only TLS#577
FrankHan052176 wants to merge 3 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.

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.

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 (ohos) platform support across configuration paths, IPC/ID generation, fingerprinting, and networking/WebSocket/TLS handling.
    • OpenHarmony builds now use Rustls and platform-appropriate application directory logic.
  • Bug Fixes
    • Prevented Linux-only components from being enabled on OpenHarmony.
    • Disabled native-TLS on OpenHarmony for proxies and WebSockets, with clearer failures instead of fallbacks.
    • Updated TLS caching and connection behavior to better match OpenHarmony capabilities.

@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: 79629a14-420b-4be2-acff-42ac8f96f778

📥 Commits

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

📒 Files selected for processing (1)
  • src/config.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • 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 crates use OpenHarmony Rustls features, while native-TLS and Linux dependencies are excluded from 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 accordingly.

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

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 matches the main OHOS platform-isolation and rustls-only TLS changes in the PR.
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
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