providerConfiguration is now a WgQuickConfig
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user