-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathServerRelaysResponse.swift
107 lines (96 loc) · 3.27 KB
/
ServerRelaysResponse.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// ServerRelaysResponse.swift
// MullvadREST
//
// Created by pronebird on 27/07/2021.
// Copyright © 2021 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadTypes
import Network
extension REST {
public struct ServerLocation: Codable, Equatable {
public let country: String
public let city: String
public let latitude: Double
public let longitude: Double
public init(country: String, city: String, latitude: Double, longitude: Double) {
self.country = country
self.city = city
self.latitude = latitude
self.longitude = longitude
}
}
public struct BridgeRelay: Codable, Equatable {
public let hostname: String
public let active: Bool
public let owned: Bool
public let location: String
public let provider: String
public let ipv4AddrIn: IPv4Address
public let weight: UInt64
public let includeInCountry: Bool
public var daita: Bool?
public func override(ipv4AddrIn: IPv4Address?) -> Self {
return BridgeRelay(
hostname: hostname,
active: active,
owned: owned,
location: location,
provider: provider,
ipv4AddrIn: ipv4AddrIn ?? self.ipv4AddrIn,
weight: weight,
includeInCountry: includeInCountry
)
}
}
public struct ServerRelay: Codable, Equatable {
public let hostname: String
public let active: Bool
public let owned: Bool
public let location: String
public let provider: String
public let weight: UInt64
public let ipv4AddrIn: IPv4Address
public let ipv6AddrIn: IPv6Address
public let publicKey: Data
public let includeInCountry: Bool
public let daita: Bool?
public func override(ipv4AddrIn: IPv4Address?, ipv6AddrIn: IPv6Address?) -> Self {
return ServerRelay(
hostname: hostname,
active: active,
owned: owned,
location: location,
provider: provider,
weight: weight,
ipv4AddrIn: ipv4AddrIn ?? self.ipv4AddrIn,
ipv6AddrIn: ipv6AddrIn ?? self.ipv6AddrIn,
publicKey: publicKey,
includeInCountry: includeInCountry,
daita: daita
)
}
}
public struct ServerWireguardTunnels: Codable, Equatable {
public let ipv4Gateway: IPv4Address
public let ipv6Gateway: IPv6Address
public let portRanges: [[UInt16]]
public let relays: [ServerRelay]
}
public struct ServerShadowsocks: Codable, Equatable {
public let `protocol`: String
public let port: UInt16
public let cipher: String
public let password: String
}
public struct ServerBridges: Codable, Equatable {
public let shadowsocks: [ServerShadowsocks]
public let relays: [BridgeRelay]
}
public struct ServerRelaysResponse: Codable, Equatable {
public let locations: [String: ServerLocation]
public let wireguard: ServerWireguardTunnels
public let bridge: ServerBridges
}
}