Add tunnel provider identifier.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts 2018-08-08 06:59:56 +02:00
parent 762618ee5a
commit 2b7aa04d40
4 changed files with 5 additions and 1 deletions

View File

@ -16,6 +16,7 @@ extension Tunnel {
return NSFetchRequest<Tunnel>(entityName: "Tunnel")
}
@NSManaged public var tunnelIdentifier: String?
@NSManaged public var title: String?
@NSManaged public var interface: Interface?
@NSManaged public var peers: NSOrderedSet?

View File

@ -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)

View File

@ -17,12 +17,13 @@
</entity>
<entity name="Tunnel" representedClassName="Tunnel" syncable="YES">
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="tunnelIdentifier" attributeType="String" syncable="YES"/>
<relationship name="interface" maxCount="1" deletionRule="Cascade" destinationEntity="Interface" inverseName="tunnel" inverseEntity="Interface" syncable="YES"/>
<relationship name="peers" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="Peer" inverseName="tunnel" inverseEntity="Peer" syncable="YES"/>
</entity>
<elements>
<element name="Interface" positionX="-54" positionY="-9" width="128" height="120"/>
<element name="Peer" positionX="-36" positionY="9" width="128" height="135"/>
<element name="Tunnel" positionX="160" positionY="192" width="128" height="90"/>
<element name="Tunnel" positionX="160" positionY="192" width="128" height="105"/>
</elements>
</model>

View File

@ -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)