From c5237d534270821cbe426693497cf19e99e16022 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Wed, 23 May 2018 22:13:09 +0200 Subject: [PATCH] Add data model. Signed-off-by: Jason A. Donenfeld --- Wireguard.xcodeproj/project.pbxproj | 16 ++++++++++++ .../Models/Interface+CoreDataClass.swift | 15 +++++++++++ .../Models/Interface+CoreDataProperties.swift | 23 +++++++++++++++++ Wireguard/Models/Peer+CoreDataClass.swift | 15 +++++++++++ .../Models/Peer+CoreDataProperties.swift | 25 +++++++++++++++++++ .../Models/Profile+CoreDataProperties.swift | 22 ++++++++++++++++ .../Wireguard.xcdatamodel/contents | 24 ++++++++++++++++-- 7 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 Wireguard/Models/Interface+CoreDataClass.swift create mode 100644 Wireguard/Models/Interface+CoreDataProperties.swift create mode 100644 Wireguard/Models/Peer+CoreDataClass.swift create mode 100644 Wireguard/Models/Peer+CoreDataProperties.swift diff --git a/Wireguard.xcodeproj/project.pbxproj b/Wireguard.xcodeproj/project.pbxproj index 349e152..b93ea62 100644 --- a/Wireguard.xcodeproj/project.pbxproj +++ b/Wireguard.xcodeproj/project.pbxproj @@ -21,6 +21,10 @@ 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 */; }; + 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 */; }; + 4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */; }; DA734B3636730B94E9C22F47 /* Pods_Wireguard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8BF50C7EC60CD91BBA05E51F /* Pods_Wireguard.framework */; }; /* End PBXBuildFile section */ @@ -53,6 +57,10 @@ 4A4BAD1620B5F8DE00F12B28 /* Wireguard.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Wireguard.xcdatamodel; sourceTree = ""; }; 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataClass.swift"; sourceTree = ""; }; 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataProperties.swift"; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Interface+CoreDataClass.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Interface+CoreDataClass.swift"; sourceTree = ""; }; 82069F3AE97A82448F990CFB /* 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 = ""; }; 8BF50C7EC60CD91BBA05E51F /* Pods_Wireguard.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Wireguard.framework; sourceTree = BUILT_PRODUCTS_DIR; }; FB0ABC1036F5A16B24286D3C /* 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 = ""; }; @@ -152,6 +160,10 @@ 4A4BAD1420B5F8C000F12B28 /* Models */ = { isa = PBXGroup; children = ( + 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */, + 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */, + 4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */, + 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */, 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */, 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */, 4A4BAD1520B5F8DE00F12B28 /* Wireguard.xcdatamodeld */, @@ -366,12 +378,16 @@ buildActionMask = 2147483647; files = ( 4A4BAD0C20B5F6AA00F12B28 /* AppCoordinator.swift in Sources */, + 4A4BAD2220B6026900F12B28 /* Interface+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 */, 4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */, 4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */, + 4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */, + 4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */, + 4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */, 4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */, 4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */, ); diff --git a/Wireguard/Models/Interface+CoreDataClass.swift b/Wireguard/Models/Interface+CoreDataClass.swift new file mode 100644 index 0000000..fdedba0 --- /dev/null +++ b/Wireguard/Models/Interface+CoreDataClass.swift @@ -0,0 +1,15 @@ +// +// Interface+CoreDataClass.swift +// +// +// Created by Jeroen Leenarts on 23-05-18. +// +// + +import Foundation +import CoreData + +@objc(Interface) +public class Interface: NSManagedObject { + +} diff --git a/Wireguard/Models/Interface+CoreDataProperties.swift b/Wireguard/Models/Interface+CoreDataProperties.swift new file mode 100644 index 0000000..3372838 --- /dev/null +++ b/Wireguard/Models/Interface+CoreDataProperties.swift @@ -0,0 +1,23 @@ +// +// Interface+CoreDataProperties.swift +// +// +// Created by Jeroen Leenarts on 23-05-18. +// +// + +import Foundation +import CoreData + +extension Interface { + + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "Interface") + } + + @NSManaged public var privateKey: String? + @NSManaged public var listenPort: Int16 + @NSManaged public var fwMark: Int32 + @NSManaged public var profile: Profile? + +} diff --git a/Wireguard/Models/Peer+CoreDataClass.swift b/Wireguard/Models/Peer+CoreDataClass.swift new file mode 100644 index 0000000..1cd36a3 --- /dev/null +++ b/Wireguard/Models/Peer+CoreDataClass.swift @@ -0,0 +1,15 @@ +// +// Peer+CoreDataClass.swift +// +// +// Created by Jeroen Leenarts on 23-05-18. +// +// + +import Foundation +import CoreData + +@objc(Peer) +public class Peer: NSManagedObject { + +} diff --git a/Wireguard/Models/Peer+CoreDataProperties.swift b/Wireguard/Models/Peer+CoreDataProperties.swift new file mode 100644 index 0000000..809c7fe --- /dev/null +++ b/Wireguard/Models/Peer+CoreDataProperties.swift @@ -0,0 +1,25 @@ +// +// Peer+CoreDataProperties.swift +// +// +// Created by Jeroen Leenarts on 23-05-18. +// +// + +import Foundation +import CoreData + +extension Peer { + + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "Peer") + } + + @NSManaged public var publicKey: String? + @NSManaged public var presharedKey: String? + @NSManaged public var allowedIPs: String? + @NSManaged public var endpoint: String? + @NSManaged public var persistentKeepalive: Int16 + @NSManaged public var profile: Profile? + +} diff --git a/Wireguard/Models/Profile+CoreDataProperties.swift b/Wireguard/Models/Profile+CoreDataProperties.swift index 8e99ac2..8f8fb9a 100644 --- a/Wireguard/Models/Profile+CoreDataProperties.swift +++ b/Wireguard/Models/Profile+CoreDataProperties.swift @@ -10,10 +10,32 @@ import Foundation import CoreData + extension Profile { @nonobjc public class func fetchRequest() -> NSFetchRequest { return NSFetchRequest(entityName: "Profile") } + @NSManaged public var title: String? + @NSManaged public var peers: NSSet? + @NSManaged public var interface: Interface? + +} + +// MARK: Generated accessors for peers +extension Profile { + + @objc(addPeersObject:) + @NSManaged public func addToPeers(_ value: Peer) + + @objc(removePeersObject:) + @NSManaged public func removeFromPeers(_ value: Peer) + + @objc(addPeers:) + @NSManaged public func addToPeers(_ values: NSSet) + + @objc(removePeers:) + @NSManaged public func removeFromPeers(_ values: NSSet) + } diff --git a/Wireguard/Models/Wireguard.xcdatamodeld/Wireguard.xcdatamodel/contents b/Wireguard/Models/Wireguard.xcdatamodeld/Wireguard.xcdatamodel/contents index 7bced00..2aefa8d 100644 --- a/Wireguard/Models/Wireguard.xcdatamodeld/Wireguard.xcdatamodel/contents +++ b/Wireguard/Models/Wireguard.xcdatamodeld/Wireguard.xcdatamodel/contents @@ -1,7 +1,27 @@ - + + + + + + + + + + + + + + + + + + + - + + + \ No newline at end of file