BUILD.md: document the Rust source edit (custom.txt path is broken for unsigned forks)
This commit is contained in:
@@ -114,34 +114,44 @@ Dart 3.12 rejects `const Map<FontWeight, String>{...}`. Change `const` to `final
|
|||||||
be wiped by `flutter pub cache clean`.** To make it permanent, copy the patched file into
|
be wiped by `flutter pub cache clean`.** To make it permanent, copy the patched file into
|
||||||
`./local_google_fonts/` and use `dependency_overrides: google_fonts: { path: ... }`.
|
`./local_google_fonts/` and use `dependency_overrides: google_fonts: { path: ... }`.
|
||||||
|
|
||||||
### 2.6. `flutter/macos/Runner/custom.txt` (default settings via Rust's `load_custom_client`)
|
### 2.6. `src/common.rs` — hardcode `enable-audio` default to off (NOT via custom.txt)
|
||||||
|
|
||||||
RustDesk's Rust core reads `Contents/Resources/custom.txt` on startup
|
**The naive approach (custom.txt) is broken for unsigned forks.** `load_custom_client`
|
||||||
(see `src/common.rs::load_custom_client` + `read_custom_client`). It accepts two
|
reads `Contents/Resources/custom.txt` and passes the content to `read_custom_client`,
|
||||||
keys: `default-settings` (fills `DEFAULT_SETTINGS`; user config still wins) and
|
but `read_custom_client` (line 2191) immediately calls `decode64()` and then
|
||||||
`override-settings` (fills `OVERWRITE_SETTINGS`; user can't override).
|
`sign::verify()` with a hardcoded ed25519 public key. Plain JSON fails the
|
||||||
|
base64 decode and the function returns early — your settings are silently dropped.
|
||||||
|
Only **official signed** custom-client builds can use the `custom.txt` path.
|
||||||
|
|
||||||
**Current contents:**
|
**What we do instead: inject `enable-audio = N` directly into `DEFAULT_SETTINGS` at
|
||||||
```json
|
the end of `load_custom_client`**, in [src/common.rs:2104-2114](src/common.rs#L2104):
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// Custom fork: hardcode enable-audio = N as the default. User can still flip it on in Settings.
|
||||||
|
// Reason: RustDesk's official custom.txt path requires ed25519-signed base64 (see
|
||||||
|
// read_custom_client at line 2191 — decode64 + sign::verify with key
|
||||||
|
// "5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM="), which we can't produce without the
|
||||||
|
// official signing key. So we bypass custom.txt and inject directly into DEFAULT_SETTINGS.
|
||||||
|
// entry().or_insert() preserves the priority chain: OVERWRITE_SETTINGS → CONFIG2 → DEFAULT_SETTINGS.
|
||||||
{
|
{
|
||||||
"app-name": "RustDesk",
|
let mut defaults = config::DEFAULT_SETTINGS.write().unwrap();
|
||||||
"default-settings": {
|
defaults.entry("enable-audio".to_string()).or_insert("N".to_string());
|
||||||
"enable-audio": "N"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Effect: the "Enable audio" option in Settings is **off by default** for new
|
`entry().or_insert()` (not `insert()`) is intentional — it lets users override
|
||||||
installs. Users can still flip it on. To add more defaults, follow the
|
`enable-audio` by writing to their own `RustDesk2.toml`'s `[options]` table
|
||||||
`KEYS_SETTINGS` whitelist in `libs/hbb_common/src/config.rs:3130`.
|
(CONFIG2 wins in the priority chain).
|
||||||
|
|
||||||
**Two parts to make this work:**
|
**To add more default-off settings**, append more `defaults.entry(...).or_insert(...)`
|
||||||
|
lines. Any key from the `KEYS_SETTINGS` whitelist at
|
||||||
|
[libs/hbb_common/src/config.rs:3130](libs/hbb_common/src/config.rs#L3130) works.
|
||||||
|
Candidates: `enable-clipboard`, `enable-keyboard`, `enable-file-transfer`,
|
||||||
|
`enable-tunnel`, `enable-record-session`.
|
||||||
|
|
||||||
1. The file `flutter/macos/Runner/custom.txt` must exist (it does in git).
|
**Verified end-to-end:** debug eprintln confirmed `DEFAULT_SETTINGS.get("enable-audio") == Some("N")`
|
||||||
2. `flutter/macos/Runner.xcodeproj/project.pbxproj` must list `custom.txt` in
|
at startup. UI's "Settings → Permissions" page now shows the audio checkbox unchecked.
|
||||||
the `PBXResourcesBuildPhase`'s `files` list. We added it under UUIDs
|
User can still flip it on in Settings.
|
||||||
`AABBCC000100000000000001` (BuildFile) and `AABBCC000200000000000002`
|
|
||||||
(FileReference). If you regenerate the Xcode project, re-add it.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user