An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
fix: custom client, options, option2bool() (#8302)
fufesou32ab56f864d4
diff --git a/flutter/lib/common.dart b/flutter/lib/common.dartindex 02f95c994..c41eda690 100644--- a/flutter/lib/common.dart+++ b/flutter/lib/common.dart@@ -1422,6 +1422,9 @@ String translate(String name) {return platformFFI.translate(name, localeName);}+// This function must be kept the same as the one in rust and sciter code.+// rust: libs/hbb_common/src/config.rs -> option2bool()+// sciter: Does not have the function, but it should be kept the same.bool option2bool(String option, String value) {bool res;if (option.startsWith("enable-")) {diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rsindex bfce3b52e..02a0f66ec 100644--- a/libs/hbb_common/src/config.rs+++ b/libs/hbb_common/src/config.rs@@ -2018,6 +2018,24 @@ pub fn is_disable_installation() -> bool {is_some_hard_opton("disable-installation")}+// This function must be kept the same as the one in flutter and sciter code.+// flutter: flutter/lib/common.dart -> option2bool()+// sciter: Does not have the function, but it should be kept the same.+pub fn option2bool(option: &str, value: &str) -> bool {+ if option.starts_with("enable-") {+ value != "N"+ } else if option.starts_with("allow-")+ || option == "stop-service"+ || option == keys::OPTION_DIRECT_SERVER+ || option == "stop-rendezvous-service"+ || option == "force-always-relay"+ {+ value == "Y"+ } else {+ value != "N"+ }+}+pub mod keys {pub const OPTION_VIEW_ONLY: &str = "view_only";pub const OPTION_SHOW_MONITORS_TOOLBAR: &str = "show_monitors_toolbar";diff --git a/libs/hbb_common/src/password_security.rs b/libs/hbb_common/src/password_security.rsindex 9584ab6c0..49a2d4d94 100644--- a/libs/hbb_common/src/password_security.rs+++ b/libs/hbb_common/src/password_security.rs@@ -79,7 +79,7 @@ pub fn approve_mode() -> ApproveMode {pub fn hide_cm() -> bool {approve_mode() == ApproveMode::Password&& verification_method() == VerificationMethod::OnlyUsePermanentPassword- && !Config::get_option("allow-hide-cm").is_empty()+ && crate::config::option2bool("allow-hide-cm", &Config::get_option("allow-hide-cm"))}const VERSION_LEN: usize = 2;diff --git a/src/core_main.rs b/src/core_main.rsindex 11d6bb8c4..468ab56df 100644--- a/src/core_main.rs+++ b/src/core_main.rs@@ -83,7 +83,10 @@ pub fn core_main() -> Option<Vec<String>> {#[cfg(feature = "flutter")]{let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "1");- if !config::Config::get_option("allow-always-software-render").is_empty() {+ if config::option2bool(+ "allow-always-software-render",+ &config::Config::get_option("allow-always-software-render"),+ ) {std::env::set_var(k, v);} else {std::env::remove_var(k);diff --git a/src/lan.rs b/src/lan.rsindex eb01e1ffe..bd337ba97 100644--- a/src/lan.rs+++ b/src/lan.rs@@ -34,7 +34,11 @@ pub(super) fn start_listening() -> ResultType<()> {if let Ok(msg_in) = Message::parse_from_bytes(&buf[0..len]) {match msg_in.union {Some(rendezvous_message::Union::PeerDiscovery(p)) => {- if p.cmd == "ping" && Config::get_option("enable-lan-discovery").is_empty()+ if p.cmd == "ping"+ && config::option2bool(+ "enable-lan-discovery",+ &Config::get_option("enable-lan-discovery"),+ ){if let Some(self_addr) = get_ipaddr_by_peer(&addr) {let mut msg_out = Message::new();diff --git a/src/server/connection.rs b/src/server/connection.rsindex 69b9b39f3..c2a754d06 100644--- a/src/server/connection.rs+++ b/src/server/connection.rs@@ -1366,7 +1366,10 @@ impl Connection {fn on_remote_authorized(&self) {self.update_codec_on_login();#[cfg(any(target_os = "windows", target_os = "linux"))]- if !Config::get_option("allow-remove-wallpaper").is_empty() {+ if config::option2bool(+ "allow-remove-wallpaper",+ &Config::get_option("allow-remove-wallpaper"),+ ) {// multi connections set oncelet mut wallpaper = WALLPAPER_REMOVER.lock().unwrap();if wallpaper.is_none() {@@ -1555,7 +1558,10 @@ impl Connection {return false;}}- return Config::get_option(enable_prefix_option).is_empty();+ config::option2bool(+ enable_prefix_option,+ &Config::get_option(enable_prefix_option),+ )}fn update_codec_on_login(&self) {diff --git a/src/server/video_service.rs b/src/server/video_service.rsindex d196d4e9f..899a4cd30 100644--- a/src/server/video_service.rs+++ b/src/server/video_service.rs@@ -37,6 +37,7 @@ use crate::{};use hbb_common::{anyhow::anyhow,+ config,tokio::sync::{mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},Mutex as TokioMutex,@@ -411,7 +412,10 @@ fn run(vs: VideoService) -> ResultType<()> {video_qos.refresh(None);let mut spf;let mut quality = video_qos.quality();- let record_incoming = !Config::get_option("allow-auto-record-incoming").is_empty();+ let record_incoming = config::option2bool(+ "allow-auto-record-incoming",+ &Config::get_option("allow-auto-record-incoming"),+ );let client_record = video_qos.record();drop(video_qos);let (mut encoder, encoder_cfg, codec_format, use_i444, recorder) = match setup_encoder(diff --git a/src/ui/index.tis b/src/ui/index.tisindex 8b57edacb..7c48fffb0 100644--- a/src/ui/index.tis+++ b/src/ui/index.tis@@ -1208,7 +1208,7 @@ function self.onMouse(evt) {}function check_if_overlay() {- if (!handler.get_option('allow-remote-config-modification')) {+ if (handler.get_option('allow-remote-config-modification') == 'Y') {var time0 = getTime();handler.check_mouse_time();self.timer(120ms, function() {