feat: add remote reboot support

This commit is contained in:
2026-04-19 16:53:17 +02:00
parent 92040e5c5e
commit afbb425e3b
11 changed files with 381 additions and 19 deletions

View File

@@ -185,6 +185,10 @@ struct ServerInfo: Codable, Hashable, Equatable {
].filter { !$0.isEmpty }
return components.isEmpty ? nil : components.joined(separator: "")
}
var supportsRestartCommand: Bool {
ServerInfo.version(apiVersion, isAtLeast: "2.14")
}
}
// MARK: - Helpers & Sample Data
@@ -226,6 +230,27 @@ extension ServerInfo {
return normalized
}
private static func version(_ value: String, isAtLeast minimum: String) -> Bool {
let lhs = value
.split(separator: ".")
.compactMap { Int($0) }
let rhs = minimum
.split(separator: ".")
.compactMap { Int($0) }
let count = max(lhs.count, rhs.count)
for index in 0..<count {
let left = index < lhs.count ? lhs[index] : 0
let right = index < rhs.count ? rhs[index] : 0
if left != right {
return left > right
}
}
return true
}
static let placeholder = ServerInfo(
hostname: "preview.example.com",
ipAddresses: ["192.168.1.1", "fe80::1"],