Change auto connection type to prioritize local IP first
All checks were successful
Build and Release / build-and-release (push) Successful in 2m36s

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
This commit is contained in:
Christoffer Martinsson 2025-11-13 12:52:46 +01:00
parent 0a13cab897
commit 76b6e3373e
5 changed files with 17 additions and 16 deletions

6
Cargo.lock generated
View File

@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.67" version = "0.1.68"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -292,7 +292,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.67" version = "0.1.68"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -315,7 +315,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.67" version = "0.1.68"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.68" version = "0.1.69"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.68" version = "0.1.69"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -62,11 +62,11 @@ impl HostDetails {
} }
} }
"auto" | _ => { "auto" | _ => {
// Try tailscale first, then local, then hostname // Try local first, then tailscale, then hostname
if let Some(ref ts_ip) = self.tailscale_ip { if let Some(ref local_ip) = self.ip {
ts_ip.clone()
} else if let Some(ref local_ip) = self.ip {
local_ip.clone() local_ip.clone()
} else if let Some(ref ts_ip) = self.tailscale_ip {
ts_ip.clone()
} else { } else {
hostname.to_string() hostname.to_string()
} }
@ -81,18 +81,19 @@ impl HostDetails {
// Add all available IPs except the primary one // Add all available IPs except the primary one
let primary = self.get_connection_ip(hostname); let primary = self.get_connection_ip(hostname);
if let Some(ref ts_ip) = self.tailscale_ip { // Add fallbacks in priority order: local first, then tailscale
if ts_ip != &primary {
fallbacks.push(ts_ip.clone());
}
}
if let Some(ref local_ip) = self.ip { if let Some(ref local_ip) = self.ip {
if local_ip != &primary { if local_ip != &primary {
fallbacks.push(local_ip.clone()); 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 // Always include hostname as final fallback if not already primary
if hostname != primary { if hostname != primary {
fallbacks.push(hostname.to_string()); fallbacks.push(hostname.to_string());

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.68" version = "0.1.69"
edition = "2021" edition = "2021"
[dependencies] [dependencies]