mirror of
https://github.com/daeuniverse/honk.git
synced 2026-12-06 16:01:20 +00:00
chore(fmt): fmt
This commit is contained in:
1 parent
82077df4aa
commit
d82393ac30
11 files changed
+38
-25
No files matched your search
+1
-1
@@ -185,7 +185,7 @@ experimental {
|
||||
default_mode: 'Rule'
|
||||
}
|
||||
cache_file {
|
||||
enabled: false
|
||||
enabled: true
|
||||
path: 'cache.db'
|
||||
cache_id: ''
|
||||
store_fakeip: false
|
||||
|
||||
@@ -452,7 +452,15 @@ group {
|
||||
let mut v: Vec<String> = 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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user