Call cancelTunnelWithError(_:) if a connection fails and won't be retried
This commit is contained in:
parent
12ba6f34b7
commit
1cd00f9459
|
@ -579,6 +579,18 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
public func sessionDidStop(_: OpenVPNSession, shouldReconnect: Bool) {
|
||||
log.info("Session did stop")
|
||||
|
||||
stopSession(shouldReconnect: shouldReconnect)
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public func sessionFailed(_: OpenVPNSession, error: Error) {
|
||||
log.info("Session failed")
|
||||
|
||||
cancelTunnelWithError(error)
|
||||
stopSession(shouldReconnect: false)
|
||||
}
|
||||
|
||||
private func stopSession(shouldReconnect: Bool) {
|
||||
isCountingData = false
|
||||
refreshDataCount()
|
||||
|
||||
|
|
|
@ -59,6 +59,11 @@ public protocol OpenVPNSessionDelegate: class {
|
|||
- Seealso: `OpenVPNSession.reconnect(...)`
|
||||
*/
|
||||
func sessionDidStop(_: OpenVPNSession, shouldReconnect: Bool)
|
||||
|
||||
/**
|
||||
Called after a session failed to start.
|
||||
*/
|
||||
func sessionFailed(_: OpenVPNSession, error: Error)
|
||||
}
|
||||
|
||||
/// Provides methods to set up and maintain an OpenVPN session.
|
||||
|
@ -1275,14 +1280,16 @@ public class OpenVPNSession: Session {
|
|||
}
|
||||
|
||||
private func doShutdown(error: Error?) {
|
||||
stopError = error
|
||||
|
||||
if let error = error {
|
||||
log.error("Trigger shutdown (error: \(error))")
|
||||
delegate?.sessionFailed(self, error: error)
|
||||
} else {
|
||||
log.info("Trigger shutdown on request")
|
||||
}
|
||||
stopError = error
|
||||
delegate?.sessionDidStop(self, shouldReconnect: false)
|
||||
}
|
||||
}
|
||||
|
||||
private func doReconnect(error: Error?) {
|
||||
if let error = error {
|
||||
|
|
Loading…
Reference in New Issue