fix: custom client, option to bool (#8303)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-06-10 11:01:39 +08:00
committed by GitHub
parent 32ab56f864
commit 9ab5512bfa
8 changed files with 32 additions and 30 deletions

View File

@@ -1286,7 +1286,9 @@ impl LoginConfigHandler {
self.session_id = sid;
self.supported_encoding = Default::default();
self.restarting_remote_device = false;
self.force_relay = !self.get_option("force-always-relay").is_empty() || force_relay;
self.force_relay =
config::option2bool("force-always-relay", &self.get_option("force-always-relay"))
|| force_relay;
if let Some((real_id, server, key)) = &self.other_server {
let other_server_key = self.get_option("other-server-key");
if !other_server_key.is_empty() && key.is_empty() {
@@ -1451,6 +1453,10 @@ impl LoginConfigHandler {
/// # Arguments
///
/// * `name` - The name of the option to toggle.
///
// It's Ok to check the option empty in this function.
// `toggle_option()` is only called in a session.
// Custom client advanced settings will not affact this function.
pub fn toggle_option(&mut self, name: String) -> Option<Message> {
let mut option = OptionMessage::default();
let mut config = self.load_config();
@@ -1707,6 +1713,10 @@ impl LoginConfigHandler {
/// # Arguments
///
/// * `name` - The name of the toggle option.
///
// It's Ok to check the option empty in this function.
// `get_toggle_option()` is only called in a session.
// Custom client advanced settings will not affact this function.
pub fn get_toggle_option(&self, name: &str) -> bool {
if name == "show-remote-cursor" {
self.config.show_remote_cursor.v

View File

@@ -67,7 +67,7 @@ async fn start_hbbs_sync_async() {
*PRO.lock().unwrap() = false;
continue;
}
if !Config::get_option("stop-service").is_empty() {
if hbb_common::config::option2bool("stop-service", &Config::get_option("stop-service")) {
continue;
}
let conns = Connection::alive_conns();
@@ -77,7 +77,7 @@ async fn start_hbbs_sync_async() {
}
if !info_uploaded.0 && info_uploaded.2.map(|x| x.elapsed() >= UPLOAD_SYSINFO_TIMEOUT).unwrap_or(true) {
let mut v = crate::get_sysinfo();
// username is empty in login screen of windows, but here we only upload sysinfo once, causing
// username is empty in login screen of windows, but here we only upload sysinfo once, causing
// real user name not uploaded after login screen. https://github.com/rustdesk/rustdesk/discussions/8031
if !cfg!(windows) || !v["username"].as_str().unwrap_or_default().is_empty() {
v["version"] = json!(crate::VERSION);

View File

@@ -75,7 +75,7 @@ impl RendezvousMediator {
crate::test_nat_type();
nat_tested = true;
}
if !Config::get_option("stop-service").is_empty() {
if config::option2bool("stop-service", &Config::get_option("stop-service")) {
crate::test_rendezvous_server();
}
let server_cloned = server.clone();
@@ -96,7 +96,7 @@ impl RendezvousMediator {
loop {
let conn_start_time = Instant::now();
*SOLVING_PK_MISMATCH.lock().await = "".to_owned();
if Config::get_option("stop-service").is_empty()
if !config::option2bool("stop-service", &Config::get_option("stop-service"))
&& !crate::platform::installing_service()
{
if !nat_tested {