mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-10 18:06:01 +02:00
refactor test_nat
This commit is contained in:
parent
61cdb60362
commit
d46862e47d
2 changed files with 11 additions and 17 deletions
|
@ -507,6 +507,16 @@ audio_rechannel!(audio_rechannel_8_7, 8, 7);
|
|||
pub fn test_nat_type() {
|
||||
let mut i = 0;
|
||||
std::thread::spawn(move || loop {
|
||||
if i == 0 {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
let is_direct = crate::ipc::get_socks().is_none(); // sync socks BTW
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
let is_direct = Config::get_socks().is_none(); // sync socks BTW
|
||||
if !is_direct {
|
||||
Config::set_nat_type(NatType::SYMMETRIC as _);
|
||||
break;
|
||||
}
|
||||
}
|
||||
match test_nat_type_() {
|
||||
Ok(true) => break,
|
||||
Err(err) => {
|
||||
|
@ -528,14 +538,6 @@ pub fn test_nat_type() {
|
|||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn test_nat_type_() -> ResultType<bool> {
|
||||
log::info!("Testing nat ...");
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
let is_direct = crate::ipc::get_socks_async(1_000).await.is_none(); // sync socks BTW
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
let is_direct = Config::get_socks().is_none(); // sync socks BTW
|
||||
if !is_direct {
|
||||
Config::set_nat_type(NatType::SYMMETRIC as _);
|
||||
return Ok(true);
|
||||
}
|
||||
let start = std::time::Instant::now();
|
||||
let (rendezvous_server, _, _) = get_rendezvous_server(1_000).await;
|
||||
let server1 = rendezvous_server;
|
||||
|
|
|
@ -65,13 +65,9 @@ impl RendezvousMediator {
|
|||
if crate::platform::is_installed() && !crate::is_custom_client() {
|
||||
crate::updater::start_auto_update();
|
||||
}
|
||||
let mut nat_tested = false;
|
||||
check_zombie();
|
||||
let server = new_server();
|
||||
if Config::get_nat_type() == NatType::UNKNOWN_NAT as i32 {
|
||||
crate::test_nat_type();
|
||||
nat_tested = true;
|
||||
}
|
||||
crate::test_nat_type();
|
||||
if config::option2bool("stop-service", &Config::get_option("stop-service")) {
|
||||
crate::test_rendezvous_server();
|
||||
}
|
||||
|
@ -100,10 +96,6 @@ impl RendezvousMediator {
|
|||
if !config::option2bool("stop-service", &Config::get_option("stop-service"))
|
||||
&& !crate::platform::installing_service()
|
||||
{
|
||||
if !nat_tested {
|
||||
crate::test_nat_type();
|
||||
nat_tested = true;
|
||||
}
|
||||
let mut futs = Vec::new();
|
||||
let servers = Config::get_rendezvous_servers();
|
||||
SHOULD_EXIT.store(false, Ordering::SeqCst);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue