mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix: android build & CONFIG deadlock
This commit is contained in:
@@ -584,6 +584,17 @@ impl Config {
|
||||
config.store();
|
||||
}
|
||||
|
||||
pub fn get_sk_uuid() -> Vec<u8> {
|
||||
// for uuid, avoid deadlock
|
||||
let mut config = Config::load_::<Config>("");
|
||||
if config.key_pair.0.is_empty() {
|
||||
let (pk, sk) = sign::gen_keypair();
|
||||
config.key_pair = (sk.0.to_vec(), pk.0.into());
|
||||
Config::store_(&config, "");
|
||||
}
|
||||
config.key_pair.1
|
||||
}
|
||||
|
||||
pub fn get_key_pair() -> (Vec<u8>, Vec<u8>) {
|
||||
// lock here to make sure no gen_keypair more than once
|
||||
let mut config = CONFIG.write().unwrap();
|
||||
|
||||
@@ -39,6 +39,10 @@ pub use tokio_socks::IntoTargetAddr;
|
||||
pub use tokio_socks::TargetAddr;
|
||||
pub mod password_security;
|
||||
|
||||
lazy_static::lazy_static!{
|
||||
static ref UUID: Vec<u8> = gen_uuid();
|
||||
}
|
||||
|
||||
#[cfg(feature = "quic")]
|
||||
pub type Stream = quic::Connection;
|
||||
#[cfg(not(feature = "quic"))]
|
||||
@@ -202,12 +206,16 @@ pub fn get_modified_time(path: &std::path::Path) -> SystemTime {
|
||||
.unwrap_or(UNIX_EPOCH)
|
||||
}
|
||||
|
||||
pub fn get_uuid() -> Vec<u8> {
|
||||
fn gen_uuid() -> Vec<u8> {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Ok(id) = machine_uid::get() {
|
||||
return id.into();
|
||||
}
|
||||
Config::get_key_pair().1
|
||||
Config::get_sk_uuid()
|
||||
}
|
||||
|
||||
pub fn get_uuid() -> Vec<u8> {
|
||||
UUID.to_owned()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user