diff options
| author | Jon Petersson <jon.petersson@kvadrat.se> | 2023-06-08 11:50:04 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2023-06-08 12:32:04 +0200 |
| commit | 1c31fcb96c52b05d8570c3377cc01667d1beb9f9 (patch) | |
| tree | 4025167bef31e927785b9bfd1d4ed00036c7f15e | |
| parent | 05c8a1f8fa425dbc0a144892ddc869fbe45cc48b (diff) | |
| download | mullvadvpn-1c31fcb96c52b05d8570c3377cc01667d1beb9f9.tar.xz mullvadvpn-1c31fcb96c52b05d8570c3377cc01667d1beb9f9.zip | |
Add custom deserialiser for RelayConstraints
| -rw-r--r-- | ios/MullvadTypes/RelayConstraints.swift | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ios/MullvadTypes/RelayConstraints.swift b/ios/MullvadTypes/RelayConstraints.swift index 22a84aea0e..9b32fdf16e 100644 --- a/ios/MullvadTypes/RelayConstraints.swift +++ b/ios/MullvadTypes/RelayConstraints.swift @@ -10,6 +10,8 @@ import Foundation public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible { public var location: RelayConstraint<RelayLocation> + + // Added in 2023.3 public var port: RelayConstraint<UInt16> public var debugDescription: String { @@ -23,4 +25,12 @@ public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible self.location = location self.port = port } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + location = try container.decode(RelayConstraint<RelayLocation>.self, forKey: .location) + + // Added in 2023.3 + port = try container.decodeIfPresent(RelayConstraint<UInt16>.self, forKey: .port) ?? .any + } } |
