Everything is a tunnel.
This commit is contained in:
parent
6f59c27220
commit
1c43581ce5
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Profile+CoreDataClass.swift
|
||||
// Tunnel+CoreDataClass.swift
|
||||
// WireGuard
|
||||
//
|
||||
// Created by Jeroen Leenarts on 23-05-18.
|
||||
|
@ -10,7 +10,7 @@
|
|||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(Profile)
|
||||
public class Profile: NSManagedObject {
|
||||
@objc(Tunnel)
|
||||
public class Tunnel: NSManagedObject {
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Profile+CoreDataProperties.swift
|
||||
// Tunnel+CoreDataProperties.swift
|
||||
// WireGuard
|
||||
//
|
||||
// Created by Jeroen Leenarts on 23-05-18.
|
||||
|
@ -10,10 +10,10 @@
|
|||
import Foundation
|
||||
import CoreData
|
||||
|
||||
extension Profile {
|
||||
extension Tunnel {
|
||||
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Profile> {
|
||||
return NSFetchRequest<Profile>(entityName: "Profile")
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Tunnel> {
|
||||
return NSFetchRequest<Tunnel>(entityName: "Tunnel")
|
||||
}
|
||||
|
||||
@NSManaged public var title: String?
|
||||
|
@ -23,7 +23,7 @@ extension Profile {
|
|||
}
|
||||
|
||||
// MARK: Generated accessors for peers
|
||||
extension Profile {
|
||||
extension Tunnel {
|
||||
|
||||
@objc(addPeersObject:)
|
||||
@NSManaged public func addToPeers(_ value: Peer)
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ProfileConfigurationTableViewController.swift
|
||||
// TunnelConfigurationTableViewController.swift
|
||||
// WireGuard
|
||||
//
|
||||
// Created by Jeroen Leenarts on 24-05-18.
|
||||
|
@ -10,12 +10,12 @@ import UIKit
|
|||
import CoreData
|
||||
import BNRCoreDataStack
|
||||
|
||||
protocol ProfileConfigurationTableViewControllerDelegate: class {
|
||||
protocol TunnelConfigurationTableViewControllerDelegate: class {
|
||||
}
|
||||
|
||||
class ProfileConfigurationTableViewController: UITableViewController {
|
||||
class TunnelConfigurationTableViewController: UITableViewController {
|
||||
var viewContext: NSManagedObjectContext!
|
||||
weak var delegate: ProfileConfigurationTableViewControllerDelegate?
|
||||
weak var delegate: TunnelConfigurationTableViewControllerDelegate?
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 3
|
||||
|
@ -45,7 +45,7 @@ class AddPeerTableViewCell: UITableViewCell {
|
|||
|
||||
}
|
||||
|
||||
extension ProfileConfigurationTableViewController: Identifyable {}
|
||||
extension TunnelConfigurationTableViewController: Identifyable {}
|
||||
extension InterfaceTableViewCell: Identifyable {}
|
||||
extension PeerTableViewCell: Identifyable {}
|
||||
extension AddPeerTableViewCell: Identifyable {}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ConnectionsTableViewController.swift
|
||||
// TunnelsTableViewController.swift
|
||||
// WireGuard
|
||||
//
|
||||
// Created by Jeroen Leenarts on 23-05-18.
|
||||
|
@ -11,30 +11,30 @@ import UIKit
|
|||
import CoreData
|
||||
import BNRCoreDataStack
|
||||
|
||||
protocol ConnectionsTableViewControllerDelegate: class {
|
||||
func addProvider(connectionsTableViewController: ConnectionsTableViewController)
|
||||
func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController)
|
||||
func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController)
|
||||
func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController)
|
||||
protocol TunnelsTableViewControllerDelegate: class {
|
||||
func addProvider(tunnelsTableViewController: TunnelsTableViewController)
|
||||
func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
}
|
||||
|
||||
class ConnectionsTableViewController: UITableViewController {
|
||||
weak var delegate: ConnectionsTableViewControllerDelegate?
|
||||
class TunnelsTableViewController: UITableViewController {
|
||||
weak var delegate: TunnelsTableViewControllerDelegate?
|
||||
|
||||
var viewContext: NSManagedObjectContext!
|
||||
|
||||
private lazy var fetchedResultsController: FetchedResultsController<Profile> = {
|
||||
let fetchRequest = NSFetchRequest<Profile>()
|
||||
fetchRequest.entity = Profile.entity()
|
||||
private lazy var fetchedResultsController: FetchedResultsController<Tunnel> = {
|
||||
let fetchRequest = NSFetchRequest<Tunnel>()
|
||||
fetchRequest.entity = Tunnel.entity()
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)]
|
||||
let frc = FetchedResultsController<Profile>(fetchRequest: fetchRequest,
|
||||
let frc = FetchedResultsController<Tunnel>(fetchRequest: fetchRequest,
|
||||
managedObjectContext: viewContext)
|
||||
frc.setDelegate(self.frcDelegate)
|
||||
return frc
|
||||
}()
|
||||
|
||||
private lazy var frcDelegate: ProfileFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate
|
||||
return ProfileFetchedResultsControllerDelegate(tableView: self.tableView)
|
||||
private lazy var frcDelegate: TunnelFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate
|
||||
return TunnelFetchedResultsControllerDelegate(tableView: self.tableView)
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
@ -47,7 +47,7 @@ class ConnectionsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
@IBAction func addProvider(_ sender: Any) {
|
||||
delegate?.addProvider(connectionsTableViewController: self)
|
||||
delegate?.addProvider(tunnelsTableViewController: self)
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
|
@ -59,16 +59,16 @@ class ConnectionsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
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 {
|
||||
fatalError("FetchedResultsController \(fetchedResultsController) should have sections, but found nil")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ class ConnectionsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -92,9 +92,9 @@ class ConnectionsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
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 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?
|
||||
|
||||
|
@ -128,19 +128,19 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle
|
|||
self.tableView = tableView
|
||||
}
|
||||
|
||||
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Profile>) {
|
||||
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Tunnel>) {
|
||||
tableView?.reloadData()
|
||||
}
|
||||
|
||||
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Profile>) {
|
||||
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
||||
tableView?.beginUpdates()
|
||||
}
|
||||
|
||||
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Profile>) {
|
||||
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
||||
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 }
|
||||
switch change {
|
||||
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 }
|
||||
switch change {
|
||||
case let .insert(_, index):
|
||||
|
@ -169,8 +169,8 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle
|
|||
}
|
||||
}
|
||||
|
||||
class ProfileTableViewCell: UITableViewCell {
|
||||
class TunnelTableViewCell: UITableViewCell {
|
||||
|
||||
}
|
||||
|
||||
extension ProfileTableViewCell: Identifyable {}
|
||||
extension TunnelTableViewCell: Identifyable {}
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
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 */; };
|
||||
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 */; };
|
||||
4A4BACED20B5F1C100F12B28 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */; };
|
||||
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 */; };
|
||||
4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */; };
|
||||
4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */; };
|
||||
4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */; };
|
||||
4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */; };
|
||||
4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.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 */; };
|
||||
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 */; };
|
||||
|
@ -45,10 +45,10 @@
|
|||
/* 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>"; };
|
||||
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; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
|
@ -62,8 +62,8 @@
|
|||
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>"; };
|
||||
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>"; };
|
||||
4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataProperties.swift"; sourceTree = "<group>"; };
|
||||
4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+CoreDataClass.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>"; };
|
||||
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>"; };
|
||||
|
@ -164,8 +164,8 @@
|
|||
children = (
|
||||
4A4BAD1220B5F82400F12B28 /* Identifyable.swift */,
|
||||
4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */,
|
||||
4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */,
|
||||
4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */,
|
||||
4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */,
|
||||
4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */,
|
||||
);
|
||||
path = ViewControllers;
|
||||
sourceTree = "<group>";
|
||||
|
@ -179,8 +179,8 @@
|
|||
4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */,
|
||||
4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */,
|
||||
4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */,
|
||||
4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */,
|
||||
4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */,
|
||||
4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */,
|
||||
4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */,
|
||||
4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */,
|
||||
);
|
||||
path = Models;
|
||||
|
@ -400,17 +400,17 @@
|
|||
4A7F6EDE20B674CD00B260B7 /* Address+CoreDataProperties.swift in Sources */,
|
||||
4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */,
|
||||
4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */,
|
||||
4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */,
|
||||
4A4BACE820B5F1BF00F12B28 /* ConnectionsTableViewController.swift in Sources */,
|
||||
4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */,
|
||||
4A4BACE820B5F1BF00F12B28 /* TunnelsTableViewController.swift in Sources */,
|
||||
4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */,
|
||||
4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */,
|
||||
4A4BA6D820B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift in Sources */,
|
||||
4A4BA6D820B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift in Sources */,
|
||||
4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */,
|
||||
4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */,
|
||||
4A7F6EDD20B674CD00B260B7 /* Address+CoreDataClass.swift in Sources */,
|
||||
4A8AABD820B6A79100B6D8C1 /* UITableView+WireGuard.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 */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -11,19 +11,32 @@
|
|||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<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">
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<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"/>
|
||||
<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"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
|
@ -43,7 +56,7 @@
|
|||
<outlet property="delegate" destination="kTU-BV-32R" id="b6T-ZR-cmO"/>
|
||||
</connections>
|
||||
</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">
|
||||
<connections>
|
||||
<action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/>
|
||||
|
@ -56,10 +69,10 @@
|
|||
</objects>
|
||||
<point key="canvasLocation" x="34" y="154"/>
|
||||
</scene>
|
||||
<!--Title-->
|
||||
<!--Tunnel settings-->
|
||||
<scene sceneID="xV8-BW-4R7">
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
@ -235,15 +248,15 @@
|
|||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AddPeerTableViewCell" id="RyR-s5-lBV" customClass="AddPeerTableViewCell" customModule="WireGuard" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="396" width="375" height="44"/>
|
||||
<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="60"/>
|
||||
<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">
|
||||
<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"/>
|
||||
<subviews>
|
||||
<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"/>
|
||||
</button>
|
||||
</subviews>
|
||||
|
@ -256,7 +269,7 @@
|
|||
</tableViewCellContentView>
|
||||
</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">
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
@ -393,7 +406,7 @@
|
|||
<outlet property="delegate" destination="0VM-73-EPX" id="oHt-UY-XIz"/>
|
||||
</connections>
|
||||
</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"/>
|
||||
</navigationItem>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
|
|
|
@ -11,6 +11,8 @@ import Foundation
|
|||
import CoreData
|
||||
import BNRCoreDataStack
|
||||
|
||||
extension UINavigationController: Identifyable {}
|
||||
|
||||
class AppCoordinator: RootViewCoordinator {
|
||||
|
||||
let persistentContainer = NSPersistentContainer(name: "WireGuard")
|
||||
|
@ -21,16 +23,16 @@ class AppCoordinator: RootViewCoordinator {
|
|||
var childCoordinators: [Coordinator] = []
|
||||
|
||||
var rootViewController: UIViewController {
|
||||
return self.connectionsTableViewController
|
||||
return self.tunnelsTableViewController
|
||||
}
|
||||
|
||||
var connectionsTableViewController: ConnectionsTableViewController!
|
||||
var tunnelsTableViewController: TunnelsTableViewController!
|
||||
|
||||
/// Window to manage
|
||||
let window: UIWindow
|
||||
|
||||
let navigationController: UINavigationController = {
|
||||
let navController = UINavigationController()
|
||||
let navController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(type: UINavigationController.self)
|
||||
return navController
|
||||
}()
|
||||
|
||||
|
@ -54,14 +56,14 @@ class AppCoordinator: RootViewCoordinator {
|
|||
} else {
|
||||
DispatchQueue.main.async {
|
||||
//start
|
||||
if let connectionsTableViewController = self?.storyboard.instantiateViewController(type: ConnectionsTableViewController.self) {
|
||||
self?.connectionsTableViewController = connectionsTableViewController
|
||||
self?.connectionsTableViewController.viewContext = self?.persistentContainer.viewContext
|
||||
self?.connectionsTableViewController.delegate = self
|
||||
self?.navigationController.viewControllers = [connectionsTableViewController]
|
||||
if let tunnelsTableViewController = self?.storyboard.instantiateViewController(type: TunnelsTableViewController.self) {
|
||||
self?.tunnelsTableViewController = tunnelsTableViewController
|
||||
self?.tunnelsTableViewController.viewContext = self?.persistentContainer.viewContext
|
||||
self?.tunnelsTableViewController.delegate = self
|
||||
self?.navigationController.viewControllers = [tunnelsTableViewController]
|
||||
do {
|
||||
if let context = self?.persistentContainer.viewContext, try Profile.countInContext(context) == 0 {
|
||||
print("No profiles ... yet")
|
||||
if let context = self?.persistentContainer.viewContext, try Tunnel.countInContext(context) == 0 {
|
||||
print("No tunnels ... yet")
|
||||
}
|
||||
} catch {
|
||||
self?.showError(error)
|
||||
|
@ -83,45 +85,45 @@ class AppCoordinator: RootViewCoordinator {
|
|||
}
|
||||
}
|
||||
|
||||
extension AppCoordinator: ConnectionsTableViewControllerDelegate {
|
||||
func addProvider(connectionsTableViewController: ConnectionsTableViewController) {
|
||||
extension AppCoordinator: TunnelsTableViewControllerDelegate {
|
||||
func addProvider(tunnelsTableViewController: TunnelsTableViewController) {
|
||||
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
|
||||
print("connect profile \(profile)")
|
||||
print("connect tunnel \(tunnel)")
|
||||
}
|
||||
|
||||
func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) {
|
||||
func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
|
||||
// TODO implement
|
||||
print("configure profile \(profile)")
|
||||
print("configure tunnel \(tunnel)")
|
||||
let editContext = persistentContainer.newBackgroundContext()
|
||||
var backgroundProfile: Profile?
|
||||
var backgroundTunnel: Tunnel?
|
||||
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) {
|
||||
let profileConfigurationViewController = storyboard.instantiateViewController(type: ProfileConfigurationTableViewController.self)
|
||||
func showTunnelConfigurationViewController(tunnel: Tunnel?, context: NSManagedObjectContext) {
|
||||
let tunnelConfigurationViewController = storyboard.instantiateViewController(type: TunnelConfigurationTableViewController.self)
|
||||
|
||||
profileConfigurationViewController.viewContext = context
|
||||
profileConfigurationViewController.delegate = self
|
||||
tunnelConfigurationViewController.viewContext = context
|
||||
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
|
||||
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 dns: String?
|
||||
@NSManaged public var table: String?
|
||||
@NSManaged public var profile: Profile?
|
||||
@NSManaged public var tunnel: Tunnel?
|
||||
@NSManaged public var adresses: NSSet?
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ extension Peer {
|
|||
@NSManaged public var allowedIPs: String?
|
||||
@NSManaged public var endpoint: String?
|
||||
@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="table" optional="YES" attributeType="String" 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 name="Peer" representedClassName="Peer" 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="presharedKey" optional="YES" 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 name="Profile" representedClassName="Profile" syncable="YES">
|
||||
<entity name="Tunnel" representedClassName="Tunnel" 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="peers" toMany="YES" minCount="1" deletionRule="Cascade" destinationEntity="Peer" inverseName="profile" inverseEntity="Peer" 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="tunnel" inverseEntity="Peer" syncable="YES"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="Interface" positionX="-54" positionY="-9" width="128" height="165"/>
|
||||
<element name="Peer" positionX="-36" positionY="9" width="128" height="135"/>
|
||||
<element name="Profile" positionX="-63" positionY="-18" width="128" height="90"/>
|
||||
<element name="Address" positionX="-54" positionY="45" width="128" height="75"/>
|
||||
<element name="Address" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Interface" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Peer" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Tunnel" positionX="0" positionY="0" width="0" height="0"/>
|
||||
</elements>
|
||||
</model>
|
Loading…
Reference in New Issue