Files
Termind/Frameworks/TermindApplication/FeatureModels/HostLibraryModel+LocalNetwork.swift
T
Kaede Akino 9a36fde226 fix(pro): enforce protocol-aware host admission before mutation
Distinguish SSH route admission from Telnet target admission and wire
Telnet access and automatic Wake hooks. Await entitlement resolution for
manual Wake and duplication before host or credential mutation.

Use explicit protocol-extension forwarding overloads so existential
single-argument calls cannot bypass the concrete admission witness.
Remove dead paywall state and update obsolete quota/date test fixtures.
Validation: 81 focused macOS and 58 focused iOS tests passed.
2026-10-17 09:50:55 +08:00

34 lines
1.1 KiB
Swift

import TermindDomain
import struct TermindDomain.Host
public nonisolated enum HostWakeOutcome: Equatable, Sendable {
case configurationRequired
case sent
case failed
}
extension HostLibraryModel {
/// Lock checks precede configuration and packet transmission.
public func requestWake(_ proposed: Host) async throws -> HostWakeOutcome {
let wasSaved = host(proposed.id) != nil
do {
try hostAccess.requireAccess(to: proposed.id, in: hosts)
} catch HostAccessError.verifyingEntitlement {
await resolveInitialHostEntitlement?()
}
try Task.checkCancellation()
guard !wasSaved || host(proposed.id) != nil else { throw CancellationError() }
try hostAccess.requireAccess(to: proposed.id, in: hosts)
let host = host(proposed.id) ?? proposed
guard host.wakeOnLAN.address != nil else { return .configurationRequired }
do {
guard let wakeOnLAN else { throw WakeOnLANError.noLocalNetwork }
try wakeOnLAN.wake(host.wakeOnLAN)
return .sent
} catch {
return .failed
}
}
}