mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-18 11:01:29 +03:00
reduce visibility of functions
This commit is contained in:
@@ -38,28 +38,19 @@ pub enum ServiceError {
|
|||||||
Certificate(#[from] crypto::Error),
|
Certificate(#[from] crypto::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ReleaseToken;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Incoming {
|
|
||||||
fingerprint: String,
|
|
||||||
addr: SocketAddr,
|
|
||||||
pos: Position,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
capture: Capture,
|
capture: Capture,
|
||||||
emulation: Emulation,
|
emulation: Emulation,
|
||||||
resolver: DnsResolver,
|
resolver: DnsResolver,
|
||||||
frontend_listener: AsyncFrontendListener,
|
frontend_listener: AsyncFrontendListener,
|
||||||
authorized_keys: Arc<RwLock<HashMap<String, String>>>,
|
authorized_keys: Arc<RwLock<HashMap<String, String>>>,
|
||||||
pub(crate) client_manager: ClientManager,
|
client_manager: ClientManager,
|
||||||
port: u16,
|
port: u16,
|
||||||
public_key_fingerprint: String,
|
public_key_fingerprint: String,
|
||||||
frontend_event_pending: Notify,
|
frontend_event_pending: Notify,
|
||||||
pending_frontend_events: VecDeque<FrontendEvent>,
|
pending_frontend_events: VecDeque<FrontendEvent>,
|
||||||
capture_status: Status,
|
capture_status: Status,
|
||||||
pub(crate) emulation_status: Status,
|
emulation_status: Status,
|
||||||
/// keep track of registered connections to avoid duplicate barriers
|
/// keep track of registered connections to avoid duplicate barriers
|
||||||
incoming_conns: HashSet<SocketAddr>,
|
incoming_conns: HashSet<SocketAddr>,
|
||||||
/// map from capture handle to connection info
|
/// map from capture handle to connection info
|
||||||
@@ -67,6 +58,13 @@ pub struct Service {
|
|||||||
next_trigger_handle: u64,
|
next_trigger_handle: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Incoming {
|
||||||
|
fingerprint: String,
|
||||||
|
addr: SocketAddr,
|
||||||
|
pos: Position,
|
||||||
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
pub async fn new(config: Config) -> Result<Self, ServiceError> {
|
pub async fn new(config: Config) -> Result<Self, ServiceError> {
|
||||||
let client_manager = ClientManager::default();
|
let client_manager = ClientManager::default();
|
||||||
@@ -264,11 +262,11 @@ impl Service {
|
|||||||
}
|
}
|
||||||
EmulationEvent::EmulationDisabled => {
|
EmulationEvent::EmulationDisabled => {
|
||||||
self.emulation_status = Status::Disabled;
|
self.emulation_status = Status::Disabled;
|
||||||
self.notify_frontend(FrontendEvent::EmulationStatus(Status::Disabled));
|
self.notify_frontend(FrontendEvent::EmulationStatus(self.emulation_status));
|
||||||
},
|
},
|
||||||
EmulationEvent::EmulationEnabled => {
|
EmulationEvent::EmulationEnabled => {
|
||||||
self.emulation_status = Status::Enabled;
|
self.emulation_status = Status::Enabled;
|
||||||
self.notify_frontend(FrontendEvent::EmulationStatus(Status::Enabled));
|
self.notify_frontend(FrontendEvent::EmulationStatus(self.emulation_status));
|
||||||
},
|
},
|
||||||
EmulationEvent::ReleaseNotify => self.capture.release(),
|
EmulationEvent::ReleaseNotify => self.capture.release(),
|
||||||
},
|
},
|
||||||
@@ -282,15 +280,15 @@ impl Service {
|
|||||||
}
|
}
|
||||||
ICaptureEvent::CaptureDisabled => {
|
ICaptureEvent::CaptureDisabled => {
|
||||||
self.capture_status = Status::Disabled;
|
self.capture_status = Status::Disabled;
|
||||||
self.notify_frontend(FrontendEvent::CaptureStatus(Status::Disabled));
|
self.notify_frontend(FrontendEvent::CaptureStatus(self.capture_status));
|
||||||
}
|
}
|
||||||
ICaptureEvent::CaptureEnabled => {
|
ICaptureEvent::CaptureEnabled => {
|
||||||
self.capture_status = Status::Enabled;
|
self.capture_status = Status::Enabled;
|
||||||
self.notify_frontend(FrontendEvent::CaptureStatus(Status::Enabled));
|
self.notify_frontend(FrontendEvent::CaptureStatus(self.capture_status));
|
||||||
}
|
}
|
||||||
ICaptureEvent::ClientEntered(handle) => {
|
ICaptureEvent::ClientEntered(handle) => {
|
||||||
log::info!("entering client {handle} ...");
|
log::info!("entering client {handle} ...");
|
||||||
self.spawn_hook_command(handle)
|
self.spawn_hook_command(handle);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
event = self.resolver.event() => match event {
|
event = self.resolver.event() => match event {
|
||||||
@@ -359,7 +357,7 @@ impl Service {
|
|||||||
self.frontend_event_pending.notify_one();
|
self.frontend_event_pending.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn client_updated(&mut self, handle: ClientHandle) {
|
fn client_updated(&mut self, handle: ClientHandle) {
|
||||||
self.notify_frontend(FrontendEvent::Changed(handle));
|
self.notify_frontend(FrontendEvent::Changed(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +432,7 @@ impl Service {
|
|||||||
self.client_updated(handle);
|
self.client_updated(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn update_dns_ips(&mut self, handle: ClientHandle, dns_ips: Vec<IpAddr>) {
|
fn update_dns_ips(&mut self, handle: ClientHandle, dns_ips: Vec<IpAddr>) {
|
||||||
self.client_manager.set_dns_ips(handle, dns_ips);
|
self.client_manager.set_dns_ips(handle, dns_ips);
|
||||||
self.client_updated(handle);
|
self.client_updated(handle);
|
||||||
}
|
}
|
||||||
@@ -469,7 +467,7 @@ impl Service {
|
|||||||
self.notify_frontend(event);
|
self.notify_frontend(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_resolving(&mut self, handle: ClientHandle, status: bool) {
|
fn set_resolving(&mut self, handle: ClientHandle, status: bool) {
|
||||||
self.client_manager.set_resolving(handle, status);
|
self.client_manager.set_resolving(handle, status);
|
||||||
self.client_updated(handle);
|
self.client_updated(handle);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user