Encryption and One-Way-Control (#200)

This is a major rewrite of the core networking logic enabling one-way control and encryption through the webrtc-dtls crate.

closes #164 
closes #104
This commit is contained in:
Ferdinand Schober
2024-11-09 13:54:43 +01:00
committed by GitHub
parent 0d074e19f1
commit 7677fae14b
38 changed files with 4003 additions and 1374 deletions

View File

@@ -5,9 +5,9 @@ use lan_mouse::{
capture_test,
config::{Config, ConfigError, Frontend},
emulation_test,
server::{Server, ServiceError},
service::{Service, ServiceError},
};
use lan_mouse_ipc::IpcError;
use lan_mouse_ipc::{IpcError, IpcListenerCreationError};
use std::{
future::Future,
io,
@@ -32,7 +32,7 @@ enum LanMouseError {
Emulation(#[from] InputEmulationError),
}
pub fn main() {
fn main() {
// init logging
let env = Env::default().filter_or("LAN_MOUSE_LOG_LEVEL", "info");
env_logger::init_from_env(env);
@@ -46,16 +46,18 @@ pub fn main() {
fn run() -> Result<(), LanMouseError> {
// parse config file + cli args
let config = Config::new()?;
log::debug!("{config:?}");
log::info!("release bind: {:?}", config.release_bind);
if config.test_capture {
run_async(capture_test::run(config))?;
} else if config.test_emulation {
run_async(emulation_test::run(config))?;
} else if config.daemon {
// if daemon is specified we run the service
run_async(run_service(config))?;
match run_async(run_service(config)) {
Err(LanMouseError::Service(ServiceError::IpcListen(
IpcListenerCreationError::AlreadyRunning,
))) => log::info!("service already running!"),
r => r?,
}
} else {
// otherwise start the service as a child process and
// run a frontend
@@ -100,8 +102,10 @@ fn start_service() -> Result<Child, io::Error> {
}
async fn run_service(config: Config) -> Result<(), ServiceError> {
log::info!("using config: {:?}", config.path);
log::info!("Press {:?} to release the mouse", config.release_bind);
Server::new(config).run().await?;
let mut service = Service::new(config).await?;
service.run().await?;
log::info!("service exited!");
Ok(())
}