From 3c278351c97df13871787c8978dff878a7003b66 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Tue, 9 Dec 2025 10:47:18 +0100 Subject: [PATCH] Filter out current host from Tailscale peer list Skip the first line in tailscale status output which is always the current host showing as idle. Add additional hostname check to prevent showing the current host in the peer list. Only display actual remote peers with their connection methods. --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 18 +++++++++++++++++- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16e26ee..46e7f1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.263" +version = "0.1.264" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.263" +version = "0.1.264" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.263" +version = "0.1.264" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 85b57e1..8b15745 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.264" +version = "0.1.265" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index f606c5f..78a4892 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -948,10 +948,20 @@ impl SystemdCollector { let status_output = String::from_utf8_lossy(&output.stdout); let mut peers = Vec::new(); + // Get current hostname to filter it out + let current_hostname = gethostname::gethostname() + .to_string_lossy() + .to_string(); + // Parse tailscale status output // Format: IP hostname user os status // Example: 100.110.98.3 wslbox cm@ linux active; direct 192.168.30.227:53757 - for line in status_output.lines() { + // Note: First line is always the current host, skip it + for (idx, line) in status_output.lines().enumerate() { + if idx == 0 { + continue; // Skip first line (current host) + } + let parts: Vec<&str> = line.split_whitespace().collect(); if parts.len() < 5 { continue; // Skip invalid lines @@ -964,6 +974,12 @@ impl SystemdCollector { // parts[4+] = status (e.g., "active;", "direct", "192.168.30.227:53757" or "idle;" or "offline") let hostname = parts[1]; + + // Skip if this is the current host (double-check in case format changes) + if hostname == current_hostname { + continue; + } + let status_parts = &parts[4..]; // Determine connection method from status diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 597b6ac..4ffc436 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.264" +version = "0.1.265" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 990044f..66544e7 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.264" +version = "0.1.265" edition = "2021" [dependencies]