diff --git a/CHANGELOG.md b/CHANGELOG.md index 921907b..353a6ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgrade OpenSSL to 1.1.1q. - Use natively async methods from NetworkExtension. [#284](https://github.com/passepartoutvpn/tunnelkit/pull/284) - OpenVPN: Unmask PUSH_REPLY and network settings in logs. +- OpenVPN: Delay tunnel disposal. [#311](https://github.com/passepartoutvpn/tunnelkit/pull/311) ### Fixed diff --git a/Sources/TunnelKitOpenVPNAppExtension/OpenVPNTunnelProvider.swift b/Sources/TunnelKitOpenVPNAppExtension/OpenVPNTunnelProvider.swift index bd92873..edc35d8 100644 --- a/Sources/TunnelKitOpenVPNAppExtension/OpenVPNTunnelProvider.swift +++ b/Sources/TunnelKitOpenVPNAppExtension/OpenVPNTunnelProvider.swift @@ -331,6 +331,13 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider { } private func disposeTunnel(error: Error?) { + log.info("Dispose tunnel in \(reconnectionDelay) milliseconds...") + tunnelQueue.asyncAfter(deadline: .now() + .milliseconds(reconnectionDelay)) { [weak self] in + self?.reallyDisposeTunnel(error: error) + } + } + + private func reallyDisposeTunnel(error: Error?) { flushLog() // failed to start