-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate settings to Version3 and introduce incremental migration scheme.
- Loading branch information
1 parent
4f40522
commit c7eecb7
Showing
16 changed files
with
460 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// StoredWgKeyData.swift | ||
// MullvadSettings | ||
// | ||
// Created by Marco Nikic on 2023-10-23. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import WireGuardKitTypes | ||
|
||
public struct StoredWgKeyData: Codable, Equatable { | ||
/// Private key creation date. | ||
public var creationDate: Date | ||
|
||
/// Last date a rotation was attempted. Nil if last attempt was successful. | ||
public var lastRotationAttemptDate: Date? | ||
|
||
/// Private key. | ||
public var privateKey: PrivateKey | ||
|
||
/// Next private key we're trying to rotate to. | ||
/// Added in 2023.3 | ||
public var nextPrivateKey: PrivateKey? | ||
|
||
public init( | ||
creationDate: Date, | ||
lastRotationAttemptDate: Date? = nil, | ||
privateKey: PrivateKey, | ||
nextPrivateKey: PrivateKey? = nil | ||
) { | ||
self.creationDate = creationDate | ||
self.lastRotationAttemptDate = lastRotationAttemptDate | ||
self.privateKey = privateKey | ||
self.nextPrivateKey = nextPrivateKey | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// TunnelSettingsV3.swift | ||
// MullvadVPN | ||
// | ||
// Created by Marco Nikic on 2023-10-17. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MullvadREST | ||
import MullvadTypes | ||
|
||
public struct TunnelSettingsV3: Codable, Equatable, TunnelSettings { | ||
/// Relay constraints. | ||
public var relayConstraints: RelayConstraints | ||
|
||
/// DNS settings. | ||
public var dnsSettings: DNSSettings | ||
|
||
/// WireGuard obfuscation settings | ||
public var wireGuardObfuscation: WireGuardObfuscationSettings | ||
|
||
public init( | ||
relayConstraints: RelayConstraints = RelayConstraints(), | ||
dnsSettings: DNSSettings = DNSSettings(), | ||
wireGuardObfuscation: WireGuardObfuscationSettings = WireGuardObfuscationSettings() | ||
) { | ||
self.relayConstraints = relayConstraints | ||
self.dnsSettings = dnsSettings | ||
self.wireGuardObfuscation = wireGuardObfuscation | ||
} | ||
|
||
public func upgradeToNextVersion() -> any TunnelSettings { | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// WireGuardObfuscationSettings.swift | ||
// MullvadVPN | ||
// | ||
// Created by Marco Nikic on 2023-10-17. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WireGuardObfuscationState: Codable { | ||
case automatic | ||
case on | ||
case off | ||
} | ||
|
||
public enum WireGuardObfuscationPort: Codable { | ||
case automatic | ||
case port80 | ||
case port5001 | ||
} | ||
|
||
public struct WireGuardObfuscationSettings: Codable, Equatable { | ||
let state: WireGuardObfuscationState | ||
let port: WireGuardObfuscationPort | ||
|
||
public init(state: WireGuardObfuscationState = .automatic, port: WireGuardObfuscationPort = .automatic) { | ||
self.state = state | ||
self.port = port | ||
} | ||
} |
Oops, something went wrong.