diff --git a/Plugin/unraid/include/config.php b/Plugin/unraid/include/config.php index 8ebf9b3..e07252f 100644 --- a/Plugin/unraid/include/config.php +++ b/Plugin/unraid/include/config.php @@ -171,6 +171,16 @@ function vv_detect_host(): string { foreach ($m[1] as $i => $key) { if (strcasecmp($hostname, trim($m[2][$i])) === 0) return strtolower($key); } + // Unraid truncates the Server Name to 15 chars (NetBIOS limit). If the live hostname + // is at that exact limit, the name configured in master.conf (matching what Tailscale + // shows for this peer — resolve_tailscale_ip() keys off the same value) may be a longer, + // untruncated version. Treat a same-prefix match as this host rather than 'unknown'. + if (strlen($hostname) === 15) { + foreach ($m[1] as $i => $key) { + $configured = trim($m[2][$i]); + if (strlen($configured) > 15 && stripos($configured, $hostname) === 0) return strtolower($key); + } + } return 'unknown'; } diff --git a/Plugin/unraid/include/monitor.php b/Plugin/unraid/include/monitor.php index df649b8..588db93 100644 --- a/Plugin/unraid/include/monitor.php +++ b/Plugin/unraid/include/monitor.php @@ -4,8 +4,8 @@ require_once __DIR__ . '/common.php'; // Monitor-page-specific helpers — partner state, fallback state, watchdog summary, scripts status. function vv_partner_state(): array { - $vars = vv_conf_vars(); - $myName = trim(shell_exec('hostname -s') ?: ''); + $vars = vv_conf_vars(); + $myHostId = strtoupper(vv_detect_host()); // Parse Tailscale peer status once $tsData = json_decode(shell_exec('tailscale status --json 2>/dev/null') ?: '{}', true) ?? []; @@ -26,7 +26,7 @@ function vv_partner_state(): array { foreach ($hostIds as $id) { $hostname = $vars[$id] ?? ''; if (!$hostname) continue; - $isMe = strcasecmp($hostname, $myName) === 0; + $isMe = ($id === $myHostId); $isOwner = strcasecmp($id, $vars['PARTNERSHIP_OWNER_HOST'] ?? '') === 0; $online = $isMe ? true : ($tsPeers[strtolower($hostname)] ?? null); $onboardPhase = $isMe ? null @@ -87,17 +87,13 @@ function vv_fallback_state(): array { } function vv_fallback_active(): array { - $vars = vv_conf_vars(); - $myName = trim(shell_exec('hostname -s') ?: ''); + $vars = vv_conf_vars(); // Identify which HOST id we are $allHostIds = array_filter(array_keys($vars), fn($k) => preg_match('/^HOST\d+$/', $k) && ($vars[$k] ?? '') !== ''); sort($allHostIds); - $myId = null; - foreach ($allHostIds as $id) { - if (strcasecmp($vars[$id] ?? '', $myName) === 0) { $myId = $id; break; } - } - if (!$myId) return []; + $myId = strtoupper(vv_detect_host()); + if ($myId === 'UNKNOWN' || !in_array($myId, $allHostIds, true)) return []; // Running containers: name → image $running = [];