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)
|
notifyStatus(.disconnected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func reconnect(after: DispatchTimeInterval) async throws {
|
||||||
|
notifyStatus(.connected)
|
||||||
|
}
|
||||||
|
|
||||||
public func reconnect(
|
public func reconnect(
|
||||||
_ tunnelBundleIdentifier: String,
|
_ tunnelBundleIdentifier: String,
|
||||||
configuration: NetworkExtensionConfiguration,
|
configuration: NetworkExtensionConfiguration,
|
||||||
|
|
|
@ -68,6 +68,18 @@ public class NetworkExtensionVPN: VPN {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
public func reconnect(
|
||||||
_ tunnelBundleIdentifier: String,
|
_ tunnelBundleIdentifier: String,
|
||||||
configuration: NetworkExtensionConfiguration,
|
configuration: NetworkExtensionConfiguration,
|
||||||
|
|
|
@ -50,7 +50,16 @@ public protocol VPN {
|
||||||
) async throws
|
) 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 tunnelBundleIdentifier: The bundle identifier of the tunnel extension.
|
||||||
- Parameter configuration: The configuration to install.
|
- Parameter configuration: The configuration to install.
|
||||||
|
|
Loading…
Reference in New Issue