Compare commits

...

2 Commits

3 changed files with 30 additions and 30 deletions
+30 -20
View File
@@ -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
`./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
(see `src/common.rs::load_custom_client` + `read_custom_client`). It accepts two
keys: `default-settings` (fills `DEFAULT_SETTINGS`; user config still wins) and
`override-settings` (fills `OVERWRITE_SETTINGS`; user can't override).
**The naive approach (custom.txt) is broken for unsigned forks.** `load_custom_client`
reads `Contents/Resources/custom.txt` and passes the content to `read_custom_client`,
but `read_custom_client` (line 2191) immediately calls `decode64()` and then
`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:**
```json
**What we do instead: inject `enable-audio = N` directly into `DEFAULT_SETTINGS` at
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",
"default-settings": {
"enable-audio": "N"
}
let mut defaults = config::DEFAULT_SETTINGS.write().unwrap();
defaults.entry("enable-audio".to_string()).or_insert("N".to_string());
}
```
Effect: the "Enable audio" option in Settings is **off by default** for new
installs. Users can still flip it on. To add more defaults, follow the
`KEYS_SETTINGS` whitelist in `libs/hbb_common/src/config.rs:3130`.
`entry().or_insert()` (not `insert()`) is intentional — it lets users override
`enable-audio` by writing to their own `RustDesk2.toml`'s `[options]` table
(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).
2. `flutter/macos/Runner.xcodeproj/project.pbxproj` must list `custom.txt` in
the `PBXResourcesBuildPhase`'s `files` list. We added it under UUIDs
`AABBCC000100000000000001` (BuildFile) and `AABBCC000200000000000002`
(FileReference). If you regenerate the Xcode project, re-add it.
**Verified end-to-end:** debug eprintln confirmed `DEFAULT_SETTINGS.get("enable-audio") == Some("N")`
at startup. UI's "Settings → Permissions" page now shows the audio checkbox unchecked.
User can still flip it on in Settings.
---
@@ -26,7 +26,6 @@
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
7ED2B35F2BB007420099885C /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7ED2B35E2BB007420099885C /* AppIcon.icns */; };
AABBCC000100000000000001 /* custom.txt in Resources */ = {isa = PBXBuildFile; fileRef = AABBCC000200000000000002 /* custom.txt */; };
84010BA8292CF66600152837 /* liblibrustdesk.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 84010BA7292CF66600152837 /* liblibrustdesk.dylib */; settings = {ATTRIBUTES = (Weak, ); }; };
84010BA9292CF68300152837 /* liblibrustdesk.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 84010BA7292CF66600152837 /* liblibrustdesk.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
C5E54335B73C89F72DB1B606 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26C84465887F29AE938039CB /* Pods_Runner.framework */; };
@@ -76,7 +75,6 @@
7436B85D94E8F7B5A9324869 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
7ED2B35E2BB007420099885C /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = AppIcon.icns; path = Runner/AppIcon.icns; sourceTree = "<group>"; };
AABBCC000200000000000002 /* custom.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = custom.txt; path = Runner/custom.txt; sourceTree = "<group>"; };
84010BA7292CF66600152837 /* liblibrustdesk.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liblibrustdesk.dylib; path = ../../target/release/liblibrustdesk.dylib; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
C3BB669FF6190AE1B11BCAEA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
@@ -135,7 +133,6 @@
7ED2B35E2BB007420099885C /* AppIcon.icns */,
33CC10F42044A3C60003C045 /* MainMenu.xib */,
33CC10F72044A3C60003C045 /* Info.plist */,
AABBCC000200000000000002 /* custom.txt */,
);
name = Resources;
path = ..;
@@ -268,7 +265,6 @@
files = (
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
7ED2B35F2BB007420099885C /* AppIcon.icns in Resources */,
AABBCC000100000000000001 /* custom.txt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
-6
View File
@@ -1,6 +0,0 @@
{
"app-name": "RustDesk",
"default-settings": {
"enable-audio": "N"
}
}