-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VPN server failure detection recovery (#786)
* Small tidy up to remove dependency cycle * Inject settings rather than environment to client * Add failure recovery register request * Add log category for failure recovery * Label the config+server tuple values * Store server not just info * Abstract reasserting from PacketTunnelProvider * Create failurerecoveryHandler + empty tests * Pull updating adapter config into helper function * Pull deviceManager into a lazy var * Add failure monitoring and recovery to PTP * Remove location from request * Don't regenerate the key on failure recovery * Fix broken existing tests * Write tests for failureRecoveryHandler * Add comment about todo pixel * Update function name to be more consistent * Make sure tunnelUpdateAttempt pixels are fired * Fix swiftlint * Add initial retry logic * Add more logging * Fixed no recovery errors * Update tests for failure recovery * Stop failure monitor when handshake succeeds * Tidy up from PR feedback * Add events for pixels * Tidy up tests * Swiftlint fixes * Tidy up error handling * Fix reasserting problem * Swiftlint * Another swiftlint fix * Make devicemanager property private * Remove... x? (wtf) * Use convenience serverInfo property Co-authored-by: Anh Do <[email protected]> * Use the typealiased tuple Co-authored-by: Anh Do <[email protected]> * Revert to injecting environment not settings * Always stop reasserting regardless of result * Fix retry logic * Better handle task cancellation * Improve readability of GenrateTunnelConfigurationResult * Make sure netP convertible errors are converted --------- Co-authored-by: Anh Do <[email protected]>
- Loading branch information
1 parent
8d8f54f
commit 2681b52
Showing
15 changed files
with
922 additions
and
56 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
30 changes: 30 additions & 0 deletions
30
Sources/NetworkProtection/Diagnostics/WireGuardAdapter+HandshakeReporting.swift
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,30 @@ | ||
// | ||
// WireGuardAdapter+HandshakeReporting.swift | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol HandshakeReporting { | ||
/// Retrieves the number of seconds of the most recent handshake for the previously added peer entry, expressed relative to the Unix epoch. | ||
/// | ||
/// - Throws: ConfigReadingError | ||
/// - Returns: Interval between the most recent handshake and the Unix epoch. | ||
/// | ||
func getMostRecentHandshake() async throws -> TimeInterval | ||
} | ||
|
||
extension WireGuardAdapter: HandshakeReporting {} |
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
Oops, something went wrong.