Move EndpointProtocol Codable to Core spec
This commit is contained in:
parent
ed6c3b6113
commit
3717136bd9
@ -576,22 +576,6 @@ extension TunnelKitProvider.Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension EndpointProtocol: Codable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
guard let proto = try EndpointProtocol(rawValue: container.decode(String.self)) else {
|
||||
throw TunnelKitProvider.ProviderConfigurationError.parameter(name: "endpointProtocol.decodable")
|
||||
}
|
||||
self.init(proto.socketType, proto.port)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
try container.encode(rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public extension UserDefaults {
|
||||
@objc var dataCountArray: [Int]? {
|
||||
|
@ -480,3 +480,19 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||
return "addr \(address.maskedDescription)/\(addressPrefixLength) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })"
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension EndpointProtocol: Codable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
guard let proto = try EndpointProtocol(rawValue: container.decode(String.self)) else {
|
||||
throw ConfigurationError.malformed(option: "remote/proto")
|
||||
}
|
||||
self.init(proto.socketType, proto.port)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
try container.encode(rawValue)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user