diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-08 13:56:50 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-08 13:56:50 +0530 |
commit | c88c660b516f4f8dd75944dc440b17a383c5154f (patch) | |
tree | 03595c3ff4b4c72c25e730cbd54ec89ecbb63596 /WireGuard/WireGuard/Model/Configuration.swift | |
parent | Tunnel edit: While preparing for reuse, should make onValueBeingEdited nil as well (diff) | |
download | wireguard-apple-c88c660b516f4f8dd75944dc440b17a383c5154f.tar.xz wireguard-apple-c88c660b516f4f8dd75944dc440b17a383c5154f.zip |
Move logic to extension: Move model files to Shared
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/Model/Configuration.swift')
-rw-r--r-- | WireGuard/WireGuard/Model/Configuration.swift | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/WireGuard/WireGuard/Model/Configuration.swift b/WireGuard/WireGuard/Model/Configuration.swift deleted file mode 100644 index 2df363b..0000000 --- a/WireGuard/WireGuard/Model/Configuration.swift +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright © 2018 WireGuard LLC. All Rights Reserved. - -import Foundation - -@available(OSX 10.14, iOS 12.0, *) -class TunnelConfiguration: Codable { - var interface: InterfaceConfiguration - var peers: [PeerConfiguration] = [] - init(interface: InterfaceConfiguration) { - self.interface = interface - } -} - -@available(OSX 10.14, iOS 12.0, *) -struct InterfaceConfiguration: Codable { - var name: String - var privateKey: Data - var addresses: [IPAddressRange] = [] - var listenPort: UInt16? - var mtu: UInt16? - var dns: [DNSServer] = [] - - var publicKey: Data { - return Curve25519.generatePublicKey(fromPrivateKey: privateKey) - } - - 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") } - } -} - -@available(OSX 10.14, iOS 12.0, *) -struct PeerConfiguration: Codable { - var publicKey: Data - var preSharedKey: Data? { - didSet(value) { - if let value = value { - if (value.count != 32) { fatalError("Invalid preshared key") } - } - } - } - var allowedIPs: [IPAddressRange] = [] - var endpoint: Endpoint? - var persistentKeepAlive: UInt16? - - init(publicKey: Data) { - self.publicKey = publicKey - if (publicKey.count != 32) { fatalError("Invalid public key") } - } -} |