Fix: status verwendet keinen Fake-Hostnamen fuer die Erreichbarkeitspruefung

local_reachable() reichte bei fehlgeschlagener Adressaufloesung (MAC->IP)
den Platzhalter-String "unresolved" an network::is_reachable() weiter -
das loeste dort einen sinnlosen ping-Aufruf gegen einen nicht
existierenden Hostnamen aus, statt korrekt "nicht erreichbar" zu
melden. Gibt jetzt direkt false zurueck, wenn die Adresse nicht
aufgeloest werden kann.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjyzpGWECyKSBWz5DtkTGz
This commit is contained in:
2026-09-15 23:09:01 +02:00
co-authored by Claude Sonnet 5
parent c8c3409b98
commit 629959ad41
+13 -7
View File
@@ -48,8 +48,9 @@ pub async fn run(name: Option<String>, json: bool) -> anyhow::Result<()> {
name: pair.name.clone(), name: pair.name.clone(),
mount_point: pair.mount_point.display().to_string(), mount_point: pair.mount_point.display().to_string(),
active, active,
local_source: target::local_source(&pair.local, &cfg.settings), local_source: target::local_source(&pair.local, &cfg.settings)
local_reachable: network::is_reachable(&local_src_host(&pair.local, &cfg.settings)), .unwrap_or_else(|_| "unresolved".to_string()),
local_reachable: local_reachable(&pair.local, &cfg.settings),
cloud_source: target::cloud_source(&pair.cloud), cloud_source: target::cloud_source(&pair.cloud),
cloud_reachable: network::is_reachable(&pair.cloud.host_or_url), cloud_reachable: network::is_reachable(&pair.cloud.host_or_url),
} }
@@ -88,11 +89,16 @@ fn reachable_str(reachable: bool) -> &'static str {
} }
} }
fn local_src_host( /// `false` wenn die Adresse (MAC->IP) gar nicht erst aufgelöst werden kann, statt den
/// Platzhalter-String `"unresolved"` an `network::is_reachable` weiterzureichen - das würde
/// dort einen sinnlosen `ping unresolved`-Aufruf gegen einen nicht existierenden Hostnamen
/// auslösen statt korrekt "nicht erreichbar" zu melden.
fn local_reachable(
local: &smart_mount::config::LocalSide, local: &smart_mount::config::LocalSide,
settings: &smart_mount::config::GlobalSettings, settings: &smart_mount::config::GlobalSettings,
) -> String { ) -> bool {
smart_mount::network::address::resolve_ip(&local.address, settings) match smart_mount::network::address::resolve_ip(&local.address, settings) {
.map(|ip| ip.to_string()) Ok(ip) => network::is_reachable(&ip.to_string()),
.unwrap_or_else(|_| "unresolved".to_string()) Err(_) => false,
}
} }