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.
25 lines
714 B
Swift
25 lines
714 B
Swift
import NetworkExtension
|
|
|
|
class PacketTunnelProvider: NEPacketTunnelProvider {
|
|
|
|
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
|
|
completionHandler(nil)
|
|
}
|
|
|
|
override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
|
completionHandler()
|
|
}
|
|
|
|
override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)?) {
|
|
if let handler = completionHandler {
|
|
handler(messageData)
|
|
}
|
|
}
|
|
|
|
override func sleep(completionHandler: @escaping () -> Void) {
|
|
completionHandler()
|
|
}
|
|
|
|
override func wake() {
|
|
}
|
|
}
|