From 76b6e3373e7b6ab87384d3acba418dc57de1fac7 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 13 Nov 2025 12:52:46 +0100 Subject: [PATCH] Change auto connection type to prioritize local IP first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the auto connection type logic to try local network connections before falling back to Tailscale. This provides better performance by using faster local connections when available while maintaining Tailscale as a reliable fallback. Changes: - Auto connection priority: local → tailscale → hostname (was tailscale → local) - Fallback retry order updated to match new priority - Supports omitting IP field in config for hosts without static local IP --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/config/mod.rs | 21 +++++++++++---------- shared/Cargo.toml | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7e640d..d3f8c35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.67" +version = "0.1.68" dependencies = [ "anyhow", "chrono", @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.67" +version = "0.1.68" dependencies = [ "anyhow", "async-trait", @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.67" +version = "0.1.68" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 5cd0dbd..4c5a37c 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.68" +version = "0.1.69" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 99d4726..bd2777a 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.68" +version = "0.1.69" edition = "2021" [dependencies] diff --git a/dashboard/src/config/mod.rs b/dashboard/src/config/mod.rs index 3422903..3c255b7 100644 --- a/dashboard/src/config/mod.rs +++ b/dashboard/src/config/mod.rs @@ -62,11 +62,11 @@ impl HostDetails { } } "auto" | _ => { - // Try tailscale first, then local, then hostname - if let Some(ref ts_ip) = self.tailscale_ip { - ts_ip.clone() - } else if let Some(ref local_ip) = self.ip { + // Try local first, then tailscale, then hostname + if let Some(ref local_ip) = self.ip { local_ip.clone() + } else if let Some(ref ts_ip) = self.tailscale_ip { + ts_ip.clone() } else { hostname.to_string() } @@ -81,18 +81,19 @@ impl HostDetails { // Add all available IPs except the primary one let primary = self.get_connection_ip(hostname); - if let Some(ref ts_ip) = self.tailscale_ip { - if ts_ip != &primary { - fallbacks.push(ts_ip.clone()); - } - } - + // Add fallbacks in priority order: local first, then tailscale if let Some(ref local_ip) = self.ip { if local_ip != &primary { fallbacks.push(local_ip.clone()); } } + if let Some(ref ts_ip) = self.tailscale_ip { + if ts_ip != &primary { + fallbacks.push(ts_ip.clone()); + } + } + // Always include hostname as final fallback if not already primary if hostname != primary { fallbacks.push(hostname.to_string()); diff --git a/shared/Cargo.toml b/shared/Cargo.toml index fb461ed..0af1508 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.68" +version = "0.1.69" edition = "2021" [dependencies]