diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 3bfc3698c..abba991a2 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -75,11 +75,50 @@ class _DesktopHomePageState extends State ); } + Widget buildPresetPasswordWarning() { + return FutureBuilder( + future: bind.isPresetPassword(), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return CircularProgressIndicator(); // Show a loading spinner while waiting for the Future to complete + } else if (snapshot.hasError) { + return Text( + 'Error: ${snapshot.error}'); // Show an error message if the Future completed with an error + } else if (snapshot.hasData && snapshot.data == true) { + return Container( + color: Colors.yellow, + child: Column( + children: [ + Align( + child: Text( + translate("Security Alert"), + style: TextStyle( + color: Colors.red, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + )).paddingOnly(bottom: 8), + Text( + translate("preset_password_warning"), + style: TextStyle(color: Colors.red), + ) + ], + ).paddingAll(8), + ); // Show a warning message if the Future completed with true + } else { + return SizedBox + .shrink(); // Show nothing if the Future completed with false or null + } + }, + ); + } + Widget buildLeftPane(BuildContext context) { final isIncomingOnly = bind.isIncomingOnly(); final isOutgoingOnly = bind.isOutgoingOnly(); final logo = loadLogo(); final children = [ + if (!isOutgoingOnly) buildPresetPasswordWarning(), if (bind.isCustomClient()) Align( alignment: Alignment.center, diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 252fe194e..0eabf8ad6 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -954,6 +954,14 @@ impl Config { } pub fn set_permanent_password(password: &str) { + if HARD_SETTINGS + .read() + .unwrap() + .get("password") + .map_or(false, |v| v == password) + { + return; + } let mut config = CONFIG.write().unwrap(); if password == config.password { return; diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 555988181..27cbb2c19 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -1849,6 +1849,14 @@ pub fn is_disable_installation() -> SyncReturn { SyncReturn(config::is_disable_installation()) } +pub fn is_preset_password() -> bool { + config::HARD_SETTINGS + .read() + .unwrap() + .get("password") + .map_or(false, |p| p == &crate::ipc::get_permanent_password()) +} + /// Send a url scheme throught the ipc. /// /// * macOS only diff --git a/src/lang/en.rs b/src/lang/en.rs index be32ef336..3961347e4 100644 --- a/src/lang/en.rs +++ b/src/lang/en.rs @@ -2,7 +2,6 @@ lazy_static::lazy_static! { pub static ref T: std::collections::HashMap<&'static str, &'static str> = [ ("desk_tip", "Your desktop can be accessed with this ID and password."), - ("outgoing_only_desk_tip", "This is a customized edition.\nYou can connect to other devices, but other devices cannot connect to your device."), ("connecting_status", "Connecting to the RustDesk network..."), ("not_ready_status", "Not ready. Please check your connection"), ("ID/Relay Server", "ID/Relay server"), @@ -215,5 +214,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("wrong-2fa-code", "Can't verify the code. Check that code and local time settings are correct"), ("enter-2fa-title", "Two-factor authentication"), ("powered_by_me", "Powered by RustDesk"), + ("outgoing_only_desk_tip", "This is a customized edition.\nYou can connect to other devices, but other devices cannot connect to your device."), + ("preset_password_warning", "This software uses a default password. Anyone knowing this password can gain full control of your device. If you did not expect this, uninstall the software immediately."), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index 4bedbcb1e..8e20292ae 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -588,5 +588,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Please select the session you want to connect to", ""), ("powered_by_me", ""), ("outgoing_only_desk_tip", ""), + ("preset_password_warning", ""), + ("Security Alert", ""), ].iter().cloned().collect(); }