";
if ($running) {
// Get stats from container and check if they are not empty
$TSstats = tailscale_stats($name);
if (!empty($TSstats)) {
// Construct TSinfo from TSstats
$TSinfo = '';
if (!$TSstats["Self"]["Online"]) {
$TSinfo .= "
Online:❌
Please check the logs!
";
} else {
$TS_version = explode('-', $TSstats["Version"])[0];
if (!empty($TS_version)) {
if (!empty($TS_latest_version)) {
if ($TS_version !== $TS_latest_version) {
$TSinfo .= "
Version:" . $TS_version . " ➔ " . $TS_latest_version . " available!
";
} else {
$TSinfo .= "
Version:" . $TS_version . "
";
}
} else {
$TSinfo .= "
Version:" . $TS_version . "
";
}
}
$TSinfo .= "
Online:✅
";
$TS_DNSName = $TSstats["Self"]["DNSName"];
$TS_HostNameActual = substr($TS_DNSName, 0, strpos($TS_DNSName, '.'));
if (strcasecmp($TS_HostNameActual, $TShostname) !== 0 && !empty($TS_DNSName)) {
$TSinfo .= "
Hostname:Real Hostname ➔ " . $TS_HostNameActual . "
";
} else {
$TSinfo .= "
Hostname:" . $TShostname . "
";
}
// Map region relay code to cleartext region if TS_derp_list is available
if (!empty($TS_derp_list)) {
foreach ($TS_derp_list['Regions'] as $region) {
if ($region['RegionCode'] === $TSstats["Self"]["Relay"]) {
$TSregion = $region['RegionName'];
break;
}
}
if (!empty($TSregion)) {
$TSinfo .= "
Main Relay:" . $TSregion . "
";
} else {
$TSinfo .= "
Main Relay:" . $TSstats["Self"]["Relay"] . "
";
}
} else {
$TSinfo .= "
Main Relay:" . $TSstats["Self"]["Relay"] . "
";
}
if (!empty($TSstats["Self"]["TailscaleIPs"])) {
$TSinfo .= "
Addresses:" . implode("
", $TSstats["Self"]["TailscaleIPs"]) . "
";
}
if (!empty($TSstats["Self"]["PrimaryRoutes"])) {
$TSinfo .= "
Routes:" . implode("
", $TSstats["Self"]["PrimaryRoutes"]) . "
";
}
if ($TSstats["Self"]["ExitNodeOption"]) {
$TSinfo .= "
Is Exit Node:✅
";
} else {
if (!empty($TSstats["ExitNodeStatus"])) {
$TS_exit_node_status = ($TSstats["ExitNodeStatus"]["Online"]) ? "✅" : "❌";
$TSinfo .= "
Exit Node:" . strstr($TSstats["ExitNodeStatus"]["TailscaleIPs"][0], '/', true) . " | Status: " . $TS_exit_node_status ."
";
} else {
$TSinfo .= "
Is Exit Node:❌
";
}
}
if (!empty($TSwebGui)) {
$TSinfo .= "
URL:" . $TSwebGui . "
";
}
if (!empty($TSstats["Self"]["KeyExpiry"])) {
$TS_expiry = new DateTime($TSstats["Self"]["KeyExpiry"]);
$current_Date = new DateTime();
$TS_expiry_formatted = $TS_expiry->format('Y-m-d');
$TS_expiry_diff = $current_Date->diff($TS_expiry);
if ($TS_expiry_diff->invert) {
$TSinfo .= "
Key Expiry:❌ Expired! Renew/Disable key expiry!
";
} else {
$TSinfo .= "
Key Expiry:" . $TS_expiry_formatted . " (" . $TS_expiry_diff->days . " days)
";
}
}
}
// Display TSinfo if data was fetched correctly
$TS_status = "
";
} else {
// Display message to refresh page if Tailscale in the container wasn't maybe ready to get the data
$TS_status = "
";
}
} else {
// Display message that container isn't running
$TS_status = "
";
}
echo "
";
}
echo "