feat: signed customization client-side hooks
Companion to the rustdesk-server Customization admin page that produces signed custom.txt blobs. - src/common.rs: replaces the hardcoded branding pubkey with a build-time RUSTDESK_BRANDING_PUBKEY env (option_env!), falling back to the operator's primary pubkey so unattended builds still produce a working client. Per-customer keys can be baked in via CI without source edits. - flutter/lib/common.dart: adds getAppIconBytes() (cached, base64 decoded once) and patches loadLogo / loadIcon to honor the buildin app-icon. This covers every existing call-site — desktop home page, server page, tabbar, and mobile settings — without touching any of them. OPTION_APP_ICON itself ships in the hbb_common submodule (already bumped in the previous commit). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3702,8 +3702,35 @@ Widget loadPowered(BuildContext context) {
|
||||
).marginOnly(top: 6);
|
||||
}
|
||||
|
||||
// Cached decoded `app-icon` bytes from the signed custom.txt blob. The blob
|
||||
// stores the image as standard base64 under the buildin key "app-icon"; we
|
||||
// decode once on first read and reuse the bytes for every Image.memory call
|
||||
// below. Empty Uint8List means "no custom icon" and we fall through to the
|
||||
// bundled assets.
|
||||
Uint8List? _appIconBytes;
|
||||
bool _appIconChecked = false;
|
||||
Uint8List? getAppIconBytes() {
|
||||
if (_appIconChecked) return _appIconBytes;
|
||||
_appIconChecked = true;
|
||||
final b64 = bind.mainGetBuildinOption(key: 'app-icon');
|
||||
if (b64.isEmpty) return null;
|
||||
try {
|
||||
_appIconBytes = base64.decode(b64);
|
||||
} catch (_) {
|
||||
_appIconBytes = null;
|
||||
}
|
||||
return _appIconBytes;
|
||||
}
|
||||
|
||||
// max 300 x 60
|
||||
Widget loadLogo() {
|
||||
final custom = getAppIconBytes();
|
||||
if (custom != null) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(maxWidth: 300, maxHeight: 60),
|
||||
child: Image.memory(custom, fit: BoxFit.contain),
|
||||
).marginOnly(left: 12, right: 12, top: 12);
|
||||
}
|
||||
return FutureBuilder<ByteData>(
|
||||
future: rootBundle.load('assets/logo.png'),
|
||||
builder: (BuildContext context, AsyncSnapshot<ByteData> snapshot) {
|
||||
@@ -3725,6 +3752,10 @@ Widget loadLogo() {
|
||||
}
|
||||
|
||||
Widget loadIcon(double size) {
|
||||
final custom = getAppIconBytes();
|
||||
if (custom != null) {
|
||||
return Image.memory(custom, width: size, height: size, fit: BoxFit.contain);
|
||||
}
|
||||
return Image.asset('assets/icon.png',
|
||||
width: size,
|
||||
height: size,
|
||||
|
||||
Reference in New Issue
Block a user