diff --git a/Cargo.toml b/Cargo.toml index 92a5771..a07d21b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,10 +55,13 @@ axum = { version = "0.8.9", features = ["macros", "tokio"] } hyper = "1.11.0" hyper-reverse-proxy = { git = "https://code.betamike.com/micropelago/hyper-reverse-proxy.git", rev = "d5a6f799189360d9449ae47ab3cdde511f02cf39", version = "0.5.2-dev" } hyper-util = "0.1.20" -ksni = "0.3.6" [target.'cfg(target_os = "linux")'.dependencies] ksni = { version = "0.3.6", optional = true } +[features] +default = ["tray"] +tray = ["dep:ksni"] + [profile.release] lto = true diff --git a/src/main.rs b/src/main.rs index 9a578cf..12f4fdf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,6 +45,7 @@ mod proxy; mod script; mod service; mod sources; +#[cfg(feature = "tray")] mod tray; static FORWARD_ENV: &[&str] = &[ diff --git a/src/proxy.rs b/src/proxy.rs index c85d53c..aebcc3b 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -166,11 +166,13 @@ pub async fn proxy(docker: Docker, config: HazeConfig) -> Result<()> { let docker = Arc::new(docker); let shutdown = Arc::new(Notify::new()); + #[cfg(feature = "tray")] let tray = crate::tray::spawn_tray(docker.clone(), config.clone(), shutdown.clone()).await; let instances = ActiveInstances::new(docker, config); let result = serve(instances, listen, base_address, acceptor, shutdown).await; + #[cfg(feature = "tray")] if let Some(tray) = tray { tray.shutdown().await; } diff --git a/src/service.rs b/src/service.rs index 20a7980..f844dd2 100644 --- a/src/service.rs +++ b/src/service.rs @@ -89,6 +89,7 @@ pub trait ServiceTrait { None } + #[cfg_attr(not(feature = "tray"), allow(dead_code))] fn has_web_ui(&self) -> bool { return false; }