mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'rustdesk/master'
This commit is contained in:
@@ -148,6 +148,15 @@ message PeerDiscovery {
|
||||
string misc = 7;
|
||||
}
|
||||
|
||||
message OnlineRequest {
|
||||
string id = 1;
|
||||
repeated string peers = 2;
|
||||
}
|
||||
|
||||
message OnlineResponse {
|
||||
bytes states = 1;
|
||||
}
|
||||
|
||||
message RendezvousMessage {
|
||||
oneof union {
|
||||
RegisterPeer register_peer = 6;
|
||||
@@ -167,5 +176,7 @@ message RendezvousMessage {
|
||||
TestNatRequest test_nat_request = 20;
|
||||
TestNatResponse test_nat_response = 21;
|
||||
PeerDiscovery peer_discovery = 22;
|
||||
OnlineRequest online_request = 23;
|
||||
OnlineResponse online_response = 24;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
use crate::{
|
||||
log,
|
||||
password_security::{
|
||||
decrypt_str_or_original, decrypt_vec_or_original, encrypt_str_or_original,
|
||||
encrypt_vec_or_original,
|
||||
},
|
||||
};
|
||||
use anyhow::Result;
|
||||
use directories_next::ProjectDirs;
|
||||
use rand::Rng;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sodiumoxide::crypto::sign;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs,
|
||||
@@ -19,8 +7,23 @@ use std::{
|
||||
time::SystemTime,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use directories_next::ProjectDirs;
|
||||
use rand::Rng;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sodiumoxide::crypto::sign;
|
||||
|
||||
use crate::{
|
||||
log,
|
||||
password_security::{
|
||||
decrypt_str_or_original, decrypt_vec_or_original, encrypt_str_or_original,
|
||||
encrypt_vec_or_original,
|
||||
},
|
||||
};
|
||||
|
||||
pub const RENDEZVOUS_TIMEOUT: u64 = 12_000;
|
||||
pub const CONNECT_TIMEOUT: u64 = 18_000;
|
||||
pub const READ_TIMEOUT: u64 = 30_000;
|
||||
pub const REG_INTERVAL: i64 = 12_000;
|
||||
pub const COMPRESS_LEVEL: i32 = 3;
|
||||
const SERIAL: i32 = 3;
|
||||
@@ -48,16 +51,10 @@ lazy_static::lazy_static! {
|
||||
pub static ref APP_NAME: Arc<RwLock<String>> = Arc::new(RwLock::new("RustDesk".to_owned()));
|
||||
static ref KEY_PAIR: Arc<Mutex<Option<(Vec<u8>, Vec<u8>)>>> = Default::default();
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref APP_DIR: Arc<RwLock<String>> = Arc::new(RwLock::new("/data/user/0/com.carriez.flutter_hbb/app_flutter".to_owned()));
|
||||
}
|
||||
#[cfg(target_os = "ios")]
|
||||
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref APP_DIR: Arc<RwLock<String>> = Default::default();
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref APP_HOME_DIR: Arc<RwLock<String>> = Default::default();
|
||||
}
|
||||
const CHARS: &'static [char] = &[
|
||||
|
||||
@@ -3,9 +3,8 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
fn find_package(name: &str) -> Vec<PathBuf> {
|
||||
let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap();
|
||||
let mut path: PathBuf = vcpkg_root.into();
|
||||
/// Link vcppkg package.
|
||||
fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf {
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if target_arch == "x86_64" {
|
||||
@@ -26,8 +25,13 @@ fn find_package(name: &str) -> Vec<PathBuf> {
|
||||
println!("cargo:info={}", target);
|
||||
path.push("installed");
|
||||
path.push(target);
|
||||
let lib = name.trim_start_matches("lib").to_string();
|
||||
println!("{}", format!("cargo:rustc-link-lib=static={}", lib));
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
"cargo:rustc-link-lib=static={}",
|
||||
name.trim_start_matches("lib")
|
||||
)
|
||||
);
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
@@ -37,7 +41,68 @@ fn find_package(name: &str) -> Vec<PathBuf> {
|
||||
);
|
||||
let include = path.join("include");
|
||||
println!("{}", format!("cargo:include={}", include.to_str().unwrap()));
|
||||
vec![include]
|
||||
include
|
||||
}
|
||||
|
||||
/// Link homebrew package(for Mac M1).
|
||||
fn link_homebrew_m1(name: &str) -> PathBuf {
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if target_os != "macos" || target_arch != "aarch64" {
|
||||
panic!("Couldn't find VCPKG_ROOT, also can't fallback to homebrew because it's only for macos aarch64.");
|
||||
}
|
||||
let mut path = PathBuf::from("/opt/homebrew/Cellar");
|
||||
path.push(name);
|
||||
let entries = if let Ok(dir) = std::fs::read_dir(&path) {
|
||||
dir
|
||||
} else {
|
||||
panic!("Could not find package in {}. Make sure your homebrew and package {} are all installed.", path.to_str().unwrap(),&name);
|
||||
};
|
||||
let mut directories = entries
|
||||
.into_iter()
|
||||
.filter(|x| x.is_ok())
|
||||
.map(|x| x.unwrap().path())
|
||||
.filter(|x| x.is_dir())
|
||||
.collect::<Vec<_>>();
|
||||
// Find the newest version.
|
||||
directories.sort_unstable();
|
||||
if directories.is_empty() {
|
||||
panic!(
|
||||
"There's no installed version of {} in /opt/homebrew/Cellar",
|
||||
name
|
||||
);
|
||||
}
|
||||
path.push(directories.pop().unwrap());
|
||||
// Link the library.
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
"cargo:rustc-link-lib=static={}",
|
||||
name.trim_start_matches("lib")
|
||||
)
|
||||
);
|
||||
// Add the library path.
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
"cargo:rustc-link-search={}",
|
||||
path.join("lib").to_str().unwrap()
|
||||
)
|
||||
);
|
||||
// Add the include path.
|
||||
let include = path.join("include");
|
||||
println!("{}", format!("cargo:include={}", include.to_str().unwrap()));
|
||||
include
|
||||
}
|
||||
|
||||
/// Find package. By default, it will try to find vcpkg first, then homebrew(currently only for Mac M1).
|
||||
fn find_package(name: &str) -> Vec<PathBuf> {
|
||||
if let Ok(vcpkg_root) = std::env::var("VCPKG_ROOT") {
|
||||
vec![link_vcpkg(vcpkg_root.into(), name)]
|
||||
} else {
|
||||
// Try using homebrew
|
||||
vec![link_homebrew_m1(name)]
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_bindings(
|
||||
|
||||
Reference in New Issue
Block a user