Skip to content

Commit e17d494

Browse files
committed
Merge branch 'add-shadowsocks-fields-to-relay-list-response-from-the-api-ios-713'
2 parents 850bb7b + dc72b5d commit e17d494

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

ios/MullvadREST/ApiHandlers/ServerRelaysResponse.swift

+14-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extension REST {
6262
public let publicKey: Data
6363
public let includeInCountry: Bool
6464
public let daita: Bool?
65+
public let shadowsocksExtraAddrIn: [String]?
6566

6667
public func override(ipv4AddrIn: IPv4Address?, ipv6AddrIn: IPv6Address?) -> Self {
6768
return ServerRelay(
@@ -75,7 +76,8 @@ extension REST {
7576
ipv6AddrIn: ipv6AddrIn ?? self.ipv6AddrIn,
7677
publicKey: publicKey,
7778
includeInCountry: includeInCountry,
78-
daita: daita
79+
daita: daita,
80+
shadowsocksExtraAddrIn: shadowsocksExtraAddrIn
7981
)
8082
}
8183

@@ -91,7 +93,8 @@ extension REST {
9193
ipv6AddrIn: ipv6AddrIn,
9294
publicKey: publicKey,
9395
includeInCountry: includeInCountry,
94-
daita: daita
96+
daita: daita,
97+
shadowsocksExtraAddrIn: shadowsocksExtraAddrIn
9598
)
9699
}
97100
}
@@ -101,12 +104,20 @@ extension REST {
101104
public let ipv6Gateway: IPv6Address
102105
public let portRanges: [[UInt16]]
103106
public let relays: [ServerRelay]
107+
public let shadowsocksPortRanges: [[UInt16]]
104108

105-
public init(ipv4Gateway: IPv4Address, ipv6Gateway: IPv6Address, portRanges: [[UInt16]], relays: [ServerRelay]) {
109+
public init(
110+
ipv4Gateway: IPv4Address,
111+
ipv6Gateway: IPv6Address,
112+
portRanges: [[UInt16]],
113+
relays: [ServerRelay],
114+
shadowsocksPortRanges: [[UInt16]]
115+
) {
106116
self.ipv4Gateway = ipv4Gateway
107117
self.ipv6Gateway = ipv6Gateway
108118
self.portRanges = portRanges
109119
self.relays = relays
120+
self.shadowsocksPortRanges = shadowsocksPortRanges
110121
}
111122
}
112123

ios/MullvadREST/Relay/IPOverrideWrapper.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public class IPOverrideWrapper: RelayCacheProtocol {
5858
ipv4Gateway: wireguard.ipv4Gateway,
5959
ipv6Gateway: wireguard.ipv6Gateway,
6060
portRanges: wireguard.portRanges,
61-
relays: overridenWireguardRelays
61+
relays: overridenWireguardRelays,
62+
shadowsocksPortRanges: wireguard.shadowsocksPortRanges
6263
),
6364
bridge: REST.ServerBridges(
6465
shadowsocks: bridge.shadowsocks,

ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ final class RelayCacheTracker: RelayCacheTrackerProtocol {
110110
cachedRelays.relays.wireguard.ipv4Gateway,
111111
ipv6Gateway: cachedRelays.relays.wireguard.ipv6Gateway,
112112
portRanges: cachedRelays.relays.wireguard.portRanges,
113-
relays: cachedRelaysWithFixedDaita
113+
relays: cachedRelaysWithFixedDaita,
114+
shadowsocksPortRanges: cachedRelays.relays.wireguard.shadowsocksPortRanges
114115
)
115116

116117
let updatedRelays = REST.ServerRelaysResponse(

ios/MullvadVPN/View controllers/Settings/SettingsInteractor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class SettingsInteractor {
5454
} catch let error as NoRelaysSatisfyingConstraintsError where error.reason == .noDaitaRelaysFound {
5555
// Return error if no relays could be selected due to DAITA constraints.
5656
compatibilityError = tunnelSettings.tunnelMultihopState.isEnabled ? .multihop : .singlehop
57-
} catch let error as NoRelaysSatisfyingConstraintsError {
57+
} catch _ as NoRelaysSatisfyingConstraintsError {
5858
// Even if the constraints error is not DAITA specific, if both DAITA and Direct only are enabled,
5959
// we should return a DAITA related error since the current settings would have resulted in the
6060
// relay selector not being able to select a DAITA relay anyway.

ios/MullvadVPNTests/MullvadREST/ApiHandlers/ServerRelaysResponse+Stubs.swift

+16-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ enum ServerRelaysResponseStubs {
8686
ipv6AddrIn: .loopback,
8787
publicKey: PrivateKey().publicKey.rawValue,
8888
includeInCountry: true,
89-
daita: true
89+
daita: true,
90+
shadowsocksExtraAddrIn: nil
9091
),
9192
REST.ServerRelay(
9293
hostname: "se10-wireguard",
@@ -99,7 +100,8 @@ enum ServerRelaysResponseStubs {
99100
ipv6AddrIn: .loopback,
100101
publicKey: PrivateKey().publicKey.rawValue,
101102
includeInCountry: true,
102-
daita: false
103+
daita: false,
104+
shadowsocksExtraAddrIn: nil
103105
),
104106
REST.ServerRelay(
105107
hostname: "se2-wireguard",
@@ -112,7 +114,8 @@ enum ServerRelaysResponseStubs {
112114
ipv6AddrIn: .loopback,
113115
publicKey: PrivateKey().publicKey.rawValue,
114116
includeInCountry: true,
115-
daita: false
117+
daita: false,
118+
shadowsocksExtraAddrIn: nil
116119
),
117120
REST.ServerRelay(
118121
hostname: "se6-wireguard",
@@ -125,7 +128,8 @@ enum ServerRelaysResponseStubs {
125128
ipv6AddrIn: .loopback,
126129
publicKey: PrivateKey().publicKey.rawValue,
127130
includeInCountry: true,
128-
daita: false
131+
daita: false,
132+
shadowsocksExtraAddrIn: nil
129133
),
130134
REST.ServerRelay(
131135
hostname: "us-dal-wg-001",
@@ -138,7 +142,8 @@ enum ServerRelaysResponseStubs {
138142
ipv6AddrIn: .loopback,
139143
publicKey: PrivateKey().publicKey.rawValue,
140144
includeInCountry: true,
141-
daita: true
145+
daita: true,
146+
shadowsocksExtraAddrIn: nil
142147
),
143148
REST.ServerRelay(
144149
hostname: "us-nyc-wg-301",
@@ -151,7 +156,8 @@ enum ServerRelaysResponseStubs {
151156
ipv6AddrIn: .loopback,
152157
publicKey: PrivateKey().publicKey.rawValue,
153158
includeInCountry: true,
154-
daita: true
159+
daita: true,
160+
shadowsocksExtraAddrIn: nil
155161
),
156162
REST.ServerRelay(
157163
hostname: "us-nyc-wg-302",
@@ -164,9 +170,11 @@ enum ServerRelaysResponseStubs {
164170
ipv6AddrIn: .loopback,
165171
publicKey: PrivateKey().publicKey.rawValue,
166172
includeInCountry: true,
167-
daita: true
173+
daita: true,
174+
shadowsocksExtraAddrIn: nil
168175
),
169-
]
176+
],
177+
shadowsocksPortRanges: []
170178
),
171179
bridge: REST.ServerBridges(shadowsocks: [
172180
REST.ServerShadowsocks(protocol: "tcp", port: 443, cipher: "aes-256-gcm", password: "mullvad"),

ios/MullvadVPNTests/MullvadREST/Relay/RelayCacheTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ extension REST.ServerRelaysResponse {
5050
ipv4Gateway: .loopback,
5151
ipv6Gateway: .loopback,
5252
portRanges: [],
53-
relays: serverRelays
53+
relays: serverRelays,
54+
shadowsocksPortRanges: []
5455
),
5556
bridge: REST.ServerBridges(shadowsocks: [], relays: bridgeRelays)
5657
)

ios/MullvadVPNTests/MullvadREST/Relay/RelaySelectorTests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,11 @@ extension RelaySelectorTests {
338338
ipv6AddrIn: .loopback,
339339
publicKey: PrivateKey().publicKey.rawValue,
340340
includeInCountry: true,
341-
daita: true
341+
daita: true,
342+
shadowsocksExtraAddrIn: nil
342343
),
343-
]
344+
],
345+
shadowsocksPortRanges: []
344346
),
345347
bridge: REST.ServerBridges(shadowsocks: [], relays: [])
346348
)

ios/MullvadVPNTests/MullvadSettings/IPOverrideWrapperTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ extension IPOverrideWrapperTests {
8484
ipv6AddrIn: .any,
8585
publicKey: Data(),
8686
includeInCountry: true,
87-
daita: false
87+
daita: false,
88+
shadowsocksExtraAddrIn: nil
8889
)
8990
}
9091

0 commit comments

Comments
 (0)