This commit introduces the Tunnel view model object which has support for asking for permission, starting and stopping the tunnel. It automatically updates its state and publishes changes as an ObservableObject.
43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
import Foundation
|
|
import NetworkExtension
|
|
|
|
extension Tunnel {
|
|
enum Status: CustomStringConvertible, Equatable, Hashable {
|
|
case unknown
|
|
case permissionRequired
|
|
case disabled
|
|
case connecting
|
|
case connected(Date)
|
|
case disconnecting
|
|
case disconnected
|
|
case reasserting
|
|
case invalid
|
|
case configurationReadWriteFailed
|
|
|
|
var description: String {
|
|
switch self {
|
|
case .unknown:
|
|
return "Unknown"
|
|
case .permissionRequired:
|
|
return "Permission Required"
|
|
case .disconnected:
|
|
return "Disconnected"
|
|
case .disabled:
|
|
return "Disabled"
|
|
case .connecting:
|
|
return "Connecting"
|
|
case .connected(_):
|
|
return "Connected"
|
|
case .disconnecting:
|
|
return "Disconnecting"
|
|
case .reasserting:
|
|
return "Reasserting"
|
|
case .invalid:
|
|
return "Invalid"
|
|
case .configurationReadWriteFailed:
|
|
return "System Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|