diff --git a/config.dae b/config.dae index 4448da35..be68f8fa 100644 --- a/config.dae +++ b/config.dae @@ -185,7 +185,7 @@ experimental { default_mode: 'Rule' } cache_file { - enabled: false + enabled: true path: 'cache.db' cache_id: '' store_fakeip: false diff --git a/crates/honk-config/src/parser/tests.rs b/crates/honk-config/src/parser/tests.rs index d1bdc347..8a93be4d 100644 --- a/crates/honk-config/src/parser/tests.rs +++ b/crates/honk-config/src/parser/tests.rs @@ -452,7 +452,15 @@ group { let mut v: Vec = g .nodes .iter() - .map(|id| config.nodes.iter().find(|n| n.id == *id).unwrap().name.clone()) + .map(|id| { + config + .nodes + .iter() + .find(|n| n.id == *id) + .unwrap() + .name + .clone() + }) .collect(); v.sort(); v diff --git a/crates/honk-core/benches/dns.rs b/crates/honk-core/benches/dns.rs index 1d7fdd21..ab6e7543 100644 --- a/crates/honk-core/benches/dns.rs +++ b/crates/honk-core/benches/dns.rs @@ -9,7 +9,6 @@ use std::sync::Arc; use std::time::Duration; use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; -use std::hint::black_box; use honk_config::dns::{DnsRouting, DnsUpstream}; use honk_config::types::DnsProtocol; use honk_core::dns::cache::DnsCache; @@ -20,6 +19,7 @@ use honk_core::dns::transport::{ DialContext, TcpPool, exchange_length_prefixed, force_dns_id_zero, restore_dns_id, }; use honk_core::dns::upstream_pool::UpstreamPool; +use std::hint::black_box; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, UdpSocket}; use tokio::runtime::Runtime; diff --git a/crates/honk-core/src/control/janitor.rs b/crates/honk-core/src/control/janitor.rs index 6cc0a94d..2a9237dd 100644 --- a/crates/honk-core/src/control/janitor.rs +++ b/crates/honk-core/src/control/janitor.rs @@ -20,8 +20,8 @@ use crate::ebpf::EbpfBackend; use honk_ebpf_common::conn::{ - MAX_CONN_STATE_NUM, TCP_CONN_STATE_CLOSING_TIMEOUT_NS, - TCP_CONN_STATE_ESTABLISHED_TIMEOUT_NS, TcpState, UDP_CONN_STATE_TIMEOUT_NS, + MAX_CONN_STATE_NUM, TCP_CONN_STATE_CLOSING_TIMEOUT_NS, TCP_CONN_STATE_ESTABLISHED_TIMEOUT_NS, + TcpState, UDP_CONN_STATE_TIMEOUT_NS, }; use honk_ebpf_common::{RedirectTuple, TuplesKey}; use std::sync::Arc; @@ -80,7 +80,10 @@ struct OccupancyGauge { impl OccupancyGauge { /// Raw counter-derived occupancy before drift correction. fn raw_estimate(&self, inserts: u64, ebpf_deletes: u64, userspace_deletes: u64) -> i64 { - inserts as i64 - ebpf_deletes as i64 - self.janitor_deletes as i64 - userspace_deletes as i64 + inserts as i64 + - ebpf_deletes as i64 + - self.janitor_deletes as i64 + - userspace_deletes as i64 } fn estimate(&self, inserts: u64, ebpf_deletes: u64, userspace_deletes: u64) -> u64 { @@ -220,8 +223,7 @@ impl BpfJanitor { }; if last_conn_state_cleanup + conn_state_interval <= now { - let (deleted, total) = - self.cleanup_conn_state(&mut gauge, occ_counters).await; + let (deleted, total) = self.cleanup_conn_state(&mut gauge, occ_counters).await; last_conn_state_cleanup = now; if utilization >= CONN_STATE_ELEVATED_WATERMARK || deleted > 0 { info!( diff --git a/crates/honk-core/src/ebpf/real/mod.rs b/crates/honk-core/src/ebpf/real/mod.rs index bae81578..d9811e63 100644 --- a/crates/honk-core/src/ebpf/real/mod.rs +++ b/crates/honk-core/src/ebpf/real/mod.rs @@ -645,9 +645,12 @@ impl EbpfBackend for RealEbpfBackend { .enumerate() { let mut buf = vec![0u8; ncpu * 8]; - if let Some(()) = - bpf_hash_lookup(bpf, "CONN_STATE_OCCUPANCY", unsafe { as_bytes(&slot) }, &mut buf)? - { + if let Some(()) = bpf_hash_lookup( + bpf, + "CONN_STATE_OCCUPANCY", + unsafe { as_bytes(&slot) }, + &mut buf, + )? { slots[i] = sum_percpu_u64(&buf, ncpu); } } diff --git a/crates/honk-outbound/examples/ech_probe.rs b/crates/honk-outbound/examples/ech_probe.rs index 4a01a54b..6422257f 100644 --- a/crates/honk-outbound/examples/ech_probe.rs +++ b/crates/honk-outbound/examples/ech_probe.rs @@ -63,7 +63,9 @@ async fn main() -> anyhow::Result<()> { stream.ssl().ech_accepted() ); - let req = format!("GET /ech-check.php HTTP/1.1\r\nHost: {host}\r\nUser-Agent: honk-ech-probe\r\nConnection: close\r\n\r\n"); + let req = format!( + "GET /ech-check.php HTTP/1.1\r\nHost: {host}\r\nUser-Agent: honk-ech-probe\r\nConnection: close\r\n\r\n" + ); stream.write_all(req.as_bytes()).await?; let mut buf = Vec::new(); let _ = stream.read_to_end(&mut buf).await; diff --git a/crates/honk-outbound/examples/juice_probe.rs b/crates/honk-outbound/examples/juice_probe.rs index 5d4473a2..0d096019 100644 --- a/crates/honk-outbound/examples/juice_probe.rs +++ b/crates/honk-outbound/examples/juice_probe.rs @@ -49,11 +49,7 @@ async fn main() -> anyhow::Result<()> { .await; match result { Ok(Ok(conn)) => { - println!( - "chrome={}: CONNECTED rtt={:?}", - chrome, - conn.rtt() - ); + println!("chrome={}: CONNECTED rtt={:?}", chrome, conn.rtt()); conn.close(0u32.into(), b"done"); } Ok(Err(e)) => println!("chrome={}: connect error: {}", chrome, e), diff --git a/crates/honk-outbound/src/alive/mod.rs b/crates/honk-outbound/src/alive/mod.rs index 84ab5e29..080920b9 100644 --- a/crates/honk-outbound/src/alive/mod.rs +++ b/crates/honk-outbound/src/alive/mod.rs @@ -820,9 +820,7 @@ impl AliveDialerSet { let idx = alive_index(domain, ipver); let cols = self.collections.read(); let coll = cols.get(node_id).map(|arr| &arr[idx])?; - coll.latencies - .last_real_sample() - .map(|s| (s.latency, s.at)) + coll.latencies.last_real_sample().map(|s| (s.latency, s.at)) } /// Moving average of the recent probe samples for the same diff --git a/crates/honk-outbound/src/proxy/juicity.rs b/crates/honk-outbound/src/proxy/juicity.rs index 044ddff1..5820f68d 100644 --- a/crates/honk-outbound/src/proxy/juicity.rs +++ b/crates/honk-outbound/src/proxy/juicity.rs @@ -338,7 +338,10 @@ impl JuicityHandler { }); // Another task may have won the race — reuse theirs. let mut clients = CLIENTS.lock(); - Ok(clients.entry(key).or_insert_with(|| Arc::clone(&client)).clone()) + Ok(clients + .entry(key) + .or_insert_with(|| Arc::clone(&client)) + .clone()) } /// Open a bi stream and write the juicity request header diff --git a/crates/honk-outbound/src/proxy/tuic.rs b/crates/honk-outbound/src/proxy/tuic.rs index 40fe8be9..68295594 100644 --- a/crates/honk-outbound/src/proxy/tuic.rs +++ b/crates/honk-outbound/src/proxy/tuic.rs @@ -700,7 +700,10 @@ impl TuicHandler { }); // Another task may have won the race — reuse theirs. let mut clients = CLIENTS.lock(); - Ok(clients.entry(key).or_insert_with(|| Arc::clone(&client)).clone()) + Ok(clients + .entry(key) + .or_insert_with(|| Arc::clone(&client)) + .clone()) } async fn send_udp( diff --git a/crates/honk-outbound/src/util.rs b/crates/honk-outbound/src/util.rs index 698f87e4..44023fe7 100644 --- a/crates/honk-outbound/src/util.rs +++ b/crates/honk-outbound/src/util.rs @@ -20,9 +20,7 @@ pub fn set_mark_best_effort(socket: &socket2::Socket, mark: u32) -> io::Result<( Err(e) if e.kind() == io::ErrorKind::PermissionDenied => { static ONCE: std::sync::Once = std::sync::Once::new(); ONCE.call_once(|| { - tracing::debug!( - "SO_MARK denied (unprivileged); continuing without bypass mark" - ); + tracing::debug!("SO_MARK denied (unprivileged); continuing without bypass mark"); }); Ok(()) }