mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-07 11:59:59 +03:00
cleanup
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -1852,7 +1852,6 @@ dependencies = [
|
||||
"log",
|
||||
"rcgen",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
@@ -2651,15 +2650,6 @@ dependencies = [
|
||||
"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]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.10.0"
|
||||
|
||||
@@ -61,7 +61,6 @@ rustls = { version = "0.23.12", default-features = false, features = [
|
||||
"ring",
|
||||
] }
|
||||
rcgen = "0.13.1"
|
||||
rustls-pemfile = "2.1.3"
|
||||
sha2 = "0.10.8"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
||||
@@ -46,7 +46,6 @@ pub struct TomlClient {
|
||||
impl ConfigToml {
|
||||
pub fn new(path: &Path) -> Result<ConfigToml, ConfigError> {
|
||||
let config = fs::read_to_string(path)?;
|
||||
log::info!("using config: \"{path:?}\"");
|
||||
Ok(toml::from_str::<_>(&config)?)
|
||||
}
|
||||
}
|
||||
@@ -232,16 +231,29 @@ impl Default for Frontend {
|
||||
|
||||
#[derive(Debug)]
|
||||
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>,
|
||||
/// optional input-capture backend override
|
||||
pub capture_backend: Option<CaptureBackend>,
|
||||
/// optional input-emulation backend override
|
||||
pub emulation_backend: Option<EmulationBackend>,
|
||||
/// the frontend to use
|
||||
pub frontend: Frontend,
|
||||
/// the port to use (initially)
|
||||
pub port: u16,
|
||||
/// list of clients
|
||||
pub clients: Vec<(TomlClient, Position)>,
|
||||
/// whether or not to run as a daemon
|
||||
pub daemon: bool,
|
||||
/// configured release bind
|
||||
pub release_bind: Vec<scancode::Linux>,
|
||||
/// test capture instead of running the app
|
||||
pub test_capture: bool,
|
||||
/// test emulation instead of running the app
|
||||
pub test_emulation: bool,
|
||||
/// path to the tls certificate to use
|
||||
pub cert_path: PathBuf,
|
||||
}
|
||||
|
||||
@@ -357,6 +369,7 @@ impl Config {
|
||||
let test_emulation = args.test_emulation;
|
||||
|
||||
Ok(Config {
|
||||
path: config_path,
|
||||
authorized_fingerprints,
|
||||
capture_backend,
|
||||
emulation_backend,
|
||||
|
||||
19
src/main.rs
19
src/main.rs
@@ -7,7 +7,7 @@ use lan_mouse::{
|
||||
emulation_test,
|
||||
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,9 +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);
|
||||
let mut server = Service::new(config).await?;
|
||||
server.run().await?;
|
||||
let mut service = Service::new(config).await?;
|
||||
service.run().await?;
|
||||
log::info!("service exited!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -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>>,
|
||||
}
|
||||
Reference in New Issue
Block a user