Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shadowsocks fields to relay list response from the API #7096

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions ios/MullvadREST/ApiHandlers/ServerRelaysResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extension REST {
public let publicKey: Data
public let includeInCountry: Bool
public let daita: Bool?
public let shadowsocksExtraAddrIn: [String]?

public func override(ipv4AddrIn: IPv4Address?, ipv6AddrIn: IPv6Address?) -> Self {
return ServerRelay(
Expand All @@ -75,7 +76,8 @@ extension REST {
ipv6AddrIn: ipv6AddrIn ?? self.ipv6AddrIn,
publicKey: publicKey,
includeInCountry: includeInCountry,
daita: daita
daita: daita,
shadowsocksExtraAddrIn: shadowsocksExtraAddrIn
)
}

Expand All @@ -91,7 +93,8 @@ extension REST {
ipv6AddrIn: ipv6AddrIn,
publicKey: publicKey,
includeInCountry: includeInCountry,
daita: daita
daita: daita,
shadowsocksExtraAddrIn: shadowsocksExtraAddrIn
)
}
}
Expand All @@ -101,12 +104,20 @@ extension REST {
public let ipv6Gateway: IPv6Address
public let portRanges: [[UInt16]]
public let relays: [ServerRelay]
public let shadowsocksPortRanges: [[UInt16]]

public init(ipv4Gateway: IPv4Address, ipv6Gateway: IPv6Address, portRanges: [[UInt16]], relays: [ServerRelay]) {
public init(
ipv4Gateway: IPv4Address,
ipv6Gateway: IPv6Address,
portRanges: [[UInt16]],
relays: [ServerRelay],
shadowsocksPortRanges: [[UInt16]]
) {
self.ipv4Gateway = ipv4Gateway
self.ipv6Gateway = ipv6Gateway
self.portRanges = portRanges
self.relays = relays
self.shadowsocksPortRanges = shadowsocksPortRanges
}
}

Expand Down
3 changes: 2 additions & 1 deletion ios/MullvadREST/Relay/IPOverrideWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class IPOverrideWrapper: RelayCacheProtocol {
ipv4Gateway: wireguard.ipv4Gateway,
ipv6Gateway: wireguard.ipv6Gateway,
portRanges: wireguard.portRanges,
relays: overridenWireguardRelays
relays: overridenWireguardRelays,
shadowsocksPortRanges: wireguard.shadowsocksPortRanges
),
bridge: REST.ServerBridges(
shadowsocks: bridge.shadowsocks,
Expand Down
3 changes: 2 additions & 1 deletion ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ final class RelayCacheTracker: RelayCacheTrackerProtocol {
cachedRelays.relays.wireguard.ipv4Gateway,
ipv6Gateway: cachedRelays.relays.wireguard.ipv6Gateway,
portRanges: cachedRelays.relays.wireguard.portRanges,
relays: cachedRelaysWithFixedDaita
relays: cachedRelaysWithFixedDaita,
shadowsocksPortRanges: cachedRelays.relays.wireguard.shadowsocksPortRanges
)

let updatedRelays = REST.ServerRelaysResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class SettingsInteractor {
} catch let error as NoRelaysSatisfyingConstraintsError where error.reason == .noDaitaRelaysFound {
// Return error if no relays could be selected due to DAITA constraints.
compatibilityError = tunnelSettings.tunnelMultihopState.isEnabled ? .multihop : .singlehop
} catch let error as NoRelaysSatisfyingConstraintsError {
} catch _ as NoRelaysSatisfyingConstraintsError {
// Even if the constraints error is not DAITA specific, if both DAITA and Direct only are enabled,
// we should return a DAITA related error since the current settings would have resulted in the
// relay selector not being able to select a DAITA relay anyway.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: true
daita: true,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "se10-wireguard",
Expand All @@ -99,7 +100,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: false
daita: false,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "se2-wireguard",
Expand All @@ -112,7 +114,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: false
daita: false,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "se6-wireguard",
Expand All @@ -125,7 +128,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: false
daita: false,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "us-dal-wg-001",
Expand All @@ -138,7 +142,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: true
daita: true,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "us-nyc-wg-301",
Expand All @@ -151,7 +156,8 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: true
daita: true,
shadowsocksExtraAddrIn: nil
),
REST.ServerRelay(
hostname: "us-nyc-wg-302",
Expand All @@ -164,9 +170,11 @@ enum ServerRelaysResponseStubs {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: true
daita: true,
shadowsocksExtraAddrIn: nil
),
]
],
shadowsocksPortRanges: []
),
bridge: REST.ServerBridges(shadowsocks: [
REST.ServerShadowsocks(protocol: "tcp", port: 443, cipher: "aes-256-gcm", password: "mullvad"),
Expand Down
3 changes: 2 additions & 1 deletion ios/MullvadVPNTests/MullvadREST/Relay/RelayCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ extension REST.ServerRelaysResponse {
ipv4Gateway: .loopback,
ipv6Gateway: .loopback,
portRanges: [],
relays: serverRelays
relays: serverRelays,
shadowsocksPortRanges: []
),
bridge: REST.ServerBridges(shadowsocks: [], relays: bridgeRelays)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ extension RelaySelectorTests {
ipv6AddrIn: .loopback,
publicKey: PrivateKey().publicKey.rawValue,
includeInCountry: true,
daita: true
daita: true,
shadowsocksExtraAddrIn: nil
),
]
],
shadowsocksPortRanges: []
),
bridge: REST.ServerBridges(shadowsocks: [], relays: [])
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ extension IPOverrideWrapperTests {
ipv6AddrIn: .any,
publicKey: Data(),
includeInCountry: true,
daita: false
daita: false,
shadowsocksExtraAddrIn: nil
)
}

Expand Down
Loading