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:
parent
eeb0130156
commit
b3a540fc48
8 changed files with 277 additions and 28 deletions
43
Apple/App/Status.swift
Normal file
43
Apple/App/Status.swift
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue