This commit is contained in:
Ferdinand Schober
2024-11-09 12:03:10 +01:00
parent ae58714681
commit 682a7b65bd
5 changed files with 25 additions and 26 deletions

10
Cargo.lock generated
View File

@@ -1852,7 +1852,6 @@ dependencies = [
"log", "log",
"rcgen", "rcgen",
"rustls", "rustls",
"rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
@@ -2651,15 +2650,6 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "rustls-pemfile"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
dependencies = [
"rustls-pki-types",
]
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.10.0" version = "1.10.0"

View File

@@ -61,7 +61,6 @@ rustls = { version = "0.23.12", default-features = false, features = [
"ring", "ring",
] } ] }
rcgen = "0.13.1" rcgen = "0.13.1"
rustls-pemfile = "2.1.3"
sha2 = "0.10.8" sha2 = "0.10.8"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]

View File

@@ -46,7 +46,6 @@ pub struct TomlClient {
impl ConfigToml { impl ConfigToml {
pub fn new(path: &Path) -> Result<ConfigToml, ConfigError> { pub fn new(path: &Path) -> Result<ConfigToml, ConfigError> {
let config = fs::read_to_string(path)?; let config = fs::read_to_string(path)?;
log::info!("using config: \"{path:?}\"");
Ok(toml::from_str::<_>(&config)?) Ok(toml::from_str::<_>(&config)?)
} }
} }
@@ -232,16 +231,29 @@ impl Default for Frontend {
#[derive(Debug)] #[derive(Debug)]
pub struct Config { pub struct Config {
/// the path to the configuration file used
pub path: PathBuf,
/// public key fingerprints authorized for connection
pub authorized_fingerprints: HashMap<String, String>, pub authorized_fingerprints: HashMap<String, String>,
/// optional input-capture backend override
pub capture_backend: Option<CaptureBackend>, pub capture_backend: Option<CaptureBackend>,
/// optional input-emulation backend override
pub emulation_backend: Option<EmulationBackend>, pub emulation_backend: Option<EmulationBackend>,
/// the frontend to use
pub frontend: Frontend, pub frontend: Frontend,
/// the port to use (initially)
pub port: u16, pub port: u16,
/// list of clients
pub clients: Vec<(TomlClient, Position)>, pub clients: Vec<(TomlClient, Position)>,
/// whether or not to run as a daemon
pub daemon: bool, pub daemon: bool,
/// configured release bind
pub release_bind: Vec<scancode::Linux>, pub release_bind: Vec<scancode::Linux>,
/// test capture instead of running the app
pub test_capture: bool, pub test_capture: bool,
/// test emulation instead of running the app
pub test_emulation: bool, pub test_emulation: bool,
/// path to the tls certificate to use
pub cert_path: PathBuf, pub cert_path: PathBuf,
} }
@@ -357,6 +369,7 @@ impl Config {
let test_emulation = args.test_emulation; let test_emulation = args.test_emulation;
Ok(Config { Ok(Config {
path: config_path,
authorized_fingerprints, authorized_fingerprints,
capture_backend, capture_backend,
emulation_backend, emulation_backend,

View File

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

View File

@@ -1,6 +0,0 @@
use input_capture::CaptureEvent;
struct PluginManager {
capture_hook: Vec<Box<dyn Fn(CaptureEvent)>>,
capture_transform: Vec<Box<dyn Fn(CaptureEvent) -> CaptureEvent>>,
}