Model: Allow creating an interface with empty name
But don't allow such a tunnel to be added to the tunnel manager. (We'll need to create an interface with an empty name when we're reading QR codes.) Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
1c8928c8a1
commit
1187657497
|
@ -28,7 +28,6 @@ struct InterfaceConfiguration: Codable {
|
|||
init(name: String, privateKey: Data) {
|
||||
self.name = name
|
||||
self.privateKey = privateKey
|
||||
if (name.isEmpty) { fatalError("Empty name") }
|
||||
if (privateKey.count != 32) { fatalError("Invalid private key") }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class TunnelViewModel {
|
|||
|
||||
func save() -> SaveResult<InterfaceConfiguration> {
|
||||
fieldsWithError.removeAll()
|
||||
guard let name = scratchpad[.name] else {
|
||||
guard let name = scratchpad[.name], (!name.isEmpty) else {
|
||||
fieldsWithError.insert(.name)
|
||||
return .error("Interface name is required")
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class TunnelsManager {
|
|||
}
|
||||
|
||||
func add(tunnelConfiguration: TunnelConfiguration, completionHandler: @escaping (TunnelContainer, Error?) -> Void) {
|
||||
assert(!tunnelConfiguration.interface.name.isEmpty)
|
||||
let tunnelProvider = TunnelProviderManager(tunnelConfiguration: tunnelConfiguration)
|
||||
for tunnel in tunnels {
|
||||
tunnel.index = tunnel.index + 1
|
||||
|
|
Loading…
Reference in New Issue