aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model/PeerConfiguration.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/Shared/Model/PeerConfiguration.swift')
-rw-r--r--WireGuard/Shared/Model/PeerConfiguration.swift39
1 files changed, 0 insertions, 39 deletions
diff --git a/WireGuard/Shared/Model/PeerConfiguration.swift b/WireGuard/Shared/Model/PeerConfiguration.swift
index 0fad842a..a113821d 100644
--- a/WireGuard/Shared/Model/PeerConfiguration.swift
+++ b/WireGuard/Shared/Model/PeerConfiguration.swift
@@ -25,42 +25,3 @@ struct PeerConfiguration {
}
}
}
-
-extension PeerConfiguration: Codable {
- enum CodingKeys: String, CodingKey {
- case publicKey = "PublicKey"
- case preSharedKey = "PreSharedKey"
- case allowedIPs = "AllowedIPs"
- case endpoint = "Endpoint"
- case persistentKeepAlive = "PersistentKeepAlive"
- }
-
- init(from decoder: Decoder) throws {
- let values = try decoder.container(keyedBy: CodingKeys.self)
- publicKey = try Data(base64Encoded: values.decode(String.self, forKey: .publicKey))!
- if let base64PreSharedKey = try? values.decode(Data.self, forKey: .preSharedKey) {
- preSharedKey = Data(base64Encoded: base64PreSharedKey)
- } else {
- preSharedKey = nil
- }
- allowedIPs = try values.decode([IPAddressRange].self, forKey: .allowedIPs)
- endpoint = try? values.decode(Endpoint.self, forKey: .endpoint)
- persistentKeepAlive = try? values.decode(UInt16.self, forKey: .persistentKeepAlive)
- }
-
- func encode(to encoder: Encoder) throws {
- var container = encoder.container(keyedBy: CodingKeys.self)
- try container.encode(publicKey.base64EncodedString(), forKey: .publicKey)
- if let preSharedKey = preSharedKey {
- try container.encode(preSharedKey.base64EncodedString(), forKey: .preSharedKey)
- }
-
- try container.encode(allowedIPs, forKey: .allowedIPs)
- if let endpoint = endpoint {
- try container.encode(endpoint, forKey: .endpoint)
- }
- if let persistentKeepAlive = persistentKeepAlive {
- try container.encode(persistentKeepAlive, forKey: .persistentKeepAlive)
- }
- }
-}