Reconnect with current manager and configuration
This commit is contained in:
parent
36ed23ccc4
commit
e2aaffc06f
|
@ -47,6 +47,10 @@ public class MockVPN: VPN {
|
|||
notifyStatus(.disconnected)
|
||||
}
|
||||
|
||||
public func reconnect(after: DispatchTimeInterval) async throws {
|
||||
notifyStatus(.connected)
|
||||
}
|
||||
|
||||
public func reconnect(
|
||||
_ tunnelBundleIdentifier: String,
|
||||
configuration: NetworkExtensionConfiguration,
|
||||
|
|
|
@ -67,6 +67,18 @@ public class NetworkExtensionVPN: VPN {
|
|||
extra: extra
|
||||
)
|
||||
}
|
||||
|
||||
public func reconnect(after: DispatchTimeInterval) async throws {
|
||||
let managers = try await lookupAll()
|
||||
guard let manager = managers.first else {
|
||||
return
|
||||
}
|
||||
if manager.connection.status != .disconnected {
|
||||
manager.connection.stopVPNTunnel()
|
||||
try await Task.sleep(nanoseconds: after.nanoseconds)
|
||||
}
|
||||
try manager.connection.startVPNTunnel()
|
||||
}
|
||||
|
||||
public func reconnect(
|
||||
_ tunnelBundleIdentifier: String,
|
||||
|
|
|
@ -50,7 +50,16 @@ public protocol VPN {
|
|||
) async throws
|
||||
|
||||
/**
|
||||
Reconnects to the VPN.
|
||||
Reconnects to the VPN with current configuration.
|
||||
|
||||
- Parameter after: The reconnection delay.
|
||||
**/
|
||||
func reconnect(
|
||||
after: DispatchTimeInterval
|
||||
) async throws
|
||||
|
||||
/**
|
||||
Reconnects to the VPN installing a new configuration.
|
||||
|
||||
- Parameter tunnelBundleIdentifier: The bundle identifier of the tunnel extension.
|
||||
- Parameter configuration: The configuration to install.
|
||||
|
|
Loading…
Reference in New Issue