no lan discovery if no install
This commit is contained in:
parent
95239fc148
commit
4fe5d2cf02
@ -59,9 +59,11 @@ impl RendezvousMediator {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
allow_err!(direct_server(server_cloned).await);
|
allow_err!(direct_server(server_cloned).await);
|
||||||
});
|
});
|
||||||
std::thread::spawn(move || {
|
if crate::platform::is_installed() {
|
||||||
allow_err!(lan_discovery());
|
std::thread::spawn(move || {
|
||||||
});
|
allow_err!(lan_discovery());
|
||||||
|
});
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
Config::reset_online();
|
Config::reset_online();
|
||||||
if Config::get_option("stop-service").is_empty() {
|
if Config::get_option("stop-service").is_empty() {
|
||||||
@ -519,7 +521,7 @@ pub fn get_mac() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn lan_discovery() -> ResultType<()> {
|
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)?;
|
let socket = std::net::UdpSocket::bind(addr)?;
|
||||||
socket.set_read_timeout(Some(std::time::Duration::from_millis(1000)))?;
|
socket.set_read_timeout(Some(std::time::Duration::from_millis(1000)))?;
|
||||||
log::info!("lan discovery listener started");
|
log::info!("lan discovery listener started");
|
||||||
@ -561,7 +563,7 @@ pub fn discover() -> ResultType<()> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
msg_out.set_peer_discovery(peer);
|
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)?;
|
socket.send_to(&msg_out.write_to_bytes()?, maddr)?;
|
||||||
log::info!("discover ping sent");
|
log::info!("discover ping sent");
|
||||||
let mut last_recv_time = Instant::now();
|
let mut last_recv_time = Instant::now();
|
||||||
|
@ -253,14 +253,14 @@ class MultipleSessions: Reactor.Component {
|
|||||||
<div style="width:*" .sessions-tab #sessions-type>
|
<div style="width:*" .sessions-tab #sessions-type>
|
||||||
<span class={!type ? 'active' : 'inactive'}>{translate('Recent Sessions')}</span>
|
<span class={!type ? 'active' : 'inactive'}>{translate('Recent Sessions')}</span>
|
||||||
<span #fav class={type == "fav" ? 'active' : 'inactive'}>{translate('Favorites')}</span>
|
<span #fav class={type == "fav" ? 'active' : 'inactive'}>{translate('Favorites')}</span>
|
||||||
<span #lan class={type == "lan" ? 'active' : 'inactive'}>{translate('Discovered')}</span>
|
{handler.is_installed() && <span #lan class={type == "lan" ? 'active' : 'inactive'}>{translate('Discovered')}</span>}
|
||||||
</div>
|
</div>
|
||||||
{!this.hidden && <SearchBar type={type} />}
|
{!this.hidden && <SearchBar type={type} />}
|
||||||
{!this.hidden && <SessionStyle type={type} />}
|
{!this.hidden && <SessionStyle type={type} />}
|
||||||
</div>
|
</div>
|
||||||
{!this.hidden &&
|
{!this.hidden &&
|
||||||
((type == "fav" && <Favorites />) ||
|
((type == "fav" && <Favorites />) ||
|
||||||
(type == "lan" && <LanPeers />) ||
|
(type == "lan" && handler.is_installed() && <LanPeers />) ||
|
||||||
<SessionList sessions={handler.get_recent_sessions()} />)}
|
<SessionList sessions={handler.get_recent_sessions()} />)}
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ function discover() {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSessionsType() == "lan") {
|
if (getSessionsType() == "lan" && handler.is_installed()) {
|
||||||
discover();
|
discover();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user