feat: add remote reboot support
This commit is contained in:
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user