From e0b5410a97e4557df92f212a4b2dfbb29dcbc3a3 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 1 Jan 2026 16:18:16 +0800 Subject: [PATCH] cargo fmt --- leaf/src/app/api/api_server.rs | 20 ++++++++++++++++---- leaf/src/app/mod.rs | 2 +- leaf/src/proxy/hc/inbound/mod.rs | 1 - leaf/src/proxy/hc/mod.rs | 1 - leaf/src/util.rs | 5 ++++- leaf/src/winsys.rs | 3 +-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/leaf/src/app/api/api_server.rs b/leaf/src/app/api/api_server.rs index 0c85e51..3db3455 100644 --- a/leaf/src/app/api/api_server.rs +++ b/leaf/src/app/api/api_server.rs @@ -260,7 +260,10 @@ table, th, td { Path(tag): Path, State(rm): State>, ) -> Result, Infallible> { - let (tcp_res, udp_res) = rm.health_check_outbound(&tag, None).await.unwrap_or((Err(anyhow::anyhow!("runtime")), Err(anyhow::anyhow!("runtime")))); + let (tcp_res, udp_res) = rm.health_check_outbound(&tag, None).await.unwrap_or(( + Err(anyhow::anyhow!("runtime")), + Err(anyhow::anyhow!("runtime")), + )); let tcp_ms = tcp_res.ok().map(|d| d.as_millis()); let udp_ms = udp_res.ok().map(|d| d.as_millis()); Ok(Json(models::OutboundHealthCheck { @@ -296,9 +299,18 @@ impl ApiServer { app = app .route("/api/v1/runtime/stat/html", get(handlers::stat_html)) .route("/api/v1/runtime/stat/json", get(handlers::stat_json)) - .route("/api/v1/runtime/outbound/{tag}/last_peer_active", get(handlers::last_peer_active)) - .route("/api/v1/runtime/outbound/{tag}/since_last_peer_active", get(handlers::since_last_peer_active)) - .route("/api/v1/runtime/outbound/{tag}/health", get(handlers::outbound_health)); + .route( + "/api/v1/runtime/outbound/{tag}/last_peer_active", + get(handlers::last_peer_active), + ) + .route( + "/api/v1/runtime/outbound/{tag}/since_last_peer_active", + get(handlers::since_last_peer_active), + ) + .route( + "/api/v1/runtime/outbound/{tag}/health", + get(handlers::outbound_health), + ); let app = app.with_state(self.runtime_manager.clone()); diff --git a/leaf/src/app/mod.rs b/leaf/src/app/mod.rs index 764b597..c4d211c 100644 --- a/leaf/src/app/mod.rs +++ b/leaf/src/app/mod.rs @@ -4,13 +4,13 @@ use tokio::sync::RwLock; pub mod dispatcher; pub mod dns_client; +pub mod healthcheck; pub mod inbound; pub mod logger; pub mod nat_manager; pub mod outbound; pub mod router; pub mod stat_manager; -pub mod healthcheck; #[cfg(feature = "api")] pub mod api; diff --git a/leaf/src/proxy/hc/inbound/mod.rs b/leaf/src/proxy/hc/inbound/mod.rs index 050a413..e115a4f 100644 --- a/leaf/src/proxy/hc/inbound/mod.rs +++ b/leaf/src/proxy/hc/inbound/mod.rs @@ -1,4 +1,3 @@ mod stream; pub use stream::Handler; - diff --git a/leaf/src/proxy/hc/mod.rs b/leaf/src/proxy/hc/mod.rs index 14e9db1..909522f 100644 --- a/leaf/src/proxy/hc/mod.rs +++ b/leaf/src/proxy/hc/mod.rs @@ -1,3 +1,2 @@ #[cfg(feature = "inbound-hc")] pub mod inbound; - diff --git a/leaf/src/util.rs b/leaf/src/util.rs index a5fa3c0..e280991 100644 --- a/leaf/src/util.rs +++ b/leaf/src/util.rs @@ -185,7 +185,10 @@ pub async fn health_check_outbound( .get(tag) .ok_or_else(|| anyhow!("outbound {} not found", tag))?; let (tcp_res, udp_res) = futures::future::join( - timeout(to, test_healthcheck_tcp(dns_client.clone(), handler.clone())), + timeout( + to, + test_healthcheck_tcp(dns_client.clone(), handler.clone()), + ), timeout(to, test_healthcheck_udp(dns_client, handler)), ) .await; diff --git a/leaf/src/winsys.rs b/leaf/src/winsys.rs index dfc013d..f643281 100644 --- a/leaf/src/winsys.rs +++ b/leaf/src/winsys.rs @@ -6,8 +6,7 @@ pub fn get_default_interface_ips() -> String { Err(_) => return String::new(), }; - let candidate = adapters.iter() - .find(|a| !a.gateways().is_empty()); + let candidate = adapters.iter().find(|a| !a.gateways().is_empty()); let adapter = match candidate { Some(adapter) => adapter,