mirror of
https://github.com/insidegui/VirtualBuddy.git
synced 2026-12-02 03:29:20 +08:00
* Move ECID getter into VZMacMachineIdentifier * Implement a custom macOS restore backend to work around macOS 27 issues on macOS 26 hosts * Add virtual installation requirement set and enforce during VM restore * Change requirement for macOS 27 Virtual Installation to min host macOS 26 * Add CI script that sets CURRENT_PROJECT_VERSION to the Xcode Cloud build number
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
import Cocoa
|
|
import OSLog
|
|
@_spi(VirtualInstallationService) import VirtualInstallation
|
|
|
|
final class VIServiceDelegate: NSObject, NSXPCListenerDelegate {
|
|
private let logger = Logger(subsystem: kVirtualInstallationSubsystem, category: String(describing: VIServiceDelegate.self))
|
|
|
|
func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
|
|
logger.debug("New connection: \(newConnection)")
|
|
|
|
let service = VirtualInstallationService(clientConnection: newConnection)
|
|
|
|
newConnection.setVirtualInstallationCodeSigningRequirement()
|
|
|
|
newConnection.invalidationHandler = { [self, weak service] in
|
|
logger.notice("Connection invalidated: \(newConnection)")
|
|
service?.terminate(reason: "Connection invalidated")
|
|
}
|
|
|
|
newConnection.interruptionHandler = { [self, weak service] in
|
|
logger.warning("Connection interrupted: \(newConnection)")
|
|
service?.terminate(reason: "Connection interrupted")
|
|
}
|
|
|
|
newConnection.exportedInterface = NSXPCInterface(with: VirtualInstallationServiceProtocol.self)
|
|
newConnection.exportedObject = service
|
|
|
|
newConnection.remoteObjectInterface = NSXPCInterface(with: VirtualInstallationClientProtocol.self)
|
|
|
|
newConnection.activate()
|
|
|
|
return true
|
|
}
|
|
|
|
private lazy var listener = NSXPCListener.service()
|
|
|
|
func bootstrap() {
|
|
listener.delegate = self
|
|
listener.activate()
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct VIServiceApp {
|
|
private static let logger = Logger(subsystem: kVirtualInstallationSubsystem, category: String(describing: VIServiceApp.self))
|
|
|
|
private static let delegate = VIServiceDelegate()
|
|
|
|
static func main() {
|
|
logger.log("Service main.")
|
|
|
|
delegate.bootstrap()
|
|
}
|
|
}
|