Skip to content

Commit 7567036

Browse files
committed
Fix the issue in smart routing when selecting one to many relays
1 parent 8fcdf86 commit 7567036

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

ios/MullvadREST/Relay/MultihopDecisionFlow.swift

-5
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ struct OneToMany: MultihopDecisionFlow {
9292
)
9393
}
9494

95-
guard !daitaAutomaticRouting else {
96-
return try ManyToOne(next: next, relayPicker: relayPicker)
97-
.pick(entryCandidates: entryCandidates, exitCandidates: exitCandidates, daitaAutomaticRouting: true)
98-
}
99-
10095
let entryMatch = try multihopPicker.findBestMatch(from: entryCandidates, useObfuscatedPortIfAvailable: true)
10196
let exitMatch = try multihopPicker.exclude(
10297
relay: entryMatch,

ios/MullvadVPNTests/MullvadREST/Relay/MultihopDecisionFlowTests.swift

+11-3
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,22 @@ class MultihopDecisionFlowTests: XCTestCase {
112112
let entryCandidates = [seSto2]
113113
let exitCandidates = [seSto2, seSto6]
114114

115-
let selectedRelays = try oneToMany.pick(
115+
let selectedRelaysWithoutSmartRouting = try oneToMany.pick(
116116
entryCandidates: entryCandidates,
117117
exitCandidates: exitCandidates,
118118
daitaAutomaticRouting: false
119119
)
120120

121-
XCTAssertEqual(selectedRelays.entry?.hostname, "se2-wireguard")
122-
XCTAssertEqual(selectedRelays.exit.hostname, "se6-wireguard")
121+
XCTAssertEqual(selectedRelaysWithoutSmartRouting.entry?.hostname, "se2-wireguard")
122+
XCTAssertEqual(selectedRelaysWithoutSmartRouting.exit.hostname, "se6-wireguard")
123+
124+
let selectedRelaysWithSmartRouting = try XCTUnwrap(oneToMany.pick(
125+
entryCandidates: [seSto2],
126+
exitCandidates: [seSto2, seSto6],
127+
daitaAutomaticRouting: true
128+
))
129+
XCTAssertEqual(selectedRelaysWithSmartRouting.entry?.hostname, "se2-wireguard")
130+
XCTAssertEqual(selectedRelaysWithSmartRouting.exit.hostname, "se6-wireguard")
123131
}
124132

125133
func testManyToOnePick() throws {

0 commit comments

Comments
 (0)