Skip to content

move the modules only rustdesk uses out to the base crate - #598

Merged
rustdesk merged 1 commit into
mainfrom
move-rustdesk-only-modules
Sep 8, 2026
Merged

rustdesk merged 1 commit into
mainfrom
move-rustdesk-only-modules

Conversation

@rustdesk

@rustdesk rustdesk commented Sep 8, 2026

Copy link
Copy Markdown
Owner

hbb_common is shared with the server, but fs, platform, keyboard, message.proto and most of config::keys are reached only from the client. Keeping them here means every change to them costs a submodule round-trip.

They move to the new base crate in the rustdesk tree. What stays is what the server actually names: rendezvous.proto, the socket/stream layer, the Config core, and the 32 option keys this crate reads itself. Those 32 are re-exported from base::config::keys, so callers still see one set.

IdPk moves from message.proto to rendezvous.proto. It is register-pk handshake business, the server is its only other user, and the field numbers are unchanged so the wire format is identical.

config::patch() resolves a home directory through the shell lookup that lived in platform::linux, so find_cmd_path, CMD_* and run_cmds_trim_newline stay behind in a new sh module. base::platform::linux re-exports them, leaving every existing platform::linux::CMD_SH path working.

backtrace, filetime, osascript, smithay-client-toolkit and winapi go with the code that used them, so the server no longer builds a Wayland client toolkit and a Windows API crate it never calls.

Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab

hbb_common is shared with the server, but `fs`, `platform`, `keyboard`,
`message.proto` and most of `config::keys` are reached only from the client.
Keeping them here means every change to them costs a submodule round-trip.

They move to the new `base` crate in the rustdesk tree. What stays is
what the server actually names: `rendezvous.proto`, the socket/stream layer, the
`Config` core, and the 32 option keys this crate reads itself. Those 32 are
re-exported from `base::config::keys`, so callers still see one set.

`IdPk` moves from message.proto to rendezvous.proto. It is register-pk handshake
business, the server is its only other user, and the field numbers are unchanged
so the wire format is identical.

`config::patch()` resolves a home directory through the shell lookup that lived
in `platform::linux`, so `find_cmd_path`, `CMD_*` and `run_cmds_trim_newline`
stay behind in a new `sh` module. `base::platform::linux` re-exports
them, leaving every existing `platform::linux::CMD_SH` path working.

backtrace, filetime, osascript, smithay-client-toolkit and winapi go with the
code that used them, so the server no longer builds a Wayland client toolkit and
a Windows API crate it never calls.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
Copilot AI lite review requested due to automatic review settings September 8, 2026 03:24
@rustdesk
rustdesk merged commit 55395c6 into main Sep 8, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

run_cmds_trim_newline currently ignores command exit status, which can silently treat failures as valid output and lead to incorrect config patch behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR restructures hbb_common to keep only server-relevant code/protos in this crate and move RustDesk client-only modules (platform/UI-adjacent helpers, fs, keyboard, message proto, etc.) out to the new base crate to reduce submodule churn and unnecessary dependencies in the server build.

Changes:

  • Add a Linux-only sh module that retains the command-path lookup + run_cmds_trim_newline() needed by config::patch().
  • Remove client-only modules (platform, fs, keyboard) and stop generating/including message.proto; move IdPk into rendezvous.proto.
  • Trim dependencies/features associated with removed client-only code (e.g., winapi/osascript/sctk/backtrace/filetime; wayland probe feature).
File summaries
File Description
src/sh.rs New Linux shell helper module used by config::patch() to resolve home paths.
src/platform/windows.rs Removed Windows-only platform utilities (moved to base).
src/platform/mod.rs Removed platform module entrypoint (moved to base).
src/platform/macos.rs Removed macOS alert helper (moved to base).
src/platform/linux/wayland_probe.rs Removed Wayland probe implementation + feature gating (moved to base).
src/platform/linux.rs Removed Linux platform utilities (moved to base, except shell helpers).
src/lib.rs Stops exporting removed modules; adds sh module on Linux.
src/keyboard.rs Removed keyboard-mode helpers (moved to base).
src/fs.rs Removed file-transfer/fs helpers (moved to base).
src/config.rs Switches Linux root-home patching to use crate::sh::run_cmds_trim_newline; trims config::keys to only keys referenced in this crate.
protos/rendezvous.proto Adds IdPk message here to keep rendezvous handshake types in the server-facing proto set.
protos/message.proto Removed (no longer generated/used by this crate).
examples/system_message.rs Removed example tied to removed platform APIs.
Cargo.toml Removes dependencies/features associated with moved platform/fs code.
build.rs Stops generating Rust bindings for message.proto; rendezvous only.
Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Cargo.toml
Comment on lines 87 to 89
[target.'cfg(target_os = "linux")'.dependencies]
sctk = { package = "smithay-client-toolkit", version = "0.20.0", default-features = false, features = [
"calloop",
] }
users = { version = "0.11" }
x11 = "2.21"
Comment thread src/sh.rs
Comment on lines +53 to +63
pub fn run_cmds_trim_newline(cmds: &str) -> ResultType<String> {
let output = std::process::Command::new(CMD_SH.as_str())
.args(vec!["-c", cmds])
.output()?;
let out = String::from_utf8_lossy(&output.stdout);
Ok(if out.ends_with('\n') {
out[..out.len() - 1].to_string()
} else {
out.to_string()
})
}
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.

2 participants