mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-29 08:00:55 +03:00
cleanup
This commit is contained in:
@@ -97,14 +97,14 @@ impl Server {
|
||||
}
|
||||
};
|
||||
|
||||
let timer_notify = Arc::new(Notify::new()); /* notify ping timer restart */
|
||||
let notify_ping = Arc::new(Notify::new()); /* notify ping timer restart */
|
||||
let (frontend_tx, frontend_rx) = channel(1); /* events coming from frontends */
|
||||
let cancellation_token = CancellationToken::new(); /* notify termination */
|
||||
let notify_capture = Arc::new(Notify::new()); /* notify capture restart */
|
||||
let notify_emulation = Arc::new(Notify::new()); /* notify emultation restart */
|
||||
|
||||
// udp task
|
||||
let (mut udp_task, udp_send, udp_recv, port_tx) = network_task::new(
|
||||
let (mut network, udp_send, udp_recv, port_tx) = network_task::new(
|
||||
self.clone(),
|
||||
frontend_tx.clone(),
|
||||
cancellation_token.clone(),
|
||||
@@ -112,33 +112,33 @@ impl Server {
|
||||
.await?;
|
||||
|
||||
// input capture
|
||||
let (mut capture_task, capture_channel) = capture_task::new(
|
||||
let (mut capture, capture_channel) = capture_task::new(
|
||||
capture_backend,
|
||||
self.clone(),
|
||||
udp_send.clone(),
|
||||
frontend_tx.clone(),
|
||||
timer_notify.clone(),
|
||||
notify_ping.clone(),
|
||||
self.release_bind.clone(),
|
||||
cancellation_token.clone(),
|
||||
notify_capture.clone(),
|
||||
);
|
||||
|
||||
// input emulation
|
||||
let (mut emulation_task, emulate_channel) = emulation_task::new(
|
||||
let (mut emulation, emulate_channel) = emulation_task::new(
|
||||
emulation_backend,
|
||||
self.clone(),
|
||||
udp_recv,
|
||||
udp_send.clone(),
|
||||
capture_channel.clone(),
|
||||
frontend_tx.clone(),
|
||||
timer_notify.clone(),
|
||||
notify_ping.clone(),
|
||||
cancellation_token.clone(),
|
||||
notify_emulation.clone(),
|
||||
);
|
||||
|
||||
// create dns resolver
|
||||
let resolver = dns::DnsResolver::new().await?;
|
||||
let (mut resolver_task, dns_req) = resolver_task::new(
|
||||
let (mut resolver, dns_req) = resolver_task::new(
|
||||
resolver,
|
||||
self.clone(),
|
||||
frontend_tx,
|
||||
@@ -146,7 +146,7 @@ impl Server {
|
||||
);
|
||||
|
||||
// frontend listener
|
||||
let (mut frontend_task, frontend_tx) = frontend_task::new(
|
||||
let (mut frontend, frontend_tx) = frontend_task::new(
|
||||
frontend,
|
||||
frontend_rx,
|
||||
self.clone(),
|
||||
@@ -160,12 +160,12 @@ impl Server {
|
||||
);
|
||||
|
||||
// task that pings clients to see if they are responding
|
||||
let mut ping_task = ping_task::new(
|
||||
let mut ping = ping_task::new(
|
||||
self.clone(),
|
||||
udp_send.clone(),
|
||||
emulate_channel.clone(),
|
||||
capture_channel.clone(),
|
||||
timer_notify,
|
||||
notify_ping,
|
||||
cancellation_token.clone(),
|
||||
);
|
||||
|
||||
@@ -195,26 +195,16 @@ impl Server {
|
||||
_ = signal::ctrl_c() => {
|
||||
log::info!("terminating service");
|
||||
}
|
||||
_ = &mut capture_task => { }
|
||||
_ = &mut emulation_task => { }
|
||||
_ = &mut frontend_task => { }
|
||||
_ = &mut resolver_task => { }
|
||||
_ = &mut udp_task => { }
|
||||
_ = &mut ping_task => { }
|
||||
_ = &mut capture => { }
|
||||
_ = &mut emulation => { }
|
||||
_ = &mut frontend => { }
|
||||
_ = &mut resolver => { }
|
||||
_ = &mut network => { }
|
||||
_ = &mut ping => { }
|
||||
}
|
||||
|
||||
// cancel tasks
|
||||
cancellation_token.cancel();
|
||||
|
||||
let _ = join!(
|
||||
capture_task,
|
||||
emulation_task,
|
||||
frontend_task,
|
||||
udp_task,
|
||||
resolver_task
|
||||
);
|
||||
|
||||
ping_task.abort();
|
||||
let _ = join!(capture, emulation, frontend, network, resolver, ping);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user