move the modules only rustdesk uses out to the base crate - #598
Merged
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
🟡 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
shmodule that retains the command-path lookup +run_cmds_trim_newline()needed byconfig::patch(). - Remove client-only modules (
platform,fs,keyboard) and stop generating/includingmessage.proto; moveIdPkintorendezvous.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 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 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() | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hbb_common is shared with the server, but
fs,platform,keyboard,message.protoand most ofconfig::keysare reached only from the client. Keeping them here means every change to them costs a submodule round-trip.They move to the new
basecrate in the rustdesk tree. What stays is what the server actually names:rendezvous.proto, the socket/stream layer, theConfigcore, and the 32 option keys this crate reads itself. Those 32 are re-exported frombase::config::keys, so callers still see one set.IdPkmoves 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 inplatform::linux, sofind_cmd_path,CMD_*andrun_cmds_trim_newlinestay behind in a newshmodule.base::platform::linuxre-exports them, leaving every existingplatform::linux::CMD_SHpath 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