From 599a048015a37bef81f32d46010c7300bbaf6b84 Mon Sep 17 00:00:00 2001 From: irrlicht Date: Sat, 31 Oct 2026 21:33:19 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20nur=20physische=20Netzwerk-Interfaces=20?= =?UTF-8?q?z=C3=A4hlen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Virtuelle Interfaces (Bridges, veth, Docker, VPN-Tunnel) führen denselben Traffic wie die physische Karte und wurden bisher doppelt gezählt. Gezählt werden jetzt nur Interfaces mit /sys/class/net//device; Loopback fällt damit ebenfalls raus. Co-Authored-By: Claude Opus 5.5 --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index c50be93..f3b3219 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,7 +81,8 @@ fn query_cpu_temp() -> String { } } -// Sums rx/tx byte counters across all interfaces except loopback. +// Sums rx/tx byte counters across physical interfaces only. Virtual ones +// (loopback, bridges, veth, VPN tunnels) would count the same traffic twice. fn read_net_bytes() -> (u64, u64) { let mut down = 0u64; let mut up = 0u64; @@ -96,7 +97,8 @@ fn read_net_bytes() -> (u64, u64) { let Some((iface, rest)) = line.split_once(':') else { continue; }; - if iface.trim() == "lo" { + // Only physical interfaces have a backing device in sysfs. + if !Path::new("/sys/class/net").join(iface.trim()).join("device").exists() { continue; } let fields: Vec<&str> = rest.split_whitespace().collect();