blob: 0cba62661bc02beadf9dddf2859a0731595413d3 (
plain)
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
|
//
// RelayWithLocation.swift
// MullvadREST
//
// Created by Mojgan on 2024-05-17.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadTypes
public struct RelayWithLocation<T: AnyRelay> {
let relay: T
public let serverLocation: Location
func matches(location: RelayLocation) -> Bool {
return switch location {
case let .country(countryCode):
serverLocation.countryCode == countryCode
case let .city(countryCode, cityCode):
serverLocation.countryCode == countryCode &&
serverLocation.cityCode == cityCode
case let .hostname(countryCode, cityCode, hostname):
serverLocation.countryCode == countryCode &&
serverLocation.cityCode == cityCode &&
relay.hostname == hostname
}
}
}
extension RelayWithLocation: Equatable {
public static func == (lhs: RelayWithLocation<T>, rhs: RelayWithLocation<T>) -> Bool {
lhs.relay.hostname == rhs.relay.hostname
}
}
|