From 2b7aa04d403f0d8277f0ff5422c3f07249c424b9 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Wed, 8 Aug 2018 06:59:56 +0200 Subject: [PATCH] Add tunnel provider identifier. Signed-off-by: Jason A. Donenfeld --- WireGuard/Models/Tunnel+CoreDataProperties.swift | 1 + WireGuard/Models/Tunnel+Extension.swift | 1 + .../WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents | 3 ++- .../TunnelConfigurationTableViewController.swift | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/WireGuard/Models/Tunnel+CoreDataProperties.swift b/WireGuard/Models/Tunnel+CoreDataProperties.swift index 1bea5a0..acbb1f9 100644 --- a/WireGuard/Models/Tunnel+CoreDataProperties.swift +++ b/WireGuard/Models/Tunnel+CoreDataProperties.swift @@ -16,6 +16,7 @@ extension Tunnel { return NSFetchRequest(entityName: "Tunnel") } + @NSManaged public var tunnelIdentifier: String? @NSManaged public var title: String? @NSManaged public var interface: Interface? @NSManaged public var peers: NSOrderedSet? diff --git a/WireGuard/Models/Tunnel+Extension.swift b/WireGuard/Models/Tunnel+Extension.swift index bd025cc..359a831 100644 --- a/WireGuard/Models/Tunnel+Extension.swift +++ b/WireGuard/Models/Tunnel+Extension.swift @@ -13,6 +13,7 @@ extension Tunnel { var providerConfiguration = [String: Any]() providerConfiguration["title"] = self.title + providerConfiguration["tunnelIdentifier"] = self.tunnelIdentifier var settingsString = "replace_peers=true\n" if let interface = interface { settingsString += generateInterfaceProviderConfiguration(interface) diff --git a/WireGuard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents b/WireGuard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents index 48e9027..d888fa1 100644 --- a/WireGuard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents +++ b/WireGuard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents @@ -17,12 +17,13 @@ + - + \ No newline at end of file diff --git a/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift b/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift index 5513e75..f761495 100644 --- a/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift +++ b/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift @@ -35,6 +35,7 @@ class TunnelConfigurationTableViewController: UITableViewController { viewContext.performAndWait { tunnel = Tunnel(context: viewContext) + tunnel.tunnelIdentifier = UUID().uuidString let peer = Peer(context: viewContext) peer.allowedIPs = "0.0.0.0/0, ::/0" tunnel.addToPeers(peer)