remove unnessarey dns call

This commit is contained in:
rustdesk 2021-05-23 00:14:00 +08:00
parent b7ab1405ee
commit bdfb59dd1a
3 changed files with 12 additions and 4 deletions

View File

@ -154,6 +154,7 @@ pub fn test_nat_type() {
#[tokio::main(basic_scheduler)]
async fn test_nat_type_() -> ResultType<bool> {
log::info!("Testing nat ...");
let start = std::time::Instant::now();
let rendezvous_server = get_rendezvous_server(100).await;
let server1 = rendezvous_server;
@ -206,7 +207,7 @@ async fn test_nat_type_() -> ResultType<bool> {
NatType::SYMMETRIC
};
Config::set_nat_type(t as _);
log::info!("tested nat type: {:?} in {:?}", t, start.elapsed());
log::info!("Tested nat type: {:?} in {:?}", t, start.elapsed());
}
Ok(ok)
}
@ -235,6 +236,7 @@ pub async fn get_nat_type(ms_timeout: u64) -> i32 {
#[tokio::main(basic_scheduler)]
async fn test_rendezvous_server_() {
let servers = Config::get_rendezvous_servers();
hbb_common::config::ONLINE.lock().unwrap().clear();
let mut futs = Vec::new();
for host in servers {
futs.push(tokio::spawn(async move {

View File

@ -93,9 +93,6 @@ pub enum Data {
#[tokio::main(basic_scheduler)]
pub async fn start(postfix: &str) -> ResultType<()> {
if postfix.is_empty() {
crate::common::test_nat_type();
}
let mut incoming = new_listener(postfix).await?;
loop {
if let Some(result) = incoming.next().await {

View File

@ -39,11 +39,20 @@ pub struct RendezvousMediator {
impl RendezvousMediator {
pub async fn start_all() {
let mut nat_tested = false;
check_zombie();
let server = new_server();
if Config::get_nat_type() == NatType::UNKNOWN_NAT as i32 {
crate::common::test_nat_type();
nat_tested = true;
}
loop {
Config::reset_online();
if Config::get_option("stop-service").is_empty() {
if !nat_tested {
crate::common::test_nat_type();
nat_tested = true;
}
let mut futs = Vec::new();
let servers = Config::get_rendezvous_servers();
for host in servers.clone() {