Everything is a tunnel.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts
2018-05-26 09:17:36 +02:00
parent 9724073447
commit 15e62d7f02
10 changed files with 129 additions and 114 deletions
@@ -1,5 +1,5 @@
// //
// Profile+CoreDataClass.swift // Tunnel+CoreDataClass.swift
// WireGuard // WireGuard
// //
// Created by Jeroen Leenarts on 23-05-18. // Created by Jeroen Leenarts on 23-05-18.
@@ -10,7 +10,7 @@
import Foundation import Foundation
import CoreData import CoreData
@objc(Profile) @objc(Tunnel)
public class Profile: NSManagedObject { public class Tunnel: NSManagedObject {
} }
@@ -1,5 +1,5 @@
// //
// Profile+CoreDataProperties.swift // Tunnel+CoreDataProperties.swift
// WireGuard // WireGuard
// //
// Created by Jeroen Leenarts on 23-05-18. // Created by Jeroen Leenarts on 23-05-18.
@@ -10,10 +10,10 @@
import Foundation import Foundation
import CoreData import CoreData
extension Profile { extension Tunnel {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Profile> { @nonobjc public class func fetchRequest() -> NSFetchRequest<Tunnel> {
return NSFetchRequest<Profile>(entityName: "Profile") return NSFetchRequest<Tunnel>(entityName: "Tunnel")
} }
@NSManaged public var title: String? @NSManaged public var title: String?
@@ -23,7 +23,7 @@ extension Profile {
} }
// MARK: Generated accessors for peers // MARK: Generated accessors for peers
extension Profile { extension Tunnel {
@objc(addPeersObject:) @objc(addPeersObject:)
@NSManaged public func addToPeers(_ value: Peer) @NSManaged public func addToPeers(_ value: Peer)
@@ -1,5 +1,5 @@
// //
// ProfileConfigurationTableViewController.swift // TunnelConfigurationTableViewController.swift
// WireGuard // WireGuard
// //
// Created by Jeroen Leenarts on 24-05-18. // Created by Jeroen Leenarts on 24-05-18.
@@ -10,12 +10,12 @@ import UIKit
import CoreData import CoreData
import BNRCoreDataStack import BNRCoreDataStack
protocol ProfileConfigurationTableViewControllerDelegate: class { protocol TunnelConfigurationTableViewControllerDelegate: class {
} }
class ProfileConfigurationTableViewController: UITableViewController { class TunnelConfigurationTableViewController: UITableViewController {
var viewContext: NSManagedObjectContext! var viewContext: NSManagedObjectContext!
weak var delegate: ProfileConfigurationTableViewControllerDelegate? weak var delegate: TunnelConfigurationTableViewControllerDelegate?
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3 return 3
@@ -45,7 +45,7 @@ class AddPeerTableViewCell: UITableViewCell {
} }
extension ProfileConfigurationTableViewController: Identifyable {} extension TunnelConfigurationTableViewController: Identifyable {}
extension InterfaceTableViewCell: Identifyable {} extension InterfaceTableViewCell: Identifyable {}
extension PeerTableViewCell: Identifyable {} extension PeerTableViewCell: Identifyable {}
extension AddPeerTableViewCell: Identifyable {} extension AddPeerTableViewCell: Identifyable {}
@@ -1,5 +1,5 @@
// //
// ConnectionsTableViewController.swift // TunnelsTableViewController.swift
// WireGuard // WireGuard
// //
// Created by Jeroen Leenarts on 23-05-18. // Created by Jeroen Leenarts on 23-05-18.
@@ -11,30 +11,30 @@ import UIKit
import CoreData import CoreData
import BNRCoreDataStack import BNRCoreDataStack
protocol ConnectionsTableViewControllerDelegate: class { protocol TunnelsTableViewControllerDelegate: class {
func addProvider(connectionsTableViewController: ConnectionsTableViewController) func addProvider(tunnelsTableViewController: TunnelsTableViewController)
func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
} }
class ConnectionsTableViewController: UITableViewController { class TunnelsTableViewController: UITableViewController {
weak var delegate: ConnectionsTableViewControllerDelegate? weak var delegate: TunnelsTableViewControllerDelegate?
var viewContext: NSManagedObjectContext! var viewContext: NSManagedObjectContext!
private lazy var fetchedResultsController: FetchedResultsController<Profile> = { private lazy var fetchedResultsController: FetchedResultsController<Tunnel> = {
let fetchRequest = NSFetchRequest<Profile>() let fetchRequest = NSFetchRequest<Tunnel>()
fetchRequest.entity = Profile.entity() fetchRequest.entity = Tunnel.entity()
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)] fetchRequest.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)]
let frc = FetchedResultsController<Profile>(fetchRequest: fetchRequest, let frc = FetchedResultsController<Tunnel>(fetchRequest: fetchRequest,
managedObjectContext: viewContext) managedObjectContext: viewContext)
frc.setDelegate(self.frcDelegate) frc.setDelegate(self.frcDelegate)
return frc return frc
}() }()
private lazy var frcDelegate: ProfileFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate private lazy var frcDelegate: TunnelFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate
return ProfileFetchedResultsControllerDelegate(tableView: self.tableView) return TunnelFetchedResultsControllerDelegate(tableView: self.tableView)
}() }()
override func viewDidLoad() { override func viewDidLoad() {
@@ -47,7 +47,7 @@ class ConnectionsTableViewController: UITableViewController {
} }
@IBAction func addProvider(_ sender: Any) { @IBAction func addProvider(_ sender: Any) {
delegate?.addProvider(connectionsTableViewController: self) delegate?.addProvider(tunnelsTableViewController: self)
} }
override func numberOfSections(in tableView: UITableView) -> Int { override func numberOfSections(in tableView: UITableView) -> Int {
@@ -59,16 +59,16 @@ class ConnectionsTableViewController: UITableViewController {
} }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(type: ProfileTableViewCell.self, for: indexPath) let cell = tableView.dequeueReusableCell(type: TunnelTableViewCell.self, for: indexPath)
guard let sections = fetchedResultsController.sections else { guard let sections = fetchedResultsController.sections else {
fatalError("FetchedResultsController \(fetchedResultsController) should have sections, but found nil") fatalError("FetchedResultsController \(fetchedResultsController) should have sections, but found nil")
} }
let section = sections[indexPath.section] let section = sections[indexPath.section]
let profile = section.objects[indexPath.row] let tunnel = section.objects[indexPath.row]
cell.textLabel?.text = profile.title cell.textLabel?.text = tunnel.title
return cell return cell
} }
@@ -79,9 +79,9 @@ class ConnectionsTableViewController: UITableViewController {
} }
let section = sections[indexPath.section] let section = sections[indexPath.section]
let profile = section.objects[indexPath.row] let tunnel = section.objects[indexPath.row]
delegate?.connect(profile: profile, connectionsTableViewController: self) delegate?.connect(tunnel: tunnel, tunnelsTableViewController: self)
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
} }
@@ -92,9 +92,9 @@ class ConnectionsTableViewController: UITableViewController {
} }
let section = sections[indexPath.section] let section = sections[indexPath.section]
let profile = section.objects[indexPath.row] let tunnel = section.objects[indexPath.row]
delegate?.configure(profile: profile, connectionsTableViewController: self) delegate?.configure(tunnel: tunnel, tunnelsTableViewController: self)
} }
@@ -110,16 +110,16 @@ class ConnectionsTableViewController: UITableViewController {
} }
let section = sections[indexPath.section] let section = sections[indexPath.section]
let profile = section.objects[indexPath.row] let tunnel = section.objects[indexPath.row]
delegate?.delete(profile: profile, connectionsTableViewController: self) delegate?.delete(tunnel: tunnel, tunnelsTableViewController: self)
} }
} }
} }
extension ConnectionsTableViewController: Identifyable {} extension TunnelsTableViewController: Identifyable {}
class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate { class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate {
private weak var tableView: UITableView? private weak var tableView: UITableView?
@@ -128,19 +128,19 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle
self.tableView = tableView self.tableView = tableView
} }
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Profile>) { func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Tunnel>) {
tableView?.reloadData() tableView?.reloadData()
} }
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Profile>) { func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Tunnel>) {
tableView?.beginUpdates() tableView?.beginUpdates()
} }
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Profile>) { func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Tunnel>) {
tableView?.endUpdates() tableView?.endUpdates()
} }
func fetchedResultsController(_ controller: FetchedResultsController<Profile>, didChangeObject change: FetchedResultsObjectChange<Profile>) { func fetchedResultsController(_ controller: FetchedResultsController<Tunnel>, didChangeObject change: FetchedResultsObjectChange<Tunnel>) {
guard let tableView = tableView else { return } guard let tableView = tableView else { return }
switch change { switch change {
case let .insert(_, indexPath): case let .insert(_, indexPath):
@@ -157,7 +157,7 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle
} }
} }
func fetchedResultsController(_ controller: FetchedResultsController<Profile>, didChangeSection change: FetchedResultsSectionChange<Profile>) { func fetchedResultsController(_ controller: FetchedResultsController<Tunnel>, didChangeSection change: FetchedResultsSectionChange<Tunnel>) {
guard let tableView = tableView else { return } guard let tableView = tableView else { return }
switch change { switch change {
case let .insert(_, index): case let .insert(_, index):
@@ -169,8 +169,8 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle
} }
} }
class ProfileTableViewCell: UITableViewCell { class TunnelTableViewCell: UITableViewCell {
} }
extension ProfileTableViewCell: Identifyable {} extension TunnelTableViewCell: Identifyable {}
+16 -16
View File
@@ -8,9 +8,9 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 861983CAE8FDC13BC83E7E04 /* Pods_WireGuard.framework */; }; 48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 861983CAE8FDC13BC83E7E04 /* Pods_WireGuard.framework */; };
4A4BA6D820B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */; }; 4A4BA6D820B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */; };
4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */; }; 4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */; };
4A4BACE820B5F1BF00F12B28 /* ConnectionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */; }; 4A4BACE820B5F1BF00F12B28 /* TunnelsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */; };
4A4BACEB20B5F1BF00F12B28 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACE920B5F1BF00F12B28 /* Main.storyboard */; }; 4A4BACEB20B5F1BF00F12B28 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACE920B5F1BF00F12B28 /* Main.storyboard */; };
4A4BACED20B5F1C100F12B28 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */; }; 4A4BACED20B5F1C100F12B28 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */; };
4A4BACF020B5F1C100F12B28 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEE20B5F1C100F12B28 /* LaunchScreen.storyboard */; }; 4A4BACF020B5F1C100F12B28 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEE20B5F1C100F12B28 /* LaunchScreen.storyboard */; };
@@ -21,8 +21,8 @@
4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */; }; 4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */; };
4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */; }; 4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */; };
4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */; }; 4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */; };
4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */; }; 4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */; };
4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */; }; 4A4BAD1B20B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */; };
4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */; }; 4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */; };
4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */; }; 4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */; };
4A4BAD2220B6026900F12B28 /* Interface+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */; }; 4A4BAD2220B6026900F12B28 /* Interface+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */; };
@@ -45,10 +45,10 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
0CE52E030FAA93F3BF5747B2 /* Pods-WireGuard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.release.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.release.xcconfig"; sourceTree = "<group>"; }; 0CE52E030FAA93F3BF5747B2 /* Pods-WireGuard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.release.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.release.xcconfig"; sourceTree = "<group>"; };
25E2BE31A33C8CCE6E79B6EF /* Pods-WireGuard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.debug.xcconfig"; sourceTree = "<group>"; }; 25E2BE31A33C8CCE6E79B6EF /* Pods-WireGuard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.debug.xcconfig"; sourceTree = "<group>"; };
4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileConfigurationTableViewController.swift; sourceTree = "<group>"; }; 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelConfigurationTableViewController.swift; sourceTree = "<group>"; };
4A4BACE220B5F1BF00F12B28 /* WireGuard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WireGuard.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4A4BACE220B5F1BF00F12B28 /* WireGuard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WireGuard.app; sourceTree = BUILT_PRODUCTS_DIR; };
4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionsTableViewController.swift; sourceTree = "<group>"; }; 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelsTableViewController.swift; sourceTree = "<group>"; };
4A4BACEA20B5F1BF00F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 4A4BACEA20B5F1BF00F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4A4BACEF20B5F1C100F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 4A4BACEF20B5F1C100F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -62,8 +62,8 @@
4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootCoordinator.swift; sourceTree = "<group>"; }; 4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootCoordinator.swift; sourceTree = "<group>"; };
4A4BAD1220B5F82400F12B28 /* Identifyable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifyable.swift; sourceTree = "<group>"; }; 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifyable.swift; sourceTree = "<group>"; };
4A4BAD1620B5F8DE00F12B28 /* WireGuard.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WireGuard.xcdatamodel; sourceTree = "<group>"; }; 4A4BAD1620B5F8DE00F12B28 /* WireGuard.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WireGuard.xcdatamodel; sourceTree = "<group>"; };
4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataClass.swift"; sourceTree = "<group>"; }; 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+CoreDataClass.swift"; sourceTree = "<group>"; };
4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataProperties.swift"; sourceTree = "<group>"; }; 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+CoreDataProperties.swift"; sourceTree = "<group>"; };
4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataProperties.swift"; sourceTree = "<absolute>"; }; 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataProperties.swift"; sourceTree = "<absolute>"; };
4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataClass.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataClass.swift"; sourceTree = "<absolute>"; }; 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataClass.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataClass.swift"; sourceTree = "<absolute>"; };
4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Interface+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Interface+CoreDataProperties.swift"; sourceTree = "<absolute>"; }; 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Interface+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Interface+CoreDataProperties.swift"; sourceTree = "<absolute>"; };
@@ -164,8 +164,8 @@
children = ( children = (
4A4BAD1220B5F82400F12B28 /* Identifyable.swift */, 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */,
4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */, 4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */,
4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */, 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */,
4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */, 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */,
); );
path = ViewControllers; path = ViewControllers;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -179,8 +179,8 @@
4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */, 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */,
4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */, 4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */,
4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */, 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */,
4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */, 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */,
4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */, 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */,
4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */, 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */,
); );
path = Models; path = Models;
@@ -400,17 +400,17 @@
4A7F6EDE20B674CD00B260B7 /* Address+CoreDataProperties.swift in Sources */, 4A7F6EDE20B674CD00B260B7 /* Address+CoreDataProperties.swift in Sources */,
4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */, 4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */,
4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */, 4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */,
4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */, 4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */,
4A4BACE820B5F1BF00F12B28 /* ConnectionsTableViewController.swift in Sources */, 4A4BACE820B5F1BF00F12B28 /* TunnelsTableViewController.swift in Sources */,
4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */, 4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */,
4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */, 4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */,
4A4BA6D820B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift in Sources */, 4A4BA6D820B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift in Sources */,
4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */, 4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */,
4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */, 4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */,
4A7F6EDD20B674CD00B260B7 /* Address+CoreDataClass.swift in Sources */, 4A7F6EDD20B674CD00B260B7 /* Address+CoreDataClass.swift in Sources */,
4A8AABD820B6A79100B6D8C1 /* UITableView+WireGuard.swift in Sources */, 4A8AABD820B6A79100B6D8C1 /* UITableView+WireGuard.swift in Sources */,
4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */, 4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */,
4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */, 4A4BAD1B20B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift in Sources */,
4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */, 4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
+26 -13
View File
@@ -11,19 +11,32 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--Profiles--> <!--Navigation Controller-->
<scene sceneID="1sx-zW-OnW">
<objects>
<navigationController storyboardIdentifier="UINavigationController" id="JOA-JU-iCW" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="GsQ-3q-wZr">
<rect key="frame" x="0.0" y="20" width="375" height="96"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cAJ-Ch-uyg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1403" y="201"/>
</scene>
<!--Tunnels-->
<scene sceneID="Tud-vM-cYZ"> <scene sceneID="Tud-vM-cYZ">
<objects> <objects>
<tableViewController storyboardIdentifier="ConnectionsTableViewController" id="kTU-BV-32R" customClass="ConnectionsTableViewController" customModule="WireGuard" customModuleProvider="target" sceneMemberID="viewController"> <tableViewController storyboardIdentifier="TunnelsTableViewController" id="kTU-BV-32R" customClass="TunnelsTableViewController" customModule="WireGuard" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="AJg-r0-KJH"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="AJg-r0-KJH">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="detailDisclosureButton" indentationWidth="10" reuseIdentifier="ProfileTableViewCell" textLabel="hzX-lc-GyT" style="IBUITableViewCellStyleDefault" id="fM3-cC-KPN" customClass="ProfileTableViewCell" customModule="WireGuard" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="detailDisclosureButton" indentationWidth="10" reuseIdentifier="TunnelTableViewCell" textLabel="hzX-lc-GyT" style="IBUITableViewCellStyleDefault" id="fM3-cC-KPN" customClass="TunnelTableViewCell" customModule="WireGuard" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="44"/> <rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fM3-cC-KPN" id="Rv6-XK-aK2" customClass="ProfileTableViewCell" customModule="WireGuard" customModuleProvider="target"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fM3-cC-KPN" id="Rv6-XK-aK2" customClass="TunnelTableViewCell" customModule="WireGuard" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="307" height="43.5"/> <rect key="frame" x="0.0" y="0.0" width="307" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
@@ -43,7 +56,7 @@
<outlet property="delegate" destination="kTU-BV-32R" id="b6T-ZR-cmO"/> <outlet property="delegate" destination="kTU-BV-32R" id="b6T-ZR-cmO"/>
</connections> </connections>
</tableView> </tableView>
<navigationItem key="navigationItem" title="Profiles" id="j0L-5U-jDs"> <navigationItem key="navigationItem" title="Tunnels" id="j0L-5U-jDs">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="h2H-H8-3Tn"> <barButtonItem key="rightBarButtonItem" systemItem="add" id="h2H-H8-3Tn">
<connections> <connections>
<action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/> <action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/>
@@ -56,10 +69,10 @@
</objects> </objects>
<point key="canvasLocation" x="34" y="154"/> <point key="canvasLocation" x="34" y="154"/>
</scene> </scene>
<!--Title--> <!--Tunnel settings-->
<scene sceneID="xV8-BW-4R7"> <scene sceneID="xV8-BW-4R7">
<objects> <objects>
<tableViewController storyboardIdentifier="ProfileConfigurationTableViewController" id="0VM-73-EPX" customClass="ProfileConfigurationTableViewController" customModule="WireGuard" customModuleProvider="target" sceneMemberID="viewController"> <tableViewController storyboardIdentifier="TunnelConfigurationTableViewController" id="0VM-73-EPX" customClass="TunnelConfigurationTableViewController" customModule="WireGuard" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="0Uy-k2-O3i"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="0Uy-k2-O3i">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -235,15 +248,15 @@
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AddPeerTableViewCell" id="RyR-s5-lBV" customClass="AddPeerTableViewCell" customModule="WireGuard" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AddPeerTableViewCell" rowHeight="60" id="RyR-s5-lBV" customClass="AddPeerTableViewCell" customModule="WireGuard" customModuleProvider="target">
<rect key="frame" x="0.0" y="396" width="375" height="44"/> <rect key="frame" x="0.0" y="396" width="375" height="60"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="RyR-s5-lBV" id="gPY-qW-fbd"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="RyR-s5-lBV" id="gPY-qW-fbd">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/> <rect key="frame" x="0.0" y="0.0" width="375" height="59.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fVu-Aa-9dn"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fVu-Aa-9dn">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/> <rect key="frame" x="0.0" y="0.0" width="375" height="59.5"/>
<state key="normal" title="Add peer"/> <state key="normal" title="Add peer"/>
</button> </button>
</subviews> </subviews>
@@ -256,7 +269,7 @@
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="PeerTableViewCell" rowHeight="308" id="gzz-88-0IG" customClass="PeerTableViewCell" customModule="WireGuard" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="PeerTableViewCell" rowHeight="308" id="gzz-88-0IG" customClass="PeerTableViewCell" customModule="WireGuard" customModuleProvider="target">
<rect key="frame" x="0.0" y="440" width="375" height="308"/> <rect key="frame" x="0.0" y="456" width="375" height="308"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="gzz-88-0IG" id="XA6-EM-5V9"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="gzz-88-0IG" id="XA6-EM-5V9">
<rect key="frame" x="0.0" y="0.0" width="375" height="307.5"/> <rect key="frame" x="0.0" y="0.0" width="375" height="307.5"/>
@@ -393,7 +406,7 @@
<outlet property="delegate" destination="0VM-73-EPX" id="oHt-UY-XIz"/> <outlet property="delegate" destination="0VM-73-EPX" id="oHt-UY-XIz"/>
</connections> </connections>
</tableView> </tableView>
<navigationItem key="navigationItem" title="Title" id="PPu-rX-T38"> <navigationItem key="navigationItem" title="Tunnel settings" id="PPu-rX-T38">
<barButtonItem key="rightBarButtonItem" systemItem="save" id="mft-1l-bWa"/> <barButtonItem key="rightBarButtonItem" systemItem="save" id="mft-1l-bWa"/>
</navigationItem> </navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
+30 -28
View File
@@ -11,6 +11,8 @@ import Foundation
import CoreData import CoreData
import BNRCoreDataStack import BNRCoreDataStack
extension UINavigationController: Identifyable {}
class AppCoordinator: RootViewCoordinator { class AppCoordinator: RootViewCoordinator {
let persistentContainer = NSPersistentContainer(name: "WireGuard") let persistentContainer = NSPersistentContainer(name: "WireGuard")
@@ -21,16 +23,16 @@ class AppCoordinator: RootViewCoordinator {
var childCoordinators: [Coordinator] = [] var childCoordinators: [Coordinator] = []
var rootViewController: UIViewController { var rootViewController: UIViewController {
return self.connectionsTableViewController return self.tunnelsTableViewController
} }
var connectionsTableViewController: ConnectionsTableViewController! var tunnelsTableViewController: TunnelsTableViewController!
/// Window to manage /// Window to manage
let window: UIWindow let window: UIWindow
let navigationController: UINavigationController = { let navigationController: UINavigationController = {
let navController = UINavigationController() let navController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(type: UINavigationController.self)
return navController return navController
}() }()
@@ -54,14 +56,14 @@ class AppCoordinator: RootViewCoordinator {
} else { } else {
DispatchQueue.main.async { DispatchQueue.main.async {
//start //start
if let connectionsTableViewController = self?.storyboard.instantiateViewController(type: ConnectionsTableViewController.self) { if let tunnelsTableViewController = self?.storyboard.instantiateViewController(type: TunnelsTableViewController.self) {
self?.connectionsTableViewController = connectionsTableViewController self?.tunnelsTableViewController = tunnelsTableViewController
self?.connectionsTableViewController.viewContext = self?.persistentContainer.viewContext self?.tunnelsTableViewController.viewContext = self?.persistentContainer.viewContext
self?.connectionsTableViewController.delegate = self self?.tunnelsTableViewController.delegate = self
self?.navigationController.viewControllers = [connectionsTableViewController] self?.navigationController.viewControllers = [tunnelsTableViewController]
do { do {
if let context = self?.persistentContainer.viewContext, try Profile.countInContext(context) == 0 { if let context = self?.persistentContainer.viewContext, try Tunnel.countInContext(context) == 0 {
print("No profiles ... yet") print("No tunnels ... yet")
} }
} catch { } catch {
self?.showError(error) self?.showError(error)
@@ -83,45 +85,45 @@ class AppCoordinator: RootViewCoordinator {
} }
} }
extension AppCoordinator: ConnectionsTableViewControllerDelegate { extension AppCoordinator: TunnelsTableViewControllerDelegate {
func addProvider(connectionsTableViewController: ConnectionsTableViewController) { func addProvider(tunnelsTableViewController: TunnelsTableViewController) {
let addContext = persistentContainer.newBackgroundContext() let addContext = persistentContainer.newBackgroundContext()
showProfileConfigurationViewController(profile: nil, context: addContext) showTunnelConfigurationViewController(tunnel: nil, context: addContext)
} }
func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
// TODO implement // TODO implement
print("connect profile \(profile)") print("connect tunnel \(tunnel)")
} }
func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
// TODO implement // TODO implement
print("configure profile \(profile)") print("configure tunnel \(tunnel)")
let editContext = persistentContainer.newBackgroundContext() let editContext = persistentContainer.newBackgroundContext()
var backgroundProfile: Profile? var backgroundTunnel: Tunnel?
editContext.performAndWait { editContext.performAndWait {
backgroundProfile = editContext.object(with: profile.objectID) as? Profile backgroundTunnel = editContext.object(with: tunnel.objectID) as? Tunnel
} }
showProfileConfigurationViewController(profile: backgroundProfile, context: editContext) showTunnelConfigurationViewController(tunnel: backgroundTunnel, context: editContext)
} }
func showProfileConfigurationViewController(profile: Profile?, context: NSManagedObjectContext) { func showTunnelConfigurationViewController(tunnel: Tunnel?, context: NSManagedObjectContext) {
let profileConfigurationViewController = storyboard.instantiateViewController(type: ProfileConfigurationTableViewController.self) let tunnelConfigurationViewController = storyboard.instantiateViewController(type: TunnelConfigurationTableViewController.self)
profileConfigurationViewController.viewContext = context tunnelConfigurationViewController.viewContext = context
profileConfigurationViewController.delegate = self tunnelConfigurationViewController.delegate = self
self.navigationController.pushViewController(profileConfigurationViewController, animated: true) self.navigationController.pushViewController(tunnelConfigurationViewController, animated: true)
} }
func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
// TODO implement // TODO implement
print("delete profile \(profile)") print("delete tunnel \(tunnel)")
} }
} }
extension AppCoordinator: ProfileConfigurationTableViewControllerDelegate { extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate {
} }
@@ -22,7 +22,7 @@ extension Interface {
@NSManaged public var mtu: Int32 @NSManaged public var mtu: Int32
@NSManaged public var dns: String? @NSManaged public var dns: String?
@NSManaged public var table: String? @NSManaged public var table: String?
@NSManaged public var profile: Profile? @NSManaged public var tunnel: Tunnel?
@NSManaged public var adresses: NSSet? @NSManaged public var adresses: NSSet?
} }
@@ -20,6 +20,6 @@ extension Peer {
@NSManaged public var allowedIPs: String? @NSManaged public var allowedIPs: String?
@NSManaged public var endpoint: String? @NSManaged public var endpoint: String?
@NSManaged public var persistentKeepalive: Int16 @NSManaged public var persistentKeepalive: Int16
@NSManaged public var profile: Profile? @NSManaged public var tunnel: Tunnel?
} }
@@ -12,7 +12,7 @@
<attribute name="privateKey" attributeType="String" syncable="YES"/> <attribute name="privateKey" attributeType="String" syncable="YES"/>
<attribute name="table" optional="YES" attributeType="String" syncable="YES"/> <attribute name="table" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="adresses" toMany="YES" deletionRule="Cascade" destinationEntity="Address" inverseName="interface" inverseEntity="Address" syncable="YES"/> <relationship name="adresses" toMany="YES" deletionRule="Cascade" destinationEntity="Address" inverseName="interface" inverseEntity="Address" syncable="YES"/>
<relationship name="profile" maxCount="1" deletionRule="Nullify" destinationEntity="Profile" inverseName="interface" inverseEntity="Profile" syncable="YES"/> <relationship name="tunnel" maxCount="1" deletionRule="Nullify" destinationEntity="Tunnel" inverseName="interface" inverseEntity="Tunnel" syncable="YES"/>
</entity> </entity>
<entity name="Peer" representedClassName="Peer" syncable="YES"> <entity name="Peer" representedClassName="Peer" syncable="YES">
<attribute name="allowedIPs" attributeType="String" syncable="YES"/> <attribute name="allowedIPs" attributeType="String" syncable="YES"/>
@@ -20,17 +20,17 @@
<attribute name="persistentKeepalive" attributeType="Integer 16" minValueString="0" maxValueString="65535" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> <attribute name="persistentKeepalive" attributeType="Integer 16" minValueString="0" maxValueString="65535" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="presharedKey" optional="YES" attributeType="String" syncable="YES"/> <attribute name="presharedKey" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="publicKey" attributeType="String" syncable="YES"/> <attribute name="publicKey" attributeType="String" syncable="YES"/>
<relationship name="profile" maxCount="1" deletionRule="Nullify" destinationEntity="Profile" inverseName="peers" inverseEntity="Profile" syncable="YES"/> <relationship name="tunnel" maxCount="1" deletionRule="Nullify" destinationEntity="Tunnel" inverseName="peers" inverseEntity="Tunnel" syncable="YES"/>
</entity> </entity>
<entity name="Profile" representedClassName="Profile" syncable="YES"> <entity name="Tunnel" representedClassName="Tunnel" syncable="YES">
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/> <attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="interface" maxCount="1" deletionRule="Cascade" destinationEntity="Interface" inverseName="profile" inverseEntity="Interface" syncable="YES"/> <relationship name="interface" maxCount="1" deletionRule="Cascade" destinationEntity="Interface" inverseName="tunnel" inverseEntity="Interface" syncable="YES"/>
<relationship name="peers" toMany="YES" minCount="1" deletionRule="Cascade" destinationEntity="Peer" inverseName="profile" inverseEntity="Peer" syncable="YES"/> <relationship name="peers" toMany="YES" minCount="1" deletionRule="Cascade" destinationEntity="Peer" inverseName="tunnel" inverseEntity="Peer" syncable="YES"/>
</entity> </entity>
<elements> <elements>
<element name="Interface" positionX="-54" positionY="-9" width="128" height="165"/> <element name="Address" positionX="0" positionY="0" width="0" height="0"/>
<element name="Peer" positionX="-36" positionY="9" width="128" height="135"/> <element name="Interface" positionX="0" positionY="0" width="0" height="0"/>
<element name="Profile" positionX="-63" positionY="-18" width="128" height="90"/> <element name="Peer" positionX="0" positionY="0" width="0" height="0"/>
<element name="Address" positionX="-54" positionY="45" width="128" height="75"/> <element name="Tunnel" positionX="0" positionY="0" width="0" height="0"/>
</elements> </elements>
</model> </model>