OPTION_PRESET_STRATEGY_NAME, OPTION_PRESET_USERNAME

This commit is contained in:
rustdesk 2024-07-17 20:10:56 +08:00
parent 875ac28ab5
commit f0587796e2
2 changed files with 17 additions and 5 deletions

View File

@ -2096,6 +2096,8 @@ pub mod keys {
pub const OPTION_KEY: &str = "key";
pub const OPTION_PRESET_ADDRESS_BOOK_NAME: &str = "preset-address-book-name";
pub const OPTION_PRESET_ADDRESS_BOOK_TAG: &str = "preset-address-book-tag";
pub const OPTION_PRESET_USERNAME: &str = "preset-username";
pub const OPTION_PRESET_STRATEGY_NAME: &str = "preset-strategy-name";
pub const OPTION_ENABLE_DIRECTX_CAPTURE: &str = "enable-directx-capture";
pub const OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE: &str =
"enable-android-software-encoding-half-scale";
@ -2236,6 +2238,8 @@ pub mod keys {
OPTION_ENABLE_DIRECTX_CAPTURE,
OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE,
OPTION_DISABLE_UDP,
OPTION_PRESET_USERNAME,
OPTION_PRESET_STRATEGY_NAME,
];
}

View File

@ -7,7 +7,7 @@ use std::{
#[cfg(not(any(target_os = "ios")))]
use crate::Connection;
use hbb_common::{
config::{Config, LocalConfig},
config::{keys, Config, LocalConfig},
tokio::{self, sync::broadcast, time::Instant},
};
use serde::{Deserialize, Serialize};
@ -83,13 +83,21 @@ async fn start_hbbs_sync_async() {
v["version"] = json!(crate::VERSION);
v["id"] = json!(id);
v["uuid"] = json!(crate::encode64(hbb_common::get_uuid()));
let ab_name = Config::get_option("preset-address-book-name");
let ab_name = Config::get_option(keys::OPTION_PRESET_ADDRESS_BOOK_NAME);
if !ab_name.is_empty() {
v["preset-address-book-name"] = json!(ab_name);
v[keys::OPTION_PRESET_ADDRESS_BOOK_NAME] = json!(ab_name);
}
let ab_tag = Config::get_option("preset-address-book-tag");
let ab_tag = Config::get_option(keys::OPTION_PRESET_ADDRESS_BOOK_TAG);
if !ab_tag.is_empty() {
v["preset-address-book-tag"] = json!(ab_tag);
v[keys::OPTION_PRESET_ADDRESS_BOOK_TAG] = json!(ab_tag);
}
let username = Config::get_option(keys::OPTION_PRESET_USERNAME);
if !username.is_empty() {
v[keys::OPTION_PRESET_USERNAME] = json!(username);
}
let strategy_name = Config::get_option(keys::OPTION_PRESET_STRATEGY_NAME);
if !strategy_name.is_empty() {
v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name);
}
match crate::post_request(url.replace("heartbeat", "sysinfo"), v.to_string(), "").await {
Ok(x) => {