mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
more on custom client
This commit is contained in:
@@ -1477,6 +1477,11 @@ impl ClipboardContext {
|
||||
}
|
||||
|
||||
pub fn load_custom_client() {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Ok(data) = std::fs::read_to_string("./custom.txt") {
|
||||
read_custom_client(data.trim());
|
||||
return;
|
||||
}
|
||||
let Ok(cmd) = std::env::current_exe() else {
|
||||
return;
|
||||
};
|
||||
@@ -1488,7 +1493,7 @@ pub fn load_custom_client() {
|
||||
log::error!("Failed to read custom client config");
|
||||
return;
|
||||
};
|
||||
read_custom_client(&data);
|
||||
read_custom_client(&data.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1512,7 +1517,13 @@ pub fn read_custom_client(config: &str) {
|
||||
log::error!("Failed to parse custom client config");
|
||||
return;
|
||||
};
|
||||
if let Some(default_settings) = data.remove("default_settings") {
|
||||
|
||||
if let Some(app_name) = data.remove("app-name") {
|
||||
if let Some(app_name) = app_name.as_str() {
|
||||
*config::APP_NAME.write().unwrap() = app_name.to_owned();
|
||||
}
|
||||
}
|
||||
if let Some(default_settings) = data.remove("default-settings") {
|
||||
if let Some(default_settings) = default_settings.as_object() {
|
||||
for (k, v) in default_settings {
|
||||
let Some(v) = v.as_str() else {
|
||||
@@ -1537,7 +1548,7 @@ pub fn read_custom_client(config: &str) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(overwrite_settings) = data.remove("overwrite_settings") {
|
||||
if let Some(overwrite_settings) = data.remove("override-settings") {
|
||||
if let Some(overwrite_settings) = overwrite_settings.as_object() {
|
||||
for (k, v) in overwrite_settings {
|
||||
let Some(v) = v.as_str() else {
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::client::translate;
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::platform::breakdown_callback;
|
||||
use hbb_common::log;
|
||||
use hbb_common::{config, log};
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::platform::register_breakdown_handler;
|
||||
@@ -63,7 +63,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
]
|
||||
.contains(&arg.as_str())
|
||||
{
|
||||
if crate::flutter_ffi::is_qs().0 {
|
||||
if config::is_incoming_only() {
|
||||
return None;
|
||||
} else {
|
||||
_is_flutter_invoke_new_connection = true;
|
||||
@@ -96,7 +96,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "1");
|
||||
if !hbb_common::config::Config::get_option("allow-always-software-render").is_empty() {
|
||||
if !config::Config::get_option("allow-always-software-render").is_empty() {
|
||||
std::env::set_var(k, v);
|
||||
} else {
|
||||
std::env::remove_var(k);
|
||||
@@ -111,7 +111,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
return core_main_invoke_new_connection(std::env::args());
|
||||
}
|
||||
let click_setup = cfg!(windows) && args.is_empty() && crate::common::is_setup(&arg_exe);
|
||||
if click_setup {
|
||||
if click_setup && !config::is_disable_installation(){
|
||||
args.push("--install".to_owned());
|
||||
flutter_args.push("--install".to_string());
|
||||
}
|
||||
@@ -188,6 +188,9 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
return None;
|
||||
} else if args[0] == "--silent-install" {
|
||||
if config::is_disable_installation() {
|
||||
return None;
|
||||
}
|
||||
let res = platform::install_me(
|
||||
"desktopicon startmenu",
|
||||
"".to_owned(),
|
||||
@@ -202,7 +205,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
};
|
||||
Toast::new(Toast::POWERSHELL_APP_ID)
|
||||
.title(&hbb_common::config::APP_NAME.read().unwrap())
|
||||
.title(&config::APP_NAME.read().unwrap())
|
||||
.text1(&text)
|
||||
.sound(Some(Sound::Default))
|
||||
.duration(Duration::Short)
|
||||
|
||||
@@ -42,6 +42,8 @@ lazy_static::lazy_static! {
|
||||
fn initialize(app_dir: &str) {
|
||||
flutter::async_tasks::start_flutter_async_runner();
|
||||
*config::APP_DIR.write().unwrap() = app_dir.to_owned();
|
||||
// core_main's load_custom_client does not work for flutter since it is only applied to its load_library in main.c
|
||||
crate::load_custom_client();
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
// flexi_logger can't work when android_logger initialized.
|
||||
@@ -62,7 +64,12 @@ fn initialize(app_dir: &str) {
|
||||
#[cfg(target_os = "ios")]
|
||||
{
|
||||
use hbb_common::env_logger::*;
|
||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));
|
||||
init_fro_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
// core_main's init_log does not work for flutter since it is only applied to its load_library in main.c
|
||||
hbb_common::init_log(false, "flutter_ffi");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1813,8 +1820,29 @@ pub fn main_support_remove_wallpaper() -> bool {
|
||||
support_remove_wallpaper()
|
||||
}
|
||||
|
||||
pub fn is_qs() -> SyncReturn<bool> {
|
||||
SyncReturn(get_hard_option("connection-type".to_owned()) == "incoming")
|
||||
pub fn is_incoming_only() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_incoming_only())
|
||||
}
|
||||
|
||||
pub fn is_outgoing_only() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_outgoing_only())
|
||||
}
|
||||
|
||||
pub fn is_disable_settings() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_disable_settings())
|
||||
}
|
||||
|
||||
pub fn is_disable_ab() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_disable_ab())
|
||||
}
|
||||
|
||||
pub fn is_disable_account() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_disable_account())
|
||||
}
|
||||
|
||||
// windows only
|
||||
pub fn is_disable_installation() -> SyncReturn<bool> {
|
||||
SyncReturn(config::is_disable_installation())
|
||||
}
|
||||
|
||||
/// Send a url scheme throught the ipc.
|
||||
|
||||
@@ -1205,6 +1205,15 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
|
||||
Config::set_option("api-server".into(), lic.api);
|
||||
}
|
||||
|
||||
let tray_shortcuts = if config::is_outgoing_only() {
|
||||
"".to_owned()
|
||||
} else {
|
||||
format!("
|
||||
cscript \"{tray_shortcut}\"
|
||||
copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\\"
|
||||
")
|
||||
};
|
||||
|
||||
let cmds = format!(
|
||||
"
|
||||
{uninstall_str}
|
||||
@@ -1227,8 +1236,7 @@ reg add {subkey} /f /v EstimatedSize /t REG_DWORD /d {size}
|
||||
reg add {subkey} /f /v WindowsInstaller /t REG_DWORD /d 0
|
||||
cscript \"{mk_shortcut}\"
|
||||
cscript \"{uninstall_shortcut}\"
|
||||
cscript \"{tray_shortcut}\"
|
||||
copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\\"
|
||||
{tray_shortcuts}
|
||||
{shortcuts}
|
||||
copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
||||
{dels}
|
||||
@@ -1237,19 +1245,11 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
||||
{after_install}
|
||||
{sleep}
|
||||
",
|
||||
version=crate::VERSION,
|
||||
build_date=crate::BUILD_DATE,
|
||||
after_install=get_after_install(&exe),
|
||||
sleep=if debug {
|
||||
"timeout 300"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
dels=if debug {
|
||||
""
|
||||
} else {
|
||||
&dels
|
||||
},
|
||||
version = crate::VERSION,
|
||||
build_date = crate::BUILD_DATE,
|
||||
after_install = get_after_install(&exe),
|
||||
sleep = if debug { "timeout 300" } else { "" },
|
||||
dels = if debug { "" } else { &dels },
|
||||
copy_exe = copy_exe_cmd(&src_exe, &exe, &path)?,
|
||||
import_config = get_import_config(&exe),
|
||||
);
|
||||
@@ -2383,6 +2383,9 @@ oLink.Save
|
||||
}
|
||||
|
||||
fn get_import_config(exe: &str) -> String {
|
||||
if config::is_outgoing_only() {
|
||||
return "".to_string();
|
||||
}
|
||||
format!("
|
||||
sc stop {app_name}
|
||||
sc delete {app_name}
|
||||
@@ -2397,6 +2400,9 @@ sc delete {app_name}
|
||||
}
|
||||
|
||||
fn get_create_service(exe: &str) -> String {
|
||||
if config::is_outgoing_only() {
|
||||
return "".to_string();
|
||||
}
|
||||
let stop = Config::get_option("stop-service") == "Y";
|
||||
if stop {
|
||||
format!("
|
||||
|
||||
@@ -12,7 +12,7 @@ use uuid::Uuid;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::{self, bail},
|
||||
config::{Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
|
||||
config::{self, Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
|
||||
futures::future::join_all,
|
||||
log,
|
||||
protobuf::Message as _,
|
||||
@@ -61,6 +61,11 @@ impl RendezvousMediator {
|
||||
}
|
||||
|
||||
pub async fn start_all() {
|
||||
if config::is_outgoing_only() {
|
||||
loop {
|
||||
sleep(1.).await;
|
||||
}
|
||||
}
|
||||
crate::hbbs_http::sync::start();
|
||||
let mut nat_tested = false;
|
||||
check_zombie();
|
||||
@@ -449,7 +454,7 @@ impl RendezvousMediator {
|
||||
|
||||
async fn handle_intranet(&self, fla: FetchLocalAddr, server: ServerPtr) -> ResultType<()> {
|
||||
let relay_server = self.get_relay_server(fla.relay_server);
|
||||
if !is_ipv4(&self.addr) {
|
||||
if !is_ipv4(&self.addr) || config::is_disable_tcp_listen() {
|
||||
// nat64, go relay directly, because current hbbs will crash if demangle ipv6 address
|
||||
let uuid = Uuid::new_v4().to_string();
|
||||
return self
|
||||
@@ -488,6 +493,7 @@ impl RendezvousMediator {
|
||||
let relay_server = self.get_relay_server(ph.relay_server);
|
||||
if ph.nat_type.enum_value() == Ok(NatType::SYMMETRIC)
|
||||
|| Config::get_nat_type() == NatType::SYMMETRIC as i32
|
||||
|| config::is_disable_tcp_listen()
|
||||
{
|
||||
let uuid = Uuid::new_v4().to_string();
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user