All models now Equatable
This commit is contained in:
parent
053c655fc0
commit
8fb8d9a9d2
|
@ -19,6 +19,7 @@ DerivedData
|
||||||
*.perspectivev3
|
*.perspectivev3
|
||||||
!default.perspectivev3
|
!default.perspectivev3
|
||||||
xcuserdata
|
xcuserdata
|
||||||
|
*.xcscheme
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
*.xccheckout
|
*.xccheckout
|
||||||
|
|
|
@ -12,6 +12,12 @@ struct DNSServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension DNSServer: Equatable {
|
||||||
|
static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
|
||||||
|
return lhs.address.rawValue == rhs.address.rawValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension DNSServer {
|
extension DNSServer {
|
||||||
var stringRepresentation: String {
|
var stringRepresentation: String {
|
||||||
return "\(address)"
|
return "\(address)"
|
||||||
|
|
|
@ -14,6 +14,19 @@ struct Endpoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Endpoint: Equatable {
|
||||||
|
static func == (lhs: Endpoint, rhs: Endpoint) -> Bool {
|
||||||
|
return lhs.host == rhs.host && lhs.port == rhs.port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Endpoint: Hashable {
|
||||||
|
func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(host)
|
||||||
|
hasher.combine(port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension Endpoint {
|
extension Endpoint {
|
||||||
var stringRepresentation: String {
|
var stringRepresentation: String {
|
||||||
switch host {
|
switch host {
|
||||||
|
|
|
@ -14,6 +14,19 @@ struct IPAddressRange {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension IPAddressRange: Equatable {
|
||||||
|
static func == (lhs: IPAddressRange, rhs: IPAddressRange) -> Bool {
|
||||||
|
return lhs.address.rawValue == rhs.address.rawValue && lhs.networkPrefixLength == rhs.networkPrefixLength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension IPAddressRange: Hashable {
|
||||||
|
func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(address.rawValue)
|
||||||
|
hasher.combine(networkPrefixLength)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension IPAddressRange {
|
extension IPAddressRange {
|
||||||
var stringRepresentation: String {
|
var stringRepresentation: String {
|
||||||
return "\(address)/\(networkPrefixLength)"
|
return "\(address)/\(networkPrefixLength)"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
|
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import Network
|
||||||
|
|
||||||
struct InterfaceConfiguration {
|
struct InterfaceConfiguration {
|
||||||
var privateKey: Data
|
var privateKey: Data
|
||||||
|
@ -17,3 +18,16 @@ struct InterfaceConfiguration {
|
||||||
self.privateKey = privateKey
|
self.privateKey = privateKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension InterfaceConfiguration: Equatable {
|
||||||
|
static func == (lhs: InterfaceConfiguration, rhs: InterfaceConfiguration) -> Bool {
|
||||||
|
let lhsAddresses = lhs.addresses.filter { $0.address is IPv4Address } + lhs.addresses.filter { $0.address is IPv6Address }
|
||||||
|
let rhsAddresses = rhs.addresses.filter { $0.address is IPv4Address } + rhs.addresses.filter { $0.address is IPv6Address }
|
||||||
|
|
||||||
|
return lhs.privateKey == rhs.privateKey &&
|
||||||
|
lhsAddresses == rhsAddresses &&
|
||||||
|
lhs.listenPort == rhs.listenPort &&
|
||||||
|
lhs.mtu == rhs.mtu &&
|
||||||
|
lhs.dns == rhs.dns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,3 +25,24 @@ struct PeerConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension PeerConfiguration: Equatable {
|
||||||
|
static func == (lhs: PeerConfiguration, rhs: PeerConfiguration) -> Bool {
|
||||||
|
return lhs.publicKey == rhs.publicKey &&
|
||||||
|
lhs.preSharedKey == rhs.preSharedKey &&
|
||||||
|
Set(lhs.allowedIPs) == Set(rhs.allowedIPs) &&
|
||||||
|
lhs.endpoint == rhs.endpoint &&
|
||||||
|
lhs.persistentKeepAlive == rhs.persistentKeepAlive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PeerConfiguration: Hashable {
|
||||||
|
func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(publicKey)
|
||||||
|
hasher.combine(preSharedKey)
|
||||||
|
hasher.combine(Set(allowedIPs))
|
||||||
|
hasher.combine(endpoint)
|
||||||
|
hasher.combine(persistentKeepAlive)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,3 +22,11 @@ final class TunnelConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TunnelConfiguration: Equatable {
|
||||||
|
static func == (lhs: TunnelConfiguration, rhs: TunnelConfiguration) -> Bool {
|
||||||
|
return lhs.name == rhs.name &&
|
||||||
|
lhs.interface == rhs.interface &&
|
||||||
|
Set(lhs.peers) == Set(rhs.peers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -477,6 +477,7 @@
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 6FF4AC26211EC472002C96EB /* Build configuration list for PBXNativeTarget "WireGuard" */;
|
buildConfigurationList = 6FF4AC26211EC472002C96EB /* Build configuration list for PBXNativeTarget "WireGuard" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
|
5F784E5721CDF6DD00B8D9A0 /* Strip Trailing Whitespace */,
|
||||||
5F45417A21C0902400994C13 /* Swiftlint */,
|
5F45417A21C0902400994C13 /* Swiftlint */,
|
||||||
6B87860E2189532500C099FB /* Extract wireguard-go Version */,
|
6B87860E2189532500C099FB /* Extract wireguard-go Version */,
|
||||||
6FF4AC10211EC46F002C96EB /* Sources */,
|
6FF4AC10211EC46F002C96EB /* Sources */,
|
||||||
|
@ -606,6 +607,24 @@
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
||||||
};
|
};
|
||||||
|
5F784E5721CDF6DD00B8D9A0 /* Strip Trailing Whitespace */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Strip Trailing Whitespace";
|
||||||
|
outputFileListPaths = (
|
||||||
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "find . -name '*.swift' -exec sed -i '' -E 's/[[:space:]]+$//g' {} +\n";
|
||||||
|
};
|
||||||
6B87860E2189532500C099FB /* Extract wireguard-go Version */ = {
|
6B87860E2189532500C099FB /* Extract wireguard-go Version */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TunnelsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
let newTunnels = managers.map { TunnelContainer(tunnel: $0) }.sorted { $0.name < $1.name }
|
let newTunnels = managers.map { TunnelContainer(tunnel: $0) }.sorted { $0.name < $1.name }
|
||||||
let hasChanges = self.tunnels.map { $0.name } != newTunnels.map { $0.name }
|
let hasChanges = self.tunnels.map { $0.tunnelConfiguration } != newTunnels.map { $0.tunnelConfiguration }
|
||||||
if hasChanges {
|
if hasChanges {
|
||||||
self.tunnels = newTunnels
|
self.tunnels = newTunnels
|
||||||
completionHandler(true)
|
completionHandler(true)
|
||||||
|
|
|
@ -13,6 +13,10 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||||
private var lastFirstInterface: NWInterface?
|
private var lastFirstInterface: NWInterface?
|
||||||
private var packetTunnelSettingsGenerator: PacketTunnelSettingsGenerator?
|
private var packetTunnelSettingsGenerator: PacketTunnelSettingsGenerator?
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
networkMonitor?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
|
override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
|
||||||
let activationAttemptId = options?["activationAttemptId"] as? String
|
let activationAttemptId = options?["activationAttemptId"] as? String
|
||||||
let errorNotifier = ErrorNotifier(activationAttemptId: activationAttemptId)
|
let errorNotifier = ErrorNotifier(activationAttemptId: activationAttemptId)
|
||||||
|
|
Loading…
Reference in New Issue