From 4fe5d2cf026a657fad37c65901652af039c8578c Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 14 Jan 2022 23:21:30 +0800 Subject: [PATCH] no lan discovery if no install --- src/rendezvous_mediator.rs | 12 +++++++----- src/ui/ab.tis | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 5558ed9fe..5e1564536 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -59,9 +59,11 @@ impl RendezvousMediator { tokio::spawn(async move { allow_err!(direct_server(server_cloned).await); }); - std::thread::spawn(move || { - allow_err!(lan_discovery()); - }); + if crate::platform::is_installed() { + std::thread::spawn(move || { + allow_err!(lan_discovery()); + }); + } loop { Config::reset_online(); if Config::get_option("stop-service").is_empty() { @@ -519,7 +521,7 @@ pub fn get_mac() -> String { } fn lan_discovery() -> ResultType<()> { - let addr = SocketAddr::from(([0, 0, 0, 0], 3000)); + let addr = SocketAddr::from(([0, 0, 0, 0], get_broadcast_port())); let socket = std::net::UdpSocket::bind(addr)?; socket.set_read_timeout(Some(std::time::Duration::from_millis(1000)))?; log::info!("lan discovery listener started"); @@ -561,7 +563,7 @@ pub fn discover() -> ResultType<()> { ..Default::default() }; msg_out.set_peer_discovery(peer); - let maddr = SocketAddr::from(([255, 255, 255, 255], 3000)); + let maddr = SocketAddr::from(([255, 255, 255, 255], get_broadcast_port())); socket.send_to(&msg_out.write_to_bytes()?, maddr)?; log::info!("discover ping sent"); let mut last_recv_time = Instant::now(); diff --git a/src/ui/ab.tis b/src/ui/ab.tis index a740b6cbe..5365949e5 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -253,14 +253,14 @@ class MultipleSessions: Reactor.Component {
{translate('Recent Sessions')} {translate('Favorites')} - {translate('Discovered')} + {handler.is_installed() && {translate('Discovered')}}
{!this.hidden && } {!this.hidden && } {!this.hidden && ((type == "fav" && ) || - (type == "lan" && ) || + (type == "lan" && handler.is_installed() && ) || )} ; } @@ -309,7 +309,7 @@ function discover() { update(); } -if (getSessionsType() == "lan") { +if (getSessionsType() == "lan" && handler.is_installed()) { discover(); }