Add support for starting and stopping the tunnel

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.
This commit is contained in:
Conrad Kramer 2023-05-08 18:19:13 -04:00
parent eeb0130156
commit b3a540fc48
8 changed files with 277 additions and 28 deletions

43
Apple/App/Status.swift Normal file
View file

@ -0,0 +1,43 @@
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"
}
}
}
}