Model: Name should be part of the interface, not the tunnel

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-17 16:11:22 +05:30
parent 6de354b4c5
commit 921b81e89b
2 changed files with 5 additions and 5 deletions

View File

@ -10,23 +10,23 @@ import Foundation
@available(OSX 10.14, iOS 12.0, *) @available(OSX 10.14, iOS 12.0, *)
class TunnelConfiguration: Codable { class TunnelConfiguration: Codable {
var name: String
let interface: InterfaceConfiguration let interface: InterfaceConfiguration
var peers: [PeerConfiguration] = [] var peers: [PeerConfiguration] = []
init(name: String, interface: InterfaceConfiguration) { init(interface: InterfaceConfiguration) {
self.name = name
self.interface = interface self.interface = interface
} }
} }
@available(OSX 10.14, iOS 12.0, *) @available(OSX 10.14, iOS 12.0, *)
class InterfaceConfiguration: Codable { class InterfaceConfiguration: Codable {
var name: String
var privateKey: Data var privateKey: Data
var addresses: [IPAddressRange] = [] var addresses: [IPAddressRange] = []
var listenPort: UInt64? = nil var listenPort: UInt64? = nil
var mtu: UInt64? = nil var mtu: UInt64? = nil
var dns: String? = nil var dns: String? = nil
init(privateKey: Data) { init(name: String, privateKey: Data) {
self.name = name
self.privateKey = privateKey self.privateKey = privateKey
} }
} }

View File

@ -13,7 +13,7 @@ class TunnelProviderManager {
var name: String var name: String
var tunnelConfiguration: TunnelConfiguration var tunnelConfiguration: TunnelConfiguration
init(tunnelConfiguration: TunnelConfiguration) { init(tunnelConfiguration: TunnelConfiguration) {
self.name = tunnelConfiguration.name self.name = tunnelConfiguration.interface.name
self.tunnelConfiguration = tunnelConfiguration self.tunnelConfiguration = tunnelConfiguration
} }
} }