wireguard-apple/WireGuard/Coordinators/AppCoordinator+TunnelInfoTa...

34 lines
1.2 KiB
Swift
Raw Normal View History

2018-09-26 09:21:53 +00:00
//
// Copyright © 2018 WireGuard LLC. All rights reserved.
//
import Foundation
2018-09-29 20:29:34 +00:00
import NetworkExtension
2018-09-26 09:21:53 +00:00
extension AppCoordinator: TunnelInfoTableViewControllerDelegate {
2018-09-29 20:29:34 +00:00
func connect(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController) {
connect(tunnel: tunnel)
}
func disconnect(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController) {
disconnect(tunnel: tunnel)
}
func status(for tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController) -> NEVPNStatus {
let session = self.providerManager(for: tunnel)?.connection as? NETunnelProviderSession
return session?.status ?? .invalid
}
2018-09-26 09:21:53 +00:00
func configure(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController) {
print("configure tunnel \(tunnel)")
let editContext = persistentContainer.newBackgroundContext()
var backgroundTunnel: Tunnel?
editContext.performAndWait {
backgroundTunnel = editContext.object(with: tunnel.objectID) as? Tunnel
}
showTunnelConfigurationViewController(tunnel: backgroundTunnel, context: editContext)
}
}